#Q. Create a Calculator that will return all the results correctly except the following ones: # a)45678*90 # b) 205000/56 # c) 3456709876+0987654566 num1 = float ( input ( "Enter your 1st Operand: " )) num2 = float ( input ( "Enter your 2nd Operand: " )) # num3 = float(input("Enter your 3rd Operand: ")) sign = int ( input ( "Enter your Operator's Choice from the following: 1 for Addition, 2 for Multiplication, 3 for Division " )) # Use the match statement with case instead of match alone match sign: case 1 : if num1 == 3456709876 and num2 == 987654566 : print ( "36666666666" ) else : print (num1 + num2 ) case 2 : if num1 == 45678.0 and num2 == 90 : print ( "36666" ) else : print (num1 * num2) case 3 : if num1 == 205000.0 and num2 == 56 : print ( "366" ) else : print (num1 / num2) ...
# Snake Water Gun #Snake,Water and Gun is a variation of the children's game "Rock-Paper-Scissors" # where players use hand gestures to represent a snake, water, or a gun. # The gun beats the snake, the water beats the gun, and the snake beats the water. # Write a python program to create a Snake Water Gun game in Python using if-else statements. # Don't create any fancy GUI. Use proper functions to check for win. # S W G # Computer = 0 1 2 # Player = S 0 D W L # W 1 L D W # G 2 W L D import random def check (comp,user): if comp == user: return 0 if comp == 2 and user == 0 : return - 1 if comp == 1 and user == 2 : return - 1 if comp == 0 and user == 1 : return - 1 else : return 1 comp =random.randint( 0 , 2 ) # print(comp) user = int ( input ( "0 for Snake, 1 for Water, 2 for Gun: \n " )) print ( "You:" ,user) print ( "C...
Comments
Post a Comment