PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
# Script "supposed" to take value inputted from user and convert it over to other unit...
# ie: L/100km -> MPG, or MPG -> L/100km
#
# Update:
# Thanks to @Diego Acero for pointing this out:
# - Apparently, in SoloLearn, you need to enter all the inputs at
# the beginning in the little pop up window. So if any of you guys
# are getting an error while trying to run this saying:
#
# Traceback(most recent call last):
# File "..\Playground\", line 27, in <module>
# mpg = input('Please enter MPG to be converted: \n\n')
# EOFError: Error when reading a line
#
# It could be the same problem.
#
print('''What would you like to convert?
[1] MPG to L/100km
[2] L/100km to MPG\n\n\n''')
convertchoice = input(': ')
if convertchoice == '1':
mpg = input('Please enter MPG to be converted: \n\n')
lpkm = 235.215 / int(mpg)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run