Skip to content

Commit 790db90

Browse files
Initial Commit
0 parents  commit 790db90

File tree

33 files changed

+735
-0
lines changed

33 files changed

+735
-0
lines changed

week0/einstein/einstein.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
m = int(input("Enter mass: "))
2+
c = 300000000
3+
print ("E is", m * pow(c, 2))

week0/faces/faces.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def convert(a):
2+
a = a.replace(":)","🙂")
3+
a = a.replace(":(","🙁")
4+
print (a)
5+
6+
def main():
7+
text = input("Input some text with emoticons: ")
8+
convert(text)
9+
10+
main()
11+
12+

week0/indoor/indoor.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Fetch input from the user and store in string variable 'text'
2+
text = input("Type some UPPERCASE text to use your indoor voice! \n")
3+
4+
# Convert uppercase characters to lowercase and print output
5+
print (text.lower())

week0/playback/playback.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print(input("Enter some text \n").replace(" ","..."))

week0/tip/tip.py

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

week1/bank/bank.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
greeting = input("Input a Greeting for $$$:")
2+
3+
if greeting.lower().strip().startswith("hello"):
4+
print("$0")
5+
elif greeting.lower().strip().startswith("h"):
6+
print("$20")
7+
else:
8+
print("$100")

week1/deep/deep.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
answer = input("What is the Answer to the Great Question of Life, the Universe, and Everything?").strip().lower()
2+
3+
if answer == "42" or answer == "forty-two" or answer == "forty two":
4+
print("Yes")
5+
else:
6+
print("No")

week1/extensions/extensions.py

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

week1/interpreter/interpreter.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
expression = input ("Expression:")
2+
3+
num1, op, num2 = expression.split(" ")
4+
5+
if op == "+":
6+
print (float(num1) + float(num2))
7+
8+
if op == "-":
9+
print (float(num1) - float(num2))
10+
11+
if op == "*":
12+
print (float(num1) * float(num2))
13+
14+
if op == "/":
15+
print (float(num1) / float(num2))

week1/meal/meal.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def main():
2+
inputtime = input("What time is it?")
3+
4+
convertedtime = convert(inputtime)
5+
6+
if 7 <= convertedtime <=8:
7+
print ("breakfast time")
8+
9+
elif 12 <= convertedtime <=13:
10+
print ("lunch time")
11+
12+
elif 18 <= convertedtime <=19:
13+
print ("dinner time")
14+
15+
def convert(time):
16+
time = time.rstrip("am").strip()
17+
time = time.rstrip("pm").strip()
18+
19+
hours, minutes = time.split(":")
20+
21+
hours = float(hours)
22+
minutes = float(minutes)
23+
24+
minutes = minutes / 60
25+
return float(hours + minutes)
26+
27+
main()
28+
29+
# 7:00 and 8:00, lunch between 12:00 and 13:00, and dinner between 18:00 and 19:00.

week2/camel/camel.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name = input("Enter your name: ")
2+
3+
for letter in name:
4+
5+
if letter.isupper() : letter = "_" + letter
6+
7+
print (letter.lower(), end="")
8+
9+
print()
10+

week2/coke/coke.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
amount = 50
2+
print("Amount due: ", amount)
3+
4+
while True:
5+
6+
money = int(input("Insert Coin: "))
7+
8+
if money == 25 or money==10 or money==5:
9+
amount = amount - money
10+
11+
if amount <= 0:
12+
print("Change Owed:", abs(amount))
13+
break
14+
15+
print("Amount Due:", amount)

week2/nutrition/nutrition.py

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

week2/plates/plates.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
10+
def check_numbers_letters() :
11+
12+
numberindex = -1
13+
14+
for c in s :
15+
if c.isnumeric() :
16+
numberindex = s.find(c)
17+
break
18+
19+
if numberindex == -1 :
20+
return False
21+
else :
22+
23+
for c in s[numberindex:len(s)]:
24+
if c.isalpha():
25+
return True
26+
27+
if "." in s or " " in s:
28+
return False
29+
elif s[0:2].isnumeric() :
30+
return False
31+
elif len(s) < 2 or len(s) > 6:
32+
return False
33+
elif s[0] =="0" :
34+
return False
35+
elif check_numbers_letters () :
36+
return False
37+
elif s[2] == "0" :
38+
return False
39+
else:
40+
return True
41+
42+
main()

