Lesson 1 homework
Problem 1
Store a sentence in a variable, then print it 3 times using the variable.
Problem 2
Ask the user for two numbers and print their sum.
Input
Code
- Take two inputs from the terminal
- Remember:
input()always returns a string - Convert before adding
- Make as many mistakes as you like
- Don't give up
Output
Problems 3 and 4 use the math operators from the Lesson 1 reading — read it first.
Problem 3
Ask the user for a number of days, then print how many full weeks that is and how many days are left over.
Input
Code
- Take one input from the terminal and convert it
- Use
//for the full weeks and%for the leftover days
Output
Problem 4
Ask the user for a number and print its square, its cube, and the number divided by 2.
Input
Code
- Use
**for the square and the cube - Use
/for the division - Before you run it: will the last line print
2or2.0? Why?
Output