IFT – 101 (Info Tech Programming Logic)
P a g e | 1
Exam 2 – 50 points
Q. 1. What are different types of Loops supported in Python, explain with examples. (5 pts)
Q. 2. Write a program that continues to take number inputs from user until a 0 is entered and then counts the total number of positive numbers entered. (e.g. 10, -5, -3, 21, -4, 0 this should result in total number of positive numbers are 2.) (5 pts)
Q. 3. Write a program in Python that would generate a phone number if the user enters the number as 1ASU-HOLIDAY (which 1-278-465-4339) using the keypad below. (10 pts)
IFT – 101 (Info Tech Programming Logic)
P a g e | 2
Q. 4. Create a function in python named “ConvertOzTo”. This function takes 2 parameters or arguments, the first being ‘ounces’ and second being 1 or 2 or 3 where 1 indicates pounds; 2 indicates liters and 3 indicates gallons. Based on the values 1, 2 or 3 passed as a parameter to the function it converts the ounces into pounds /liters /gallons and returns the value and prints the ounces converted to new unit (10 pts)
Q. 5. Write a program that replaces words in the sentence “I like to go dancing in the rain, but rain should not be too heavy” such as dancing with driving, rain with forest and heavy with long. (5 pts)
Q 6. Write a program that counts the frequency (or number of the words) used in the string below and counts how many times the word “know” occurs in the string. (5 pts) I know you know what I know
Q 7. Make Five dictionaries, where the name of each dictionary is the name of a pet. In each dictionary, include the breed of animal and the owner’s name. Create a list that has these 5 dictionaries as elements and name the list as pets. Next, loop through your list and as you do print everything you know about each pet. (10 pts).