0% found this document useful (0 votes)
8 views3 pages

Imppython Codes

The document contains code snippets for three different programs: a Rock Paper Scissors game, a simple name output, and calculations for sum, product, and division. The Rock Paper Scissors game allows user input to determine the winner against a computer choice. The other snippets perform basic arithmetic operations, displaying results for sums and products of numbers.

Uploaded by

svshekar88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Imppython Codes

The document contains code snippets for three different programs: a Rock Paper Scissors game, a simple name output, and calculations for sum, product, and division. The Rock Paper Scissors game allows user input to determine the winner against a computer choice. The other snippets perform basic arithmetic operations, displaying results for sums and products of numbers.

Uploaded by

svshekar88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

ROCK PAPER SCISSORS

import random

uScore = 0

cScore = 0

print("****rock paper scissors*****")

print("Rules:")

print("1. rock beats scissors")

print("2. scissors beats paper")

print("3. paper beats rock")

print()

def game():

choice = input("pick one: r for rock,p for paper or s for scissors:")

if choice == "r":

user_choice = "Rock"

elif choice == "p":

user_choice = "Paper"

elif choice == "s":

user_choice = "scissors"

else:

User_choice = "wrong entry! Try again"

computer_choice = random.choice(["Rock","paper","scissors"])

print(f"\nYouchose {user_choice}, computer chose {computer_choice} . \n")

game()

print("")

if user_choice == computer_choice:

print("result: tie")
elif user_choice == "Rock" and Computer_choice == "scissors":

print("result:you win!")

uscore = uscore+1

elif User_choice == "Paper" and computer_choice == "Rock":

print("Result:you win!")

uScore = uScore+1

else:

print("result:you lose!")

cScore = cScore + 1

2.ENTER YOUR NAME

print (" My name is shreyank")

3. CALCULATE SUM OR PRODUCT

Sum

numbers = [10, 20, 30, 40]


total_sum = sum(numbers)
print(f"Sum of numbers in list: {total_sum}")

product

num1 = 5
num2 = 10
num3 = 2
product = num1 * num2 * num3
print(product) # Output: 100

DIVISION
num1 = 10

num2 = 9

result = num1/num2

print(f"the normal division of {num1} by {num2} is: {result}")

You might also like