Posts

try and except error handling

  try :     a = int ( input ( "enter you number" ))     print ( a ) except :     print ( "error" )

try except error handling

  try :     a = int ( input ( "enter your age: " ))     print ( a ) except :     print ( "some error occured" )

I created a average function using def

  def average ( a , b ):     return ( a + b ) / 2 print ( average ( 2 , 3 ))

MATCH in python (imp)

  a = int ( input ( "enter the number : " )) match a :     case 1 :         print ( "case is 1" )     case 2 :         print ( "case is 2" )     case 3 :         print ( "case is 3" )     case _:         print ( "there is no such case" )

multiplication by use of for and if

  a = int ( input ( "enter the no. for which you want the table : " )) print ( "the multiplication table of :" , a ) for count in range ( 1 , 999 ):     print ( a , 'x' , count , '=' , a * count )

if and else

  age = int ( input ( "enter you age :" )) if ( age > 17 ):   print ( "yes you can drive" ) else :   print ( "no you can't" )