Tuesday, 31 March 2020

Date types in python

There are various data types in Python. Some of the important types are listed below.

  1. Number 
  2. String.
  3. List
  4. Tuple
  5. Set
  6. Dictionary

Thursday, 26 March 2020

while loop practice problems python

With the while loop we can execute a set of statements as long as a condition is true.

Example


Print i as long as i is less than 6:
i-> start from 1. While -> condition (Print i as long as i is less than 6 ). Print () -> display.
I + = 1 -> every round (loop)add 1 


i = 1
while i < 6:
  print(i)
  i += 1

For loops and some exercises


For loops are used for sequential traversal. For example: traversing a list or string or array etc. In Python, there is no C style for loop, i.e., for (i=0; i<n; i++). There is “for in” loop which is similar to for each loop in other languages.
for var in iterable
# statements 
In Python, iterable means an object can be used in iteration.