A) Write a program to check your age if you are eligible to vote or not. (age must be equal or greater than 18)
-
B) Write a program to separate the username and the domain parts from the provided email. [eg. sujan@gmail.com, username = sujan domain = gmail.com]
-
C) Write a program to make a digital timer.
-
D) Write a program to make a simple shopping cart.
-
E) Write a program to make a num pad (image for demo)
-
F) Write a program to make a concession stand
-
G) Write a number guessing game in python.
-
H) Rock, Paper, Scissor game
# Rock Paper Scissors game in python
import random
options = ("rock", "paper", "scissors")
playAgain = True
while playAgain:
player = None
computer = random.choice(options)
while player not in options:
player = input("Enter your choice 'rock', 'paper' or 'scissors': ")
print(f"Player: {player}")
print(f"Computer: {computer}")
if player == computer:
print("It's a tie")
# The or \ is a way of continuing a line of code onto the next line in Python.
elif (player == "rock" and computer == "scissors") or \
(player == "paper" and computer == "rock") or \
(player == "scissors" and computer == "paper"):
print("You win")
else:
print("You lose")
conti = input("Wanna play again? (y/n): ")
while conti != 'y' and conti != 'n':
print("Invalid entry, enter y/n:")
conti = input("Wanna play again? (y/n): ")
if conti == 'n':
playAgain = False
break
elif conti == 'y':
computer = random.choice(options)
-
I) Simple encryption program in python
# Encryption program in python
import random
import string
chars = " " + string.punctuation + string.digits + string.ascii_letters
chars = list(chars) #chars is typecasted into list
keys = chars.copy()
random.shuffle(keys)
# Encryption
msg = input("Enter message to encrypt: ")
cipher_text = ""
for letter in msg:
index_ = chars.index(letter)
cipher_text += keys[index_]
print(f"Text encoded: {cipher_text}")
#Decryption
original_msg = ""
cipher = input("Enter the cipher text to decode: ")
for item in cipher:
ind_ = keys.index(item)
original_msg += chars[ind_]
print(f"Original message: {original_msg}")