Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

# 🚨 Don't change the code below 👇

year = int(input("Which year do you want to check? "))


# 🚨 Don't change the code above 👆

#First *fork* your copy. Then copy-paste your code below this line 👇
#Finally click "Run" to execute the tests

if year % 4 == 0 and year % 100 != 0:


print("Leap year.")
elif year % 4 == 0 and year % 100 == 0:
if year % 400 == 0:
print("Leap year.")
else:
print("Not leap year.")
else:
print("Not leap year.")

-----------------------------------------------------------

# 🚨 Don't change the code below 👇


print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L ")
add_pepperoni = input("Do you want pepperoni? Y or N ")
extra_cheese = input("Do you want extra cheese? Y or N ")
# 🚨 Don't change the code above 👆

#Write your code below this line 👇

S = 15
M = 20
L = 25

if size == "S":
bill = 15
if add_pepperoni == "Y":
bill = bill + 2
elif size == "M":
bill = 20
if add_pepperoni == "Y":
bill = bill + 3
elif size == "L":
bill = 25
if add_pepperoni == "Y":
bill = bill + 3

if extra_cheese == "Y":
bill = bill + 1
print(f"Your final bill is: ${bill}.")
else:
print(f"Your final bill is: ${bill}.")

------------------------------------------------------------------
word = (name1 + name2).upper()
count = word.count("T") + word.count("R") + word.count("U") + word.count("E")
count1 = word.count("L") + word.count("O") + word.count("V") + word.count("E")
ctotal = str(count) + str(count1)
if int(ctotal) > 40 and int(ctotal) < 50:
print(f"Your score is {ctotal}, you are alright together.")
elif int(ctotal) < 10 or int(ctotal) > 90:
print(f"Your score is {ctotal}, you go together like coke and mentos.")
else:
print(f"Your score is {ctotal}.")

--------------------------------------------------------------------

import random

length = len(names)
index = random.randint(0,length)
print(f"{names[index]} is going to buy the meal today!")

---------------------------------------------------------------------------------

rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''

paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''

scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''

import random

list = [rock, paper, scissors]

user_choice = int(input("What do you choose? 0 is for rock, 1 is for paper, 2 is


for scissors"))
print(f"Your choice: {list[user_choice]}")

computer_choice = random.randint(0,2)
print(f"Computer choice: {list[computer_choice]}")

if user_choice == 0 and computer_choice == 2:


print("You win!")
elif user_choice < computer_choice:
print("You lose!")
elif user_choice == computer_choice:
print("It's a draw!")
elif user_choice > computer_choice:
print("You win!")
elif user_choice >=3 or user_choice < 0:
print("Insert a number between 0 and 2")

-----------------------------------------------------------------------------

total_height = 0
for height in student_heights:
total_height += height

average = total_height/len(student_heights)
print(round(average))

---------------------------------------------------------------------------

#Step 2

import random
word_list = ["aardvark", "baboon", "camel"]
chosen_word = random.choice(word_list)

print(f'Pssst, the solution is {chosen_word}.')

player_life = 3

display = []
for each_letter in chosen_word:
display.append("_")
print(display)

while count != 0:
guess = input("Guess a letter: ").lower()

#TODO-2: - Loop through each position in the chosen_word;


#If the letter at that position matches 'guess' then reveal that letter in the
display at that position.
#e.g. If the user guessed "p" and the chosen word was "apple", then display
should be ["_", "p", "p", "_", "_"].
for position in range(len(chosen_word)):
letter = chosen_word[position]
if letter == guess:
display[position] = letter
count -=1
if guess not in chosen_word:
print("You lost a life!")
player_life -= 1
if player_life == 0:
print("You are hanged!")
break
print(display)

if count == 0:
print(chosen_word)
print("You win!")

-----------------------------------------------------------------------------------
-------------------------

def prime_checker(number):
count = 0
for i in range(2,number):
if number % i == 0:
count += 1
if count > 0:
print("It's not a prime number.")
else:
print("It's a prime number.")

-----------------------------------------------------------------------------------
------------------------
def encrypt(text, shift):
text2 = ""
for letter in text:
index = alphabet.index(letter)
new_index = index + shift
if new_index + shift < 26:
text2 += alphabet[new_index]
else:
text2 += alphabet[new_index - 26]
print(text2)

if direction == "encode":
encrypt(text, shift)
-----------------------------------------------------------------------------------
------------------------

You might also like