PYTHON SERIES PART 3

Program 1:- Write a python code to check whether a given number is prime number or not!

Source code:-
def oddeven(x):
If x%2==0: print(“The number”, x, “is even”)
Else: print(“the number”, x, “is odd”)
Num = int(input(“enter a number : “))
oddeven (num)

Program 2:-  Design a rock paper scissor game

Source code:- rom random import randint
choice = [“rock”,”paper”,”scissors”]
def main():
computer = choice[randint(0,2)]
print(“Welcome to the Rock, Paper, Scissors Game\n”)
player = input(“Your Choice: “).lower()
print(“Computer Chose: ” + computer)
if player == computer:
print(“Draw”)
elif player == “rock” and computer == “paper”:
print(“Computer Wins”)
elif player == “rock” and computer == “scissors”:
print(“Player Wins”)
elif player == “paper” and computer == “rock”:
print(“Player Wins”)
elif player == “paper” and computer == “scissors”:
print(“Computer Wins”)
elif player == “scissors” and computer == “rock”:
print(“Computer Wins”)
elif player == “scissors” and computer == “paper”:
print(“Player Wins”)
elif player == “end”:
StopIteration
main()
main()

**suggestion to run: – Write these code in notepad and then save it. Then change the extension of that saved file from .txt to .py and then open again . To preview the source code again you can reverse this procedure too .**

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Share on whatsapp
WhatsApp
Subscribe
Notify of
guest
68 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

Post Author

Newsletter

Make sure to subscribe to our newslatter and be the first to know the news

Total Post Views

View 1424

Topics

Try Short Blogging

FOR FREE

It's free blog spot and
completely risk free