Slide 1Slide 2Slide 3Slide 4Slide 5Intro to: Computers & Programming Defining Identifiers: Objects with Names V22.0002-001Adam MeyersNew York University Introduction to: Computers & Programming Exercises Using: Variables and FunctionsIntro to: Computers & Programming Defining Identifiers: Objects with Names V22.0002-001Exercise 1: Calculate an Average of 5 Numbers•Use the function input– input(prompt)• displays prompt• waits for user to type something• returns whatever the user types• The program should allow the user to input 5 items• At the end it should display the averageIntro to: Computers & Programming Defining Identifiers: Objects with Names V22.0002-001Problem 2: Calculate Birthday Biorhythms• Go to http://en.wikipedia.org/wiki/Biorhythm• Implement a function that given an age in number of days, would calculate and print one's biorhythms, i.e.,–def print_biorhythms(number_of_days): ...• Write a function that calls print_biorhtyhms. It queries the user for their age and then gives them the biorythm for their next birthday (assuming no leap years).Intro to: Computers & Programming Defining Identifiers: Objects with Names V22.0002-001Problem 3: Write a Mad Libs Program•Mad Libs– A game in which a passage of text is assumed with various blanks that are typed by parts of speech: adverb, adjective, noun, verb, etc.•We can create a program that plays this game interactively, prompting users to fill in these blanks•Use the function input againIntro to: Computers & Programming Defining Identifiers: Objects with Names V22.0002-001Mad Libs: Slide 2•Choose a short self-contained text from the web, e.g., the first paragraph of Wikipedia's featured article of the day.•Divide it into lines, with one print statement per line.•Replace some of the words with variables indicating their part of speech.•Precede print statements with queries to the user to set each of the variables.•Encapsulate the above into an executable
View Full Document