-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser Inputs.py
More file actions
25 lines (21 loc) · 803 Bytes
/
Copy pathUser Inputs.py
File metadata and controls
25 lines (21 loc) · 803 Bytes
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
# Input() = A function that prompts the user to enter data.
# It returns the entered data as a string
name = input("What is your name?: ")
age = int(input ("How old are you? "))
age = age + 1
print(f"Hello {name}")
print("HAPPY BIRTHDAY!!!")
print(f"You are {age} years old")
# Exercise 1: Calculate the Area of a Rectangle
#inputs
length = float(input("What is the Length?: "))
width = float(input("What is the width?: "))
area = length * width
print(f"The Area of the Rectangle is {area} cm²")
# Exercise 2: Creating a shopping cart program
item = input("What would you like to purchase?: ")
price = float(input("What is the price?: "))
quantity = int(input("How many would you like?: "))
total = price * quantity
print (f"You have bought {quantity} X {item}/s")
print(f"Your total is: ${total}")