Coduri Python Exercitii
Coduri Python Exercitii
Coduri Python Exercitii
#First *fork* your copy. Then copy-paste your code below this line 👇
#Finally click "Run" to execute the tests
-----------------------------------------------------------
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
computer_choice = random.randint(0,2)
print(f"Computer choice: {list[computer_choice]}")
-----------------------------------------------------------------------------
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)
player_life = 3
display = []
for each_letter in chosen_word:
display.append("_")
print(display)
while count != 0:
guess = input("Guess a letter: ").lower()
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)
-----------------------------------------------------------------------------------
------------------------