15 Oct TCMS 18:30 Python Homework 10.11
Use float() to create a number from a string like ‘12.34’. Make sure the result is really a number!
Try using int() to create an integer from a decimal number like 56.78. Did the answer get rounded up or down?
Try using int() to create an integer from a string. Make sure the result is really an integer!
Write a program that asks for your first name, then asks for your last name, and then prints a message with your first and last names in it.
Use input() to ask question and get answer, for example:
firstName = input("What is your first name?")
The string answer as value will be assigned to variable firstName.
Write a program that asks for the dimensions (length and width) of a rectangular room, and then calculates and displays the total amount(area) of carpet needed to cover the room.
Use input() to ask question and get answer, however, you can only get string data type of answer. In order to get decimal number as dimensions, you need to use float(input(…..)) which will convert from string answer into a decimal number.
Write a program that helps the user add up her change. The program should ask:
- “How many quarters?”
- “How many dimes?”
- “How many nickels?”
- “How many pennies?”
Then it should give the total value of the change