LECUTR 0
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.
x = str(input("input something"))
print("hello,",x.lower())
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):
return float(d.replace("$",""))
def percent_to_float(p):
return float(p.replace("%",""))/100
main()
Before there were emoji, there were emoticons, whereby text like :)
was a happy face and text like :(
was a sad face. Nowadays, programs tend to convert emoticons to emoji automatically!
In a file called faces.py
, implement a function called convert
that accepts a str
as input and returns that same input with any :)
converted to 😄and any :(
converted to 😢. All other text should be returned unchanged.
Then, in that same file, implement a function called main
that prompts the user for input, calls convert
on that input, and prints the result. You’re welcome, but not required, to prompt the user explicitly, as by passing a str
of your own as an argument to input
. Be sure to call main
at the bottom of your file.
def convert(setence):
if setence == "hello, :)":
print("hello, 😄")
if setence == "hello, :(":
print("hello, 😢")
def main():
x = input("hello or goodbye")
convert(x)
main()