Learning python - 3rd Day (Afternoon)

Watched this tutorial: Click here

I learnt about data types.

How many data types are there in python? -- I thought the answer of this question is complicated.

But no! There are only 8 types of data used in python.

These are:

  • None - means nothing is assigned
  • Numeric - Float, Integer, Complex 
  • List - I have already talked about this here
  • Tuple - This is included in my last blog. Click here to check
  • Set - I have also learnt it in this part
  • String
  • Range - Well this is a new function, I have learnt this also, I am going to write about this after this part.
  • Dictionary - One of the craziest data type. Click here to check how I learnt this
Range:

This is actually a function which can only be found directly in Python,
Lets say I want to get all the numbers from 0-10
I can use for loop in other languages to do this. I can use in python too, but For loop takes much code to do such type of things where we can simply write range(10)

Example:

Input: range(10)
Output: range(0,10)

Input: list(range(10))
Output: [0,1,2,3,4,5,6,7,8,9]

We can also specify start value 
Example:
 
Input: list(range(2,10))
Output: [2,3,4,5,6,7,8,9]

Jump value can also be specified
Example:

Input: list(range(2,10,2))
Output: [2,4,6,8]


















Comments

Popular posts from this blog

Apple iPad Air (2022) Specifications and Review in 2023

17-year-old suspect in fatal stabbing at Taylor Swift-themed dance event ID’d

Exercise vs Diet