Review Questions: Part 2

1) The Rowan Concert Series is presenting a family concert next week. Ticket prices are as follows:  Tickets for Rowan Students cost $11.00 each. For non-Rowan Students, the ticket price is $19.00 for Adults and $7.75 for Kids.  In addition, there is a 5% (0.05) surcharge for online ticket purchases for Students and Adults (so Kids do NOT pay the surcharge, but Adults and Rowan Students do).

Write a function that asks the user how many adult, student, and kid tickets they want to buy. Then ask if they want to buy the tickets on line or at the ticket office (remember: on-line ticket purchases for adults & students have the surcharge, but ticket office tickets don’t). Your function should print out how many of each type of ticket they are buying and what the total price is.

 

2) Student clubs at Rowan can rent vans from the SGA for $100.00  plus 55 cents per mile traveled. Write a function that takes two arguments: the number of vehicles needed and the one-way distance from Rowan. Your function should compute and return the total cost.

For example, if you need 1 vehicle to drive to somewhere 20 miles away from Rowan (or 40 miles round trip), then the cost will be $100 for the vehicle plus 40 miles at 55 cents a mile, for a total cost of $122.00

As another example, if you need 3 vehicles to drive to somewhere 37 miles away from Rowan (round trip distance of 74 miles) then the cost would be $300 for the vehicles plus 74 miles at 55 cents a mile for each of the 3 vehicles for a total cost of  $422.10.

 

3)There are 7 days in a week, 24 hours in a day, and 60 minutes in each hour.

Write a function that accept a number of weeks as input and return the number of minutes that are in that many weeks. To make it work, you need to write three more functions: a function WeeksToDays, a function DaysToHours, and a function HoursToMinutes.

Example: 1 week = 10080 Minutes

 

4) Write a program for your robot that spins right if it sees a light in its center light sensor, goes forward if it sees a light in its right light sensor, and goes backward if it sees a light in its left light sensor

 

 

5) Do this on paper: what gets printed when I run loopy() below

def printSnoopy():

   print ":-)"

 

def loopy():

   for i in range (4):

      printSnoopy()

      print "i is now ", i

      print

 

6) what gets printed when I run loopy2(16)

 

def loopy2(num):

   foo = [num, num+2, num+4, num+6]

   for pig in foo:

      print pig

 

 

 

7) Write code that asks the user for a number, and if they give you a number less than 0, it keeps asking until it gets one greater than zero. Then print out their number.