Review Questions: Part 1

1)      The volume of a pyramid with a square base is 1/3 x length_of_base x width_of_base x height. Write a function that asks the user for these three values and prints out the volume

2)      Write another function that takes 3 arguments (length, width, and height) and prints the volume of a pyramid with a square base

3)      Now write a function that  takes 3 arguments (length, width, and height) and returns the volume of a pyramid with a square base

 

 

 

4)      Write a function that prints out all the integers from 0 to 24, each on its own line

5)      Write a function that prints out all the integers from 0 to 24, all together on one line (with spaces in between

6)      Write a function that prints out all the integers from 1 to 25

7)      Write a function that prints out all the integers from 2 to 26

8)      Write a function that prints out all the integers from 342 to 358

 

9)      In the US, election day is always the first Tuesday in November whose date comes after November 1st. (So election day is always somewhere in between November 2nd and November 8th inclusive) So for example,

• In 1976, election day was on November 2nd (first Tuesday after November 1st)

• In 1984, election day was on November 6th (first Tuesday after November 1st)

• In 1988, election day was on November 8th, (first Tuesday after November 1st, since November 1st was a Tuesday, we have a special case and have to go to the 8th

 

Write a complete program that asks the user for the date of the first Tuesday in November, and tells them when voting day will be. Here are three examples  user input has been

underlined. Your code must be identical to mine given the same input.

 

Date of 1st Tue: 2

Election day on day 2

 

Date of 1st Tue: 6

Election day on day 6

 

Date of 1st Tue: 1

Election day on day 8