Skip to main content

Section 7.6 Integration Practice

Checkpoint 7.6.1.

    The CodeLens screenshot above shows a piece of code mid execution. Which of the following images shows the correct global frame state? Pay special attention to where the arrows are in the screenshot.
  • i
  • Not quite, walk through the code line by line
  • ii
  • Correct!
  • iii
  • Not quite, walk through the code line by line

Checkpoint 7.6.2.

    Which code snippet would result in the given CodeLens screenshot of the Global frame?
  • i
  • Correct!
  • ii
  • Not quite, walk through the code line by line and see what it would produce
  • iii
  • Not quite, walk through the code line by line

Checkpoint 7.6.3.

Using the image of the CodeLens program above, what will the program output to the console?

Checkpoint 7.6.4.

Write a Python program that asks the user to enter a temperature in Celsius three times (accomplish this using a loop). For each input, calculate and display the equivalent temperature in Fahrenheit (accomplish this using a function called temperature_convertor). Your function should return the temperature in Fahrenheit for each iteration. Print this temperature to the user.

Checkpoint 7.6.5.

Define a function called palindrome_checker. The program should prompt the user to input a string of text and then the function should determine whether the inputted text is a palindrome. A palindrome is defined as a word, phrase or a number that reads the same forward and backward disregarding spaces.

Checkpoint 7.6.6.

Define a function that counts the number of vowels and consonants in a string by iterating over the string and using conditionals to check if the alphabet is a vowel. Ask the user for an input string.

Checkpoint 7.6.7.

Define 3 separate functions to draw a triangle, circle and square in the turtle module. Ask the user for input and draw the shape based on that input using conditionals. (Example. S for square, T for triangle and C for circle). Ask for input 5 times using a for loop. Each time the shape should be drawn at a random location.

Checkpoint 7.6.8.

Ask the user to input an integer. Define a function that checks if the integer is positive and prints all the odd numbers up to that integer. If it is negative, the program should print “Invalid input, please enter a positive integer". The function should run thrice.

Checkpoint 7.6.9.

Ask the user to input an integer. Define a function to check if the input is a prime number. For this exercise, consider anything that does not get divided by the first 10 numbers a prime number.

Checkpoint 7.6.10.

Ask the user for an integer input. Define a Boolean myInteger and set it to False. If the integer is below 50 run the function to ask for the input again. Once, an integer above 50 is found, the Boolean should switch to True, end the program and print “My integer found”.

Checkpoint 7.6.11.

Develop a program for a bookstore. Write a function called calculate_discount. If the customer is regular, discount should be 10 percent. If a premium customer, 15 percent discount and no discount for a guest. Also, the discount should be applied only when the bill total is above 50 dollars. Your function should take in the initial bill amount and the status of the customer as input. Print out the final amount to be charged.

Checkpoint 7.6.12.

Define a Boolean called isTeenager and set it to false. Define a function to check if a user is a teenager. If the age is less than 13 or more than 19, the Boolean should not change, and it should print “Not a teenager”. If it’s between 13 and 19, changes Boolean to true and prints "Teenager”. Ask the user to input the age.

Checkpoint 7.6.13.

Write a method called spiral that uses turtle to create a spiral square illusion. In each iteration of the loop, the turtle should turn slightly more than 90 degrees (e.g., 92 degrees), and the side length should gradually increase. Use a conditional to stop the loop after a certain number of iterations.

Checkpoint 7.6.14.

Write a method called password_validator that checks if a given string is a valid password with the following criteria: at least 8 characters long, contains at least one uppercase letter, one lowercase letter, and one digit. Use loops and conditionals to verify these conditions.

Checkpoint 7.6.15.

Write a method that uses nested for loops to print the following pattern, where the number of rows is provided by the user. If the number provided by the user is above 10 or negative, ask for another input and run the program again. 1 2 2 3 3 3 4 4 4 4

Checkpoint 7.6.16.

Write a method that asks the user for a sentence and then uses a for loop to count the frequency of the letter “a” in the sentence and print it.

Checkpoint 7.6.17.

Write a method that asks the user for the principal, rate of interest, and number of years. Use a for loop to calculate the amount of simple interest each year and print it out for each year. Ask the user for another input if the rate of interest is above 10 percent. Use the formula Simple Interest = (principal * rate * year)/100.

Checkpoint 7.6.18.

Write a method that asks the user for a number, then prints the square and cube of every number from 1 to that number using a for loop. Ask the user for another input if the number given is above 15.

Checkpoint 7.6.19.

Nina lives in Winnipeg and wants to be prepared for any extreme temperatures this week. Write her a method called temperature_warning_system which runs seven times and uses a for loop and conditionals to print "Warning: Very Hot!" on days when the temperature is above 90 degrees Fahrenheit, and "Warning: Very Cold!" when below 30 degrees Fahrenheit. If the temperature is between 30 and 90, print “All good”.

Checkpoint 7.6.20.

Write a method called factorial_calculator that asks the user for a non-negative integer and then uses a for loop to calculate the factorial of that number. Print the factorial result. If a negative integer has been entered, run the program again.

Checkpoint 7.6.21.

Ask the user for a string. Write a method called vowel_replacement that asks the user for a string and uses a for loop and conditionals to replace every vowel in the string with the letter z and print the new string.
You have attempted of activities on this page.