Posts

Showing posts from September, 2021

perfect code for guess the number

  # guess wala game  print ( "You have only 9 attempt to guess the nunber" ) hima = 1 while ( hima <= 9 ):       qwer = int ( input ( "Enter your number:"  ))    if   qwer >= 20 :      print ( "you have to choose number  less than you enter" )    elif   18 < qwer < 20 :      print ( "you have to choose a number very less lesser than you enter" )    elif   qwer <= 15 :      print ( "you have to choose number  greater than you enter:" )    elif   15 < qwer < 18 :      print ( "you have to choose a number very less greater than  you...

Code for a number greater than 100

  # we have to make a program if user type less than 100 than the program will continue otherwise it will stop. while ( True ):      a = int ( input ( "Enter the number:"  ))      if   a > 100 :          print ( "Congragulation you enter the number greator than 100" )          break      else :        print ( "Make sure you enter a number greater than 100." )      continue         

A faulty calculator which give some different value for some values

  #Exercise Faulty Calculator #45*3=555, 56+9=77,56/6=4 # We have to make faulty calculator which will give the incorrect value for these number else give correct value for any other operation def   add ( a , b ):    result =( a + b )    print ( result ) def    sub ( a , b ):      result =( a - b )      print ( result ) def    mul ( a , b ):      result =( a * b )      print ( result ) def   div ( a , b ):      result =( a / b )      print ( result ) a = int ( input ( "Enter the first number: " )) b = int ( input ( "Enter the second number: " )) op = input ( "Enter the opearator: " ) if    a == 45   and   b == 3 ...

code for find the determinant of 3x3 matrix

  a1 = int ( input ( "Enter R11: " )) a2 = int ( input ( "Enter R12: " )) a3 = int ( input ( "Emter R13: " )) a4 = int ( input ( "Emter R21: " )) a5 = int ( input ( "Emter R22: " )) a6 = int ( input ( "Emter R23: " )) a7 = int ( input ( "Emter R31: " )) a8 = int ( input ( "Emter R32: " )) a9 = int ( input ( "Emter R33: " )) b =( a1 )*( a5 * a9 - a8 * a6 ) c =(- 1 )*( a2 )*( a4 * a9 - a7 * a6 ) d =( a3 )*( a4 * a8 - a7 * a5 ) e = b + c + d if        a1 == int ( a1 ):      print ( "The determinant of the given matrix is:" , e ) elif   a2 == int ( a2 ):      print ( "The determinant of the given matrix is:" , e ) elif   a3 == int ( a3 ):      print ( "The determinant of the given matrix is:" , e ) elif   ...

code for finding the determinant of 2x2 matrix

  input ( "Enter the Matrix of 2x2 order only." ) a1 = int ( input ( "Enter R11:" )) a2 = int ( input ( "Enter R12: " )) a3 = int ( input ( "Enter R21: " )) a4 = int ( input ( "Enter R22: " )) b =( a1 * a4 )-( a3 * a2 ) if   a1 == int ( a1 ):      print ( "The determinant of the given matrix is:" , b ) elif   a2 == int ( a2 ):   print ( "The determinant of the given matrix is:" , b ) elif   a3 == int ( a3 ):       print ( "The determinant of the given matrix is:" , b ) elif   a4 == int ( a4 ):    print ( "The determinant of the given matrix is:" , b ) else :    print ( "Enter only numeric value." )

code for a simple calculator

  def   add ( a , b ):     result =( a + b )     print ( result ) def   sub ( a , b ):     result =( a - b )     print ( result ) def   mul ( a , b ):   result =( a * b )   print ( result ) def   div ( a , b ):    result =( a / b )    print ( result ) a = int ( input ( "Enter the first number: " )) b = int ( input ( "Enter the second number: " )) op = input ( "Enter the operator: " )   if   op == "+" :       print ( add ( a , b )) elif   op == "-" :    print ( sub ( a , b )) elif   op == "*" :    print ( mul ( a , b )) elif   op == "/" :    print ( div ( a , b )) else :    print ( "Enter the correct operator. \n "  )

My first table code and I learned after that

  #include   <stdio.h> /*  Print the table entered by the user */ int   main () {  int   a ;     printf ( "Enter The desire no. of which you want the table: \n " );     scanf ( " %d " ,& a ); /*int printf(const char *, ...)*/ printf ( "Table of desire no is  %d : \n " , a );     printf ( " %d x1= %d \n " , a , a * 1 );     printf ( " %d x2= %d \n " , a , a * 2 );     printf ( " %d x3= %d \n " , a ,  a * 3 );     printf ( " %d x4= %d \n " , a ,  a * 4 );     printf ( " %d x5= %d \n " , a , a * 5 );     printf ( " %d x6= %d \n " , a , a * 6 );     printf ( " %d x7= %d \n " , a , a * 7 );     printf ( " %d x8= %d \n " , a , a * 8 );     printf ( " %d ...