Numerical Input
text_one = input("Enter the price of one item: ")
price = float(text_one)
text_two = input("Enter the quantity of items: ")
quantity = int(text_two)
cost = price * quantity
print("The total cost is $", end="")
print(cost)
Numerical Input
text_one = input("Enter the price of one item: ")
price = float(text_one)
text_two = input("Enter the quantity of items: ")
quantity = int(text_two)
cost = price * quantity
print("The total cost is $", end="")
print(cost)
Enter the price of one item: 2.75
Enter the quantity of items: 3
The total cost is $8.25
Numerical Input
text_one = input("Enter the price of one item: ")
price = float(text_one)
text_two = input("Enter the quantity of items: ")
quantity = int(text_two)
cost = price * quantity
print("The total cost is $", end="")
print(cost)
Enter the price of one item: 2.75
Enter the quantity of items: 3.5
Numerical Input
text_one = input("Enter the price of one item: ")
price = float(text_one)
text_two = input("Enter the quantity of items: ")
quantity = int(text_two)
cost = price * quantity
print("The total cost is $", end="")
print(cost)
Enter the price of one item: 2.75
Enter the quantity of items: 3.5
Traceback (most recent call last):
File "tutor.py", line 4, in <module>
quantity = int(text_two)
ValueError: invalid literal for int() with base 10: '3.5'