diff --git a/school/a-level/homework/fundementals/einstein.py b/school/a-level/homework/fundementals/einstein.py new file mode 100644 index 0000000..2423dad --- /dev/null +++ b/school/a-level/homework/fundementals/einstein.py @@ -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') diff --git a/school/a-level/homework/fundementals/indoor voice.py b/school/a-level/homework/fundementals/indoor voice.py new file mode 100644 index 0000000..b1b4fb5 --- /dev/null +++ b/school/a-level/homework/fundementals/indoor voice.py @@ -0,0 +1,3 @@ +text = input('Please enter some text: ') +text = text.lower() +print(text) diff --git a/school/a-level/homework/fundementals/making faces.py b/school/a-level/homework/fundementals/making faces.py new file mode 100644 index 0000000..49738bf --- /dev/null +++ b/school/a-level/homework/fundementals/making faces.py @@ -0,0 +1,11 @@ +mapping = { + ':)': '🙂', + ':(': '🙁' +} + +text = input('Please enter some text: ') + +for emoticon in mapping.keys(): + text = text.replace(emoticon, mapping[emoticon]) + +print(text) diff --git a/school/a-level/homework/fundementals/playback speed.py b/school/a-level/homework/fundementals/playback speed.py new file mode 100644 index 0000000..c36fa9a --- /dev/null +++ b/school/a-level/homework/fundementals/playback speed.py @@ -0,0 +1,3 @@ +text = input('Please enter some text: ') +text = text.replace(' ', '...') +print(text) diff --git a/school/a-level/homework/fundementals/tip calculator.py b/school/a-level/homework/fundementals/tip calculator.py new file mode 100644 index 0000000..7b5bac8 --- /dev/null +++ b/school/a-level/homework/fundementals/tip calculator.py @@ -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}!')