Preparing git repo for final project

This commit is contained in:
2023-07-09 11:19:26 +02:00
parent 6a38966eef
commit 63d06d6b35
67 changed files with 1587 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
def main():
greeting = input("Greeting:\t\t").lower().strip()
if greeting.startswith("hello"):
print("$0")
elif greeting.startswith("h"):
print("$20")
else:
print("$100")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,28 @@
import re
answer_regex = re.compile(r"\s*(42|forty[ -]?two)\s*", re.IGNORECASE)
def ifelse_answer():
answer = input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t")
answer = answer.strip()
answer = answer.replace('-', '')
answer = answer.replace(' ', '')
answer = answer.lower()
if answer in ('42', 'fortytwo'):
print("Yes")
else:
print("No")
def regex_answer():
print('Yes'
if answer_regex.match(
input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t"))
else 'No')
def oneliner():
print({True: 'Yes', False: 'No'}[input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t").lower().strip() in ('42', 'fortytwo', 'forty two', 'forty-two')])
if __name__ == "__main__":
regex_answer()

View File

@@ -0,0 +1,22 @@
extensions = {
".gif": "image/gif",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".png": "image/png",
".pdf": "application/pdf",
".txt": "text/plain",
".zip": "application/zip"
}
def main():
file_name = input("Enter file name:\t\t").lower().strip()
for extension, mime in extensions.items():
if file_name.endswith(extension):
print(mime)
break
else:
print("application/octet-stream")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,17 @@
def main():
expression = input("Enter an arithmetic expression:\t\t")
x, y, z = expression.split()
result = 0.0
if y == '+':
result = int(x) + int(z)
elif y == '-':
result = int(x) - int(z)
elif y == '*':
result = int(x) * int(z)
elif y == '/':
result = int(x) / int(z)
print(round(float(result), 1))
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,17 @@
def main():
t = convert(input("What time is it?\t\t"))
if 7 <= t <= 8:
print("breakfast time")
elif 12 <= t <= 13:
print("lunch time")
elif 18 <= t <= 19:
print("dinner time")
def convert(time):
h ,m = map(int, time.split(":"))
return float(h + m / 60)
if __name__ == "__main__":
main()