Skip to content

Commit f26601c

Browse files
Add files via upload
1 parent 159f335 commit f26601c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1574
-0
lines changed

week 0/einstein/einstein.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
x= float(input("Enter the mass: "))
2+
lspeed= 300000000
3+
energy = (x * pow(lspeed , 2))
4+
print(energy)

week 0/faces/faces.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
def convert(string_user):
3+
emoji_string = string_user.replace(":)" , "🙂")
4+
emoji_string2 = emoji_string.replace(":(" , "🙁")
5+
return (emoji_string2)
6+
7+
def main():
8+
i = input("Write me the sentence: ")
9+
user_string = convert(i)
10+
print(user_string)
11+
12+
main ()

week 0/indoor/indoor.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
user_input = input("Please write me sth: ").lower()
2+
print (user_input)

week 0/playback/playback.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
s = input("Enter the Sentence please: ")
2+
convert= s.replace( " " , "...")
3+
print (convert)

week 0/tip/tip.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
def main():
3+
dollars = dollars_to_float(input("How much was the meal? "))
4+
percent = percent_to_float(input("What percentage would you like to tip? "))
5+
tip = dollars * percent
6+
print(f"Leave ${tip:.2f}")
7+
8+
def dollars_to_float(d):
9+
meal_price = float(d.replace( "$", ""))
10+
return meal_price
11+
def percent_to_float(p):
12+
rep = float(p.replace( "%", "" ))
13+
percent_to_float = float(rep * 0.01)
14+
return percent_to_float
15+
16+
main()

week 1/bank/bank.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
s = input("Please say a welcome sentence: ").lower().strip()
2+
3+
if "hello" in s :
4+
print("$0")
5+
elif (s[0]==("h")) and (s != ("hello")):
6+
print("$20")
7+
else:
8+
print("$100")

week 1/deep/deep.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
i = input("Enter my age: ").strip().lower()
3+
if i== "42":
4+
print ("Yes")
5+
elif i== "forty two":
6+
print ("Yes")
7+
elif i== "forty-two":
8+
print ("Yes")
9+
else:
10+
print ("No")

week 1/extensions/extensions.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
s = input("Enter the File-name: ").lower()
2+
3+
if ".txt.pdf" in s:
4+
print("application/pdf")
5+
elif ".gif" in s:
6+
print("image/gif")
7+
elif ".jpg" in s:
8+
print("image/jpeg")
9+
elif ".png" in s:
10+
print("image/png")
11+
elif ".txt" in s:
12+
print("text/plain")
13+
elif ".pdf" in s:
14+
print("application/pdf")
15+
elif ".zip" in s:
16+
print("application/zip")
17+
elif ".jpeg" in s:
18+
print("image/jpeg")
19+
else:
20+
print("application/octet-stream")
21+

week 1/interpreter/interpreter.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
s = input("Enter the arg: ")
2+
x , y , z = s.split(" ")
3+
4+
if y == "+":
5+
print(float(x) + float(z))
6+
elif y == "-":
7+
print(float(x) - float(z))
8+
elif y == "*":
9+
print(float(x) * float(z))
10+
elif y == "/":
11+
print(float(x) / float(z))

week 1/meal/meal.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# def main():
2+
# s= input("Please enter the time: ")
3+
# h , m = s.split(":")
4+
# if int(h)==7 and 00 <= int(m) <= 59 or int (h)== 8 and int (m)== 00:
5+
# print ("breakfast time")
6+
# elif 12 <= int(h) <= 13 and 00 <= int(m) <= 59 :
7+
# print ("lunch time")
8+
# elif 18 <= int(h) <= 19 and 00 <= int(m) <= 59 :
9+
# print ("dinner time")
10+
# else:
11+
# return ("None")
12+
# if __name__ == "__main__":
13+
# main()
14+
15+
def convert ( time ):
16+
hour, minute, = map(int, time.split(':'))
17+
decimal_time = hour + minute / 60
18+
return (decimal_time)
19+
20+
def main ():
21+
s = input("Please enter the time: ")
22+
decimal_time = convert(s)
23+
if 7.0 <= decimal_time <= 8.0:
24+
print ("breakfast time")
25+
elif 12.0 <= decimal_time <= 13.0:
26+
print ("lunch time")
27+
elif 18.0 <= decimal_time <= 19.0:
28+
print ("dinner time")
29+
else:
30+
return ("")
31+
32+
if __name__ == "__main__" :
33+
main()

week 2/camel/camel.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# preferredFirstName
2+
s = input("Enter the fuckiiiing string: ")
3+
for c in s:
4+
if c.isupper():
5+
s = s.replace(c , f"_{c}")
6+
lowering = s.lower()
7+
print(lowering)

week 2/coke/coke.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
amount_due = 50
3+
while amount_due > 0:
4+
print(f"Amount Due: {amount_due}")
5+
6+
coin = int(input("Insert Coin: "))
7+
if coin == 5 or coin == 10 or coin == 25:
8+
amount_due = amount_due - coin
9+
else:
10+
continue
11+
# it's posiible that the 'amount_due' become a negetive num; so we use abs() to make it posetive.
12+
change_owed = abs(amount_due)
13+
print(f"Change Owed: {change_owed}")

