feat(hmwk): fundementals part 1 homework
This commit is contained in:
parent
72f3bc757f
commit
3f92bc6163
5 changed files with 53 additions and 0 deletions
11
school/a-level/homework/fundementals/einstein.py
Normal file
11
school/a-level/homework/fundementals/einstein.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
c = 299792458
|
||||
|
||||
while True:
|
||||
try:
|
||||
m = int(input('Please enter an integer mass in kg: '))
|
||||
break
|
||||
except ValueError:
|
||||
print('Please ensure that your input was an integer!')
|
||||
|
||||
e = m * (c ** 2)
|
||||
print(f'e = {e:,}J')
|
3
school/a-level/homework/fundementals/indoor voice.py
Normal file
3
school/a-level/homework/fundementals/indoor voice.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
text = input('Please enter some text: ')
|
||||
text = text.lower()
|
||||
print(text)
|
11
school/a-level/homework/fundementals/making faces.py
Normal file
11
school/a-level/homework/fundementals/making faces.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
mapping = {
|
||||
':)': '🙂',
|
||||
':(': '🙁'
|
||||
}
|
||||
|
||||
text = input('Please enter some text: ')
|
||||
|
||||
for emoticon in mapping.keys():
|
||||
text = text.replace(emoticon, mapping[emoticon])
|
||||
|
||||
print(text)
|
3
school/a-level/homework/fundementals/playback speed.py
Normal file
3
school/a-level/homework/fundementals/playback speed.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
text = input('Please enter some text: ')
|
||||
text = text.replace(' ', '...')
|
||||
print(text)
|
25
school/a-level/homework/fundementals/tip calculator.py
Normal file
25
school/a-level/homework/fundementals/tip calculator.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
while True:
|
||||
try:
|
||||
pounds = input('How much was the meal? ')
|
||||
|
||||
pounds = pounds.split('£')
|
||||
pounds = pounds[len(pounds) - 1]
|
||||
pounds = float(pounds)
|
||||
|
||||
break
|
||||
except ValueError:
|
||||
print('Please ensure that you input a valid amount of money!')
|
||||
|
||||
while True:
|
||||
try:
|
||||
percentage = input('What percentage would you like to tip? ')
|
||||
|
||||
percentage = percentage.split('%')[0]
|
||||
percentage = float(percentage) / 100
|
||||
|
||||
break
|
||||
except ValueError:
|
||||
print('Please ensure that you enter a valid percentage!')
|
||||
|
||||
tip = round(pounds * percentage, 2)
|
||||
print(f'You should tip £{tip}!')
|
Loading…
Reference in a new issue