week2/twttr/twttr.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
text = input("Input:")
2+
3+
vowel_list = ["a", "e", "i", "o", "u"]
4+
5+
for l in text:
6+
for _ in vowel_list:
7+
if l.lower() == _:
8+
l = ""
9+
10+
print(l, end="")
11+
12+
print()

week3/fuel/fuel.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def take_input():
2+
while True:
3+
try:
4+
user_input = input("Fraction: ").strip().split("/")
5+
return round(int(user_input[0]) / int(user_input[1]), 2) * 100
6+
7+
except ValueError:
8+
pass
9+
except ZeroDivisionError:
10+
pass
11+
12+
13+
def main():
14+
value = int(take_input())
15+
if 99 <= value <= 100:
16+
print("F")
17+
elif value <= 1:
18+
print("E")
19+
elif value > 100:
20+
take_input()
21+
else:
22+
print(int(value), "%", sep="")

week3/grocery/grocery.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
groceriesdict = {}
2+
3+
while True :
4+
5+
try :
6+
key = input("")
7+
8+
if key in groceriesdict : groceriesdict[key] += 1
9+
else : groceriesdict[key] = 1
10+
11+
except EOFError :
12+
for k in sorted(groceriesdict) :
13+
print (groceriesdict[k], k.upper(), sep=" " , end="\n")
14+
break
15+
16+
except KeyError : pass

week3/outdated/outdated.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
months = {
2+
"01":"January",
3+
"02":"February",
4+
"03":"March",
5+
"04":"April",
6+
"05":"May",
7+
"06":"June",
8+
"07":"July",
9+
"08":"August",
10+
"09":"September",
11+
"10":"October",
12+
"11":"November",
13+
"12":"December"
14+
}
15+
16+
def Main():
17+
18+
while method() :
19+
method()
20+
21+
def method() :
22+
23+
date = input("Date:").capitalize()
24+
25+
for j in months :
26+
value = months[j]
27+
if "/" in date and value in date :
28+
return True
29+
if value in date and "," not in date :
30+
return True
31+
32+
date = date.replace("/"," ").replace(","," ").split()
33+
34+
if date[1].isalpha() :
35+
return True
36+
37+
month = date[0].strip()
38+
day = int(date[1].strip())
39+
year = int(date[2].strip())
40+
41+
if month.isnumeric() :
42+
month=int(month.strip())
43+
44+
if month > 12 :
45+
return True
46+
47+
for i in months :
48+
if month == months[i] :
49+
month = i
50+
51+
if day > 31:
52+
return True
53+
54+
print(f"{year:04}-{month:02}-{day:02}",end="")
55+
return False
56+
57+
Main()

week3/taqueria/taqueria.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
menu = {
2+
"Baja Taco": 4.00,
3+
"Burrito": 7.50,
4+
"Bowl": 8.50,
5+
"Nachos": 11.00,
6+
"Quesadilla": 8.50,
7+
"Super Burrito": 8.50,
8+
"Super Quesadilla": 9.50,
9+
"Taco": 3.00,
10+
"Tortilla Salad": 8.00
11+
}
12+
13+
flag = True ; ordertotal = []
14+
15+
def takeuserinput() :
16+
17+
try :
18+
order = input("Item:").title()
19+
if order in menu : ordertotal.append(round(menu[order],3))
20+
return True
21+
22+
except EOFError :
23+
return False
24+
except KeyError : return False
25+
26+
27+
while flag :
28+
flag = takeuserinput()
29+
if not flag :
30+
break
31+
print (f"${sum(ordertotal):.2f}")
32+
print()
33+

0 commit comments

Comments
 (0)