Skip to content

Commit 33bfb79

Browse files
authored
Add files via upload
1 parent f73be57 commit 33bfb79

File tree

11 files changed

+164
-0
lines changed

11 files changed

+164
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
import random # A library to generate random choices
3+
4+
# variables to store options
5+
ROCK = 'r'
6+
SCISSORS = 's'
7+
PAPER = 'p'
8+
9+
emojis = {ROCK:'🪨', PAPER:'📃', SCISSORS:'✂️'} # A dictionary to store option keys with emoji values
10+
options = tuple(emojis.keys()) # A tuple to store option values
11+
12+
13+
14+
def get_user_choice():# A function to return a user choice
15+
16+
user_input = input("Rock, paper, or scissors? (r/p/s): ")
17+
18+
if user_input in options:
19+
return user_input
20+
else:
21+
print("Invalid input")
22+
23+
24+
25+
def display_choices(cpu, user_input): # A function that displays the choices (cpu, user_input)
26+
27+
print(f"You chose {emojis[user_input]}")
28+
print(f"Computer chose {emojis[cpu]}")
29+
30+
31+
def determine_winner(cpu, user_input): # A function that determines the winner
32+
33+
if ((user_input == ROCK and cpu == SCISSORS) or
34+
(user_input == SCISSORS and cpu == PAPER) or
35+
(user_input == PAPER and cpu == ROCK)):
36+
print("You won!🥳")
37+
elif(user_input == cpu):
38+
print("You tie!😎")
39+
else:
40+
print("You lose!😢")
41+
42+
43+
def Game():# A function to return various functions to start the game.
44+
while True:
45+
user_input = get_user_choice()
46+
47+
cpu = random.choice(options)
48+
49+
display_choices(cpu, user_input)
50+
51+
determine_winner(cpu, user_input)
52+
53+
Continue = input("Do you want to continue (y/n)😊: ").lower()
54+
55+
if Continue == 'n':
56+
print("Thanks for playing!😁")
57+
break
58+
59+
# Calling the Game function to initialize the program.
60+
Game()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Simple Dice Rolling game
2+
import random # random library for generating random numbers
3+
4+
def roll_dice(): # A function to roll the dice
5+
while True: # while playing the game
6+
7+
user_input = input("Roll the dice? (y/n): ").lower() # Accepting user inputs in lower case
8+
9+
if user_input == "y": # Continue if user_input is y
10+
11+
die1 = random.randint(1,6) # variables for dice
12+
die2 = random.randint(1,6)
13+
14+
print(f"You rolled a {die1} and a {die2}")
15+
16+
elif user_input == "n": # Break from the loop if user input is n
17+
print("Thanks for playing...")
18+
break
19+
20+
else: # Check if user input is invalid
21+
print("Invalid input")
22+
23+
roll_dice()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# A simple number guessing game using python.
2+
import random # For random numbers
3+
4+
def number_guessing():
5+
number = random.randint(1,100)
6+
while True:
7+
8+
try:
9+
guess = int(input("Guess a number from 1 to 100: "))
10+
11+
if number == guess:
12+
print("Congratulations! You guessed the number!")
13+
break
14+
elif number > guess:
15+
print("Too low!")
16+
else:
17+
print("Too high!")
18+
19+
20+
except ValueError:
21+
print("Enter a valid number")
22+
23+
number_guessing()
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from email.message import EmailMessage # A library that provides email methods
2+
import ssl # A library that helps to send message
3+
import smtplib
4+
from variables import password # Importing stored variables.
5+
6+
def Email_Details():
7+
sender_email = input('Please enter your email address: ').strip().lower()
8+
9+
email_password = password
10+
11+
receiver_email = input('Please enter the recipient email address: ').strip().lower()
12+
13+
subject = input('Enter the email subject: ')
14+
15+
body = input("Enter your email message: \n")
16+
17+
return sender_email, receiver_email, email_password, subject, body
18+
19+
20+
def send_email(sender_email, receiver_email, subject, body):
21+
em = EmailMessage()
22+
em['From'] = sender_email
23+
em['To'] = receiver_email
24+
em['Subject'] = subject
25+
em.set_content(body)
26+
27+
return em
28+
29+
def Login(sender_email, receiver_email, email_password, em):
30+
context = ssl.create_default_context()
31+
32+
with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
33+
smtp.login(sender_email, email_password)
34+
smtp.sendmail(sender_email, receiver_email, em.as_string())
35+
36+
def Main():
37+
sender_email, receiver_email, email_password, subject, body = Email_Details()
38+
em = send_email(sender_email, receiver_email, subject, body)
39+
Login(sender_email, receiver_email, email_password, em)
40+
print(" ")
41+
print('Email sent successfully!')
42+
43+
Main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
password = 'dffk pipb gsbm vgba'
555 Bytes
Loading

0 commit comments

Comments
 (0)