PYTHON Practice 1
PYTHON Practice 1
In a file called indoor.py, implement a program in Python that prompts the user for input
and then outputs that same input in lowercase. Punctuation and whitespace should be
outputted unchanged. You’re welcome, but not required, to prompt the user explicitly, as by
passing a str of your own as an argument to input.
Hints
In a file called playback.py, implement a program in Python that prompts the user for input
and then outputs that same input, replacing each space with ... (i.e., three periods).
Hints
, wherein represents energy (measured in Joules), represents mass (measured in kilograms), and
represents the speed of light (measured approximately as 300000000 meters per second), per
Albert Einstein et al. Essentially, the formula means that mass and energy are equivalent.
In a file called einstein.py, implement a program in Python that prompts the user for mass
as an integer (in kilograms) and then outputs the equivalent number of Joules as an integer.
Assume that the user will input an integer.
Hints
— Morty Seinfeld
In the United States, it’s customary to leave a tip for your server after dining in a restaurant,
typically an amount equal to 15% or more of your meal’s cost. Not to worry, though, we’ve
written a tip calculator for you, below!
def main():
dollars = dollars_to_float(input("How much was the meal? "))
percent = percent_to_float(input("What percentage would you like to
tip? "))
tip = dollars * percent
print(f"Leave ${tip:.2f}")
def dollars_to_float(d):
# TODO
def percent_to_float(p):
# TODO
main()
Well, we’ve written most of a tip calculator for you. Unfortunately, we didn’t have time to
implement two functions:
Assume that the user will input values in the expected formats.
Hints