Skip to content

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

first number? 40
second number? 2

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

42

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

how many days? 17

Code

  • Take one input from the terminal and convert it
  • Use // for the full weeks and % for the leftover days

Output

2
3

Problem 4

Ask the user for a number and print its square, its cube, and the number divided by 2.

Input

pick a number: 4

Code

  • Use ** for the square and the cube
  • Use / for the division
  • Before you run it: will the last line print 2 or 2.0? Why?

Output

16
64
2.0