-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserinput.py
More file actions
19 lines (17 loc) · 758 Bytes
/
userinput.py
File metadata and controls
19 lines (17 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#input() = A fn that takes input from the user and returns it as a string
"""name = input("Enter your name: ")
print(f"Hello, {name}!")
age = int(input("Enter your age: "))
agee = age+1
print(f"Next year you will be {agee} years old!")
# Exercise: Write a program to calc area of rectangle using user input
length = input("Enter the length of the rectangle: ")
width = input("Enter the width of the rectangle: ")
area = int(length)*int(width)
print(f"The area of the rectangle is {area} square units.")"""
# Exercise2: Shopping Cart Program
item = input("Enter the name of the item: ")
price = float(input("Enter the price of the item: "))
quantity = int(input("Enter the quantity of the item: "))
total = price * quantity
print(f"Your total is ${total}.")