week 2/nutrition/nutrition.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
3+
s = input("Enter the fruit name: ").strip().lower()
4+
fruits_dict = {
5+
"apple" : "130",
6+
"avocado" : "50",
7+
"banana" : "110",
8+
"cantaloupe" : "50",
9+
"grapefruit" : "60",
10+
"grape" : "90",
11+
"honeydew melon " : "50",
12+
"kiwifruit" : "90",
13+
"lemon" : "15",
14+
"lime" : "20",
15+
"nectarine" : "60",
16+
"orange" : "80",
17+
"peach" : "60" ,
18+
"pear" : "100" ,
19+
"pineapple" : "50" ,
20+
"plums" : "70" ,
21+
"strawberries" : "50" ,
22+
"sweet cherries" : "100" ,
23+
"tangerine" : "50" ,
24+
"watermelon" : "80" ,
25+
}
26+
27+
28+
if s in fruits_dict:
29+
print("Calories: " + fruits_dict[s])
30+
else:
31+
print("", end="")

week 2/plates/plates.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def main():
2+
plate = input("Plate: ")
3+
if is_valid(plate):
4+
print("Valid")
5+
else:
6+
print("Invalid")
7+
8+
def is_valid(s):
9+
if 2 <= len(s) <= 6 and s.isalpha():
10+
return True
11+
elif 2 <= len(s) <= 6 and s[0:2].isalpha() and s.isalnum():
12+
for c in s:
13+
if c.isdigit() :
14+
nums = s.find(c)
15+
if (s[nums:].isdigit() and int(c) != 0):
16+
return True
17+
else:
18+
return False
19+
20+
main()

week 2/twttr/twttr.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
s = input("Enter the string: ")
3+
vowels = ["a", "e", "i", "o", "u" , "A", "E", "I", "O", "U"]
4+
new_s = ""
5+
for c in range(len(s)):
6+
if s[c] not in vowels:
7+
new_s += s[c]
8+
9+
print (new_s)

week 3/fuel/fuel.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
while True:
2+
try:
3+
n = (input("Enter the x/y: "))
4+
x , y = n.split("/")
5+
x = int(x)
6+
y = int(y)
7+
r_int = round((x*100)/y)
8+
if 1 < r_int < 99:
9+
print (f"{r_int}%")
10+
elif 0 <= r_int <= 1:
11+
print("E")
12+
elif r_int > 100:
13+
raise ValueError
14+
elif r_int >= 99 :
15+
print("F")
16+
17+
except (ValueError, ZeroDivisionError):
18+
print("x and y are not in correct format!!\nplz try an integer...")
19+
else:
20+
break

week 3/grocery/grocery.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# grocery {"item" : "number"}
2+
grocery={}
3+
while True:
4+
try:
5+
item = input().upper().strip()
6+
if item not in grocery:
7+
grocery[item] = 1
8+
elif item in grocery:
9+
grocery[item] += 1
10+
11+
except EOFError:
12+
for item in sorted(grocery):
13+
print ( grocery[item] ,item)
14+
break

week 3/outdated/outdated.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# M / D / Y convert to Y-M-D
2+
months= [
3+
"January",
4+
"February",
5+
"March",
6+
"April",
7+
"May",
8+
"June",
9+
"July",
10+
"August",
11+
"September",
12+
"October",
13+
"November",
14+
"December"
15+
]
16+
17+
while True:
18+
d = input("Enter the year: ").strip()
19+
20+
if "/" in d:
21+
month, day, year = d.split("/")
22+
if month.isdigit() and day.isdigit() and year.isdigit() :
23+
month = int (month)
24+
day = int (day)
25+
year = int (year)
26+
if 1 <= month <= 12 and 1 <= day <= 31:
27+
print (f"{year}-{month:02}-{day:02}")
28+
break
29+
elif " " in d and "," in d:
30+
date = d.split(" ")
31+
if date[0].isalpha():
32+
year = date[2]
33+
month = date[0].title()
34+
day = int(date[1].replace("," , ""))
35+
if month in months:
36+
m = int(months.index(month)+1)
37+
if 1 <= m <= 12 and 1 <= day <= 31:
38+
print(f"{year}-{m:02}-{day:02}")
39+
break
40+

week 3/outdated/temp.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# M / D / Y convert to Y-M-D
2+
months= [
3+
"January",
4+
"February",
5+
"March",
6+
"April",
7+
"May",
8+
"June",
9+
"July",
10+
"August",
11+
"September",
12+
"October",
13+
"November",
14+
"December"
15+
]
16+
17+
18+
d = input("Enter the year: ")
19+
20+
if "/" in d:
21+
month, day, year = d.split("/")
22+
month = int (month)
23+
day = int (day)
24+
year = int (year)
25+
26+
print (f"{year}-{month:02}-{day:02}")
27+
28+
elif " " in d:
29+
date = d.split(" ")
30+
print(date[2])

week 3/taqueria/taqueria.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# {"Food name" : "Price"}
2+
# {"item" : value}
3+
4+
food_dict = {
5+
"Baja Taco": 4.00,
6+
"Burrito": 7.50,
7+
"Bowl": 8.50,
8+
"Nachos": 11.00,
9+
"Quesadilla": 8.50,
10+
"Super Burrito": 8.50,
11+
"Super Quesadilla": 9.50,
12+
"Taco": 3.00,
13+
"Tortilla Salad": 8.00
14+
}
15+
16+
total_price = 0
17+
while True:
18+
try:
19+
item = input("Item: ").title()
20+
21+
except EOFError:
22+
print("")
23+
break
24+
if item in food_dict:
25+
total_price += food_dict[item]
26+
print(f"Total: ${total_price:.2f}")

week 4/adieu/adieu.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import inflect
2+
p = inflect.engine()
3+
# test_list.append(test_str)
4+
5+
name_list = []
6+
while True:
7+
try:
8+
s = input("Input: ")
9+
name_list.append(s)
10+
names = p.join(name_list)
11+
except EOFError:
12+
print(f"Adieu, adieu, to {names}")
13+
break

0 commit comments

Comments
 (0)