Skip to content

Commit 741779a

Browse files
week0 & week1
1 parent c6ba694 commit 741779a

File tree

10 files changed

+117
-0
lines changed

10 files changed

+117
-0
lines changed

week0/einstein/einstein.py

Lines changed: 3 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print(input("Enter some text \n").replace(" ","..."))

week0/tip/tip.py

Lines changed: 16 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 22 additions & 0 deletions
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

Lines changed: 15 additions & 0 deletions
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

Lines changed: 29 additions & 0 deletions
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.

0 commit comments

Comments
 (0)