Posts

Python Program To Create Guess a Number Between 1 and 100 Game

  import random n1 = (random.randint( 0 , 100 )) print ( " \t ************************************************" ) print ( " \t \t \t \t Welcome To The Game " ) print ( " \t \t \t Guess a Number between 1 to 10" ) print ( " \t \t \t You Have Only 5 Chance" ) print ( " \t ************************************************" ) guess = 0 over = 5 while (guess <= 5 ): guess = guess + 1 num = int ( input ( "Enter a Number= " )) if num < n1: print ( "Greater Number Please: " ) print (over - guess, "Chances Left" ) elif num > n1: print ( "Lower Number Please: " ) print (over - guess, "Chances Left" ) else : print ( " \n \n You Guess It Right" ) print ( guess, "Attempts" ) break if guess > 5 : print ( "Game Over" )

Python Program to Create a Rock Paper Scissor game

  # Rock Paper Scissor game print ( " \t \t \t \t ************************************************" ) print ( " \t \t \t \t Welcome To The Game Rock Paper Scissor game." ) print ( " \t \t Enter 'R' for 'Rock', 'P' for 'Paper' and 'S' for 'Scissor'" ) print ( " \t You Have Only 5 Chance to play and win. So, let's start this game." ) print ( " \t \t \t \t ************************************************" ) import random comp_win = 0 you_win = 0 chances = 1 while True : comp = random.choice([ "R" , "P" , "S" ]) choice = input ( "Enter 'R' 'P' or 'S': " ) choice = choice.upper() if choice == comp: print ( "Computer and you chose the same. So, one point goes to both of you." ) comp_win = comp_win + 1 you_win = you_win + 1 elif comp == 'R' and choice == 'S'

Python Program For Personal Notepad

  print ( " \t ************************************************" ) print ( " \t \t \t \t Welcome To The Personal Notpad " ) print ( " \t ************************************************" ) i = 0 while (i< 5 ): i = i+ 1 print ( 'What do you want to do(lock or retrive)?' ) a = int ( input ( '1 for Input Information , 2 for retreive the Information: ' )) b = int ( input ( '1 for Work information , 2 for Study information: ' )) c = int ( input ( '1 for Ganesh , 2 for Priti , 3 for Nitesh: ' )) if a == 1 and b == 1 and c == 1 : with open ( 'ganesh-exercise.txt' , 'a' ) as np: inp3 = int ( input ( 'no. of items? :' )) for items in range ( 0 ,inp3): print ( ' write item' ,items + 1 , ' :' ) inp99 = input ( '' ) np.write(inp99+ ' \n ' ) print ( 'succesful

Nested function In Python

  l = 10 def fun1 (): l = 50 def fun2 (): global l l = 88 print (l) fun2() print (l) fun1() print (l)

Python Program to Print the Fibonacci sequence

  n = int ( input ( "Enter Your Number: " )) i = 0 a = 0 b = 1 while i < n: i = i+ 1 print (a) fibo = a+ b a = b b = fibo # print(n,"*"+ int(i), "=" + n*int(i)) print ( "Your Fibonic is Completed" )

Table in Python using While Loop

  n = int ( input ( "Enter Your Number: " )) i = 0 while i < 10 : i = i+ 1 print (n, '*' , i, '=' , n*i) # print(n,"*"+ int(i), "=" + n*int(i)) print ( "Your Table is Completed" )

Python Program to Find the Largest, middle, smallest Number Among Three Numbers

print ( " \t ************************************************" ) print ( " \t \t \t \t Welcome To The Largest Number Calculator " ) print ( " \t ************************************************" ) p = int ( input ( "Enter your First Number: " )) n = int ( input ( "Enter your Second Number: " )) r = int ( input ( "Enter your Third Number: " )) print ( " \n \n " ) #Largest Number if p > n and p > r: print (p, "is The Largest Number" ) elif n > p and n > r : print (n, " is The Largest Number" ) else : print (r, " is The Largest Number" ) # Middle Number if p < n and p > r: print (p, "is The Middle Number" ) elif p > n and p < r: print (n, " is The Middle Number" ) elif n < p and n > r: print (n, " is The Middle Number" ) elif n > p and n < r: print (n, " is The Middle Number" ) else :