adds currency converter
This commit is contained in:
parent
d6a1cf4e40
commit
952860942b
|
@ -440,6 +440,38 @@ else:
|
|||
|
||||
</details>
|
||||
|
||||
# Coding challenge - Currency converter
|
||||
|
||||
I would like you to write a program that converts EUR to DOLLAR.
|
||||
You should do this in a **new** python file.
|
||||
I suggest you call it `euro_to_dollar.py` or something that makes sense to you.
|
||||
The result of this program *could* be as follows.
|
||||
|
||||
```bash
|
||||
➜ python_course_doc git:(master) ✗ python3 test.py
|
||||
How much EUR would you like to convert into DOLLAR? 140
|
||||
140 EUR is 159.6 DOLLAR
|
||||
➜ python_course_doc git:(master) ✗ python3 test.py
|
||||
How much EUR would you like to convert into DOLLAR? blablabla
|
||||
That's not a number I understand...
|
||||
➜ python_course_doc git:(master) ✗
|
||||
```
|
||||
<details>
|
||||
<summary>Spoiler warning</summary>
|
||||
result = input("How much EUR would you like to convert into DOLLAR? ")
|
||||
|
||||
rate = 1.14
|
||||
|
||||
if result.isdigit():
|
||||
eur = int(result)
|
||||
dollar = eur * rate
|
||||
print("{} EUR is {} DOLLAR".format(eur, dollar))
|
||||
else:
|
||||
print("That's not a number I understand...")
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
# A text based adventure game
|
||||
|
||||
We can use conditional logic to create quite elaborate decision processes.
|
||||
|
@ -1712,6 +1744,12 @@ for login in my_login_list:
|
|||
print("\t{}: {}".format(key, login[key]))
|
||||
```
|
||||
|
||||
🏃 Try it
|
||||
---
|
||||
|
||||
Go back to you *currency converter* program and add a `dict` with multiple currencies so you can enter one amount to convert and your program gives you how much that is in each currency of the `dict`.
|
||||
|
||||
|
||||
# Coding challenge - Task manager
|
||||
|
||||
Can you create me a *task manager* please?
|
||||
|
|
Loading…
Reference in New Issue