Today I learned about inputs in Python and how to do some simple things where that allow a user or that prompt a user to input some values and then we generate an output in Python. This is based on Bro code’s Python full course for free the 2024 version about 30 minutes into the course.
# input() = A function that prompts the user to enter data
# Returns the entered data as a string
# Exercise 1 Rectangle Area Calculator
# length = float(input("Enter the length: "))
# width = float(input("Enter the width: "))
# area = length * width
# print(f"The area is: {area}cm²")
# Exercise 2 Shopping Cart Program
# item = input("What item would you like to buy?: ")
# price = float(input("What is the price?: "))
# quantity = int(input("How many items would you like to buy?: "))
# total = price * quantity
# print("The total price is $",total)
# print(f"You bought {quantity} {item}/s.")
# print(f"Your total is: ${total}.")
name = input("What is your name? ")
location = input("Where do you live? ")
print(f"Hi, {name} from {location}. I hate place.")
Leave a Reply