Posts

Guess number Exercise.3

i= 0 print ( "Enter a number that save you: \n HINT: ^100" ) while ( True ): a= int ( input ()) if a> 101 : print ( "Now you are safe" ) break if a< 101 : print ( "! meyonii omaoma aaa sindeu ttntntntntnttnttnnt \n " ) continue

Some functions#1

# sf=["sfjgj","zgrgrgr","fsdegf","gtezger"] # print(sf) number = [ 2 , 5 , 7 , 8 , 6 , 3 , 1 ] number.reverse() number.sort() print (number[ 4 ]) print (number[ 2 : 8 ]) print ( len (number)) print (number)

Print Stars Exercise.4

print ( "Enter how many rows you want to print" ) j= int ( input ()) print ( "Please enter 1 or 0" ) d= int ( input ()) if d== 1 : for i in range ( 0 ,j+ 1 ): print ( "*" *i) if d== 0 : for i in range ( 0 ,j+ 1 ). __reversed__ (): print ( "*" * i)

IO BASIC

#files IO basics """ # "r" = open file for reading - default mode # "w" = open file for writing or create a new file and it remove all data of file and make a new file when runs # "x" = creates file if not exist # "a" = add more content to a file like append or create a new file.append means add more in file that already exist # "t" = text mode # "b" = binary mode # "+" = write and read mode """

Guess number Exercise.3 #2

x= 1 print ( "Hello this is a no. game .You need to guess a no. If you guess right, you won" ) while (x<= 6 ): inpot= int ( input ( "Enter your number: \n " )) if inpot< 30 : print ( "Please enter greater number \n " ) elif inpot> 30 : print ( "Please enter a smaller number \n " ) else : print ( "You won \n " ) print ( "You complete it in" ,x) break print ( "You complete it in" , 6 -x) x = x + 1 if (x> 6 ): print ( "Oh shit,here we go again" )

Faulty calculator Exercise.2

print ( "Enter first number" ) num1= int ( input ()) print ( "enter your operator" ) op= input () print ( "Enter second number" ) num2= int ( input ()) if op== '+' and num1== 54 and num2== 5 : print ( "64" ) elif op== '*' and num1== 45 and num2== 5 : print ( "555" ) elif op == '/' and num1 == 56 and num2 == 6 : print ( "4" ) elif op== '+' : print (num1+num2) elif op== '-' : print (num1-num2) elif op== '*' : print (num1*num2) elif op== '/' : print (num1/num2) else : print ( "Invalid Input" )