Python Essentials Classroom Series – 03/Sept/2021


  • Floating point numbers (decimal numbers) are floats in python Preview
  • we can use all the operators which we have used for integer
  • To convert other types to float we have float() function Preview

input method in python

  • Input method in python is used to accept input from the command line or terminal
  • input function always returns a type string.
  • if we need to use it as int or float we need to use int() or float() methods Preview

Comments in python

  • When we write python anything after # is a comment and is used for readability purposes and will not be executed by interpreter

Conditional Statments if, elif and else

  • The syntax of the conditional statement if
if <conditional expression>:

  • The conditional expression should return a boolean i.e True or False. The code block will be executed in the case of true
flag = False
if flag:
    print('This code is executing as flag is True')
    print('line 1')
    print('line 2')
    print('line 3')
print('This code is outside of if statement')
  • Exercise:
    • Create a file.
    • ask the input from the user and store it is integer
    • if the value is greater than 5 print good
x = int(input('Enter the number: '))

if x > 5:
  • We have one more flavor if else
if <expression>:
   <code block>
   <code block>
  • we have one more flavor if elif else
if <condition>:
elif <condition>:
  • Lets write a program which accepts the aggregate marks and prints the grade
average = int(input('Enter the average marks: '))

if 92 <= average <= 100 :
elif 83 <= average <= 91:
elif 75 <= average <= 82:
elif 67 <= average <= 74:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin