Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 The list inp is a list of integers. Write a while loop that does the following: Iterates over the list inp. If the
Problem The list inp is a list of integers. Write a while loop that does the following: Iterates over the list inp. If the number is greater than terminate the loop. If the number is less than or greater than print the skip message shown. Use the chr function to convert the number to an ASCII printable character. Catenatejoin the character to the string variable message. Print the message. You will need to use an IFELIFELSE statement. inp # write your code below Expected Output: Skipped Skipped Skipped The message is GoBlue! Problem The list type has a method called pop which removes and returns an element from a list using a index passed to the method. For example, given: lst abc c lstpop # return the first element a in the list, remove it from lst # at this point, c has the value a and lst has the elements bc c lstpop # return the first element b in the list, remove it from lst # at this point, c has the value b and lst has the elements c Write code that builds a list of things from elements of the list things. Do the following: Initialize a variable to an empty list Iterate continuously using while: Pop the first element in the list things. If element has a value of 'none' or 'None' Terminate the loop Append the element to the list. Print the list things books'movies','none','fitness','yoga','running' # write your code below Expected Output: books 'movies' Problem Write a code that calculates the largest, smallest and average score in the set of entered scores. Do the following: Initialize a variable to an empty list. This variable will hold the scores. Initialize a counter variable. Accept the number of scores from the user. Iterate continuously: If the counter is less than the number of scores: Accept a score from the user. Append the score to the scores list. increment the counter. Otherwise: Calculate the largest score you may use a function Calculate the smallest score you may use a function Terminate the loop Calculate the average score. Print the average, smallest, and largest score as shown below. Expected Output: Given the input below: How many scores are you entering? Add another number: Add another number: Add another number: Add another number: Add another number: The average score is: The smallest score is: The largest score is: Problem Complete the function called gcf that calculates the Greatest Common FactorDivisor given two integers. The function accepts two integers x and y as parameters and returns the GCF using the Euclidean algorithm below. You need to use a while loop. Step : r x y Step : x y Step : y r Step : Repeat Steps through while y is greater than Step : GCF x Write code that iterates over the list numberpairs you may use a for statement and calls the function gcf with each pair and prints the output shown below. # write the function below # Do not change the line below numberpairs # write your code below Expected Output: The greatest common factor of is The greatest common factor of is The greatest common factor of is Problem The problem requires using the function computeScrabbleScore developed in an earlier problem set. Copy the code for the function to the cell below. Write code that repeatedly prompts the user for a word until the sentinel "None" or "none" is entered. In the loop, call computeScrabbleScore with the word entered then add the word and its value as a keyvalue pair into the dictionary scrabbleWords. Print scrabbleWords. # Copy the function computeScrabbleScore here # write your code below Expected Output: Given the input below: Please input a word, enter 'None' or 'none' to cancel: Hello Please input a word, enter 'None' or 'none' to cancel: World Please input a word, enter 'None' or 'none' to cancel: None The expected output is: hello: 'world': Problem Alter the above code so that it iterates over the list things and builds a list of tuples where the first element of the tuple is the list element and the second the Scrabble value of the element. Use the while statement to iterate continuously over things stopping when the list element has a value of 'none' or 'None'. Print the list after the loop terminates. Use the list pop method to extract elements from things. things books'movies','fitness','yoga','running','None',ab # Copy the function computeScrabbleScore here # write your code below Expected Output: booksmoviesfitnessyogarunning Problem Write code that divides each value in the list dividend by eac
Problem
The list inp is a list of integers. Write a while loop that does the following:
Iterates over the list inp.
If the number is greater than terminate the loop.
If the number is less than or greater than print the skip message shown.
Use the chr function to convert the number to an ASCII printable character.
Catenatejoin the character to the string variable message.
Print the message.
You will need to use an IFELIFELSE statement.
inp
# write your code below
Expected Output:
Skipped
Skipped
Skipped
The message is GoBlue!
Problem
The list type has a method called pop which removes and returns an element from a list using a index passed to the method. For example, given:
lst abc
c lstpop # return the first element a in the list, remove it from lst
# at this point, c has the value a and lst has the elements bc
c lstpop # return the first element b in the list, remove it from lst
# at this point, c has the value b and lst has the elements c
Write code that builds a list of things from elements of the list things.
Do the following:
Initialize a variable to an empty list
Iterate continuously using while:
Pop the first element in the list things.
If element has a value of 'none' or 'None'
Terminate the loop
Append the element to the list.
Print the list
things books'movies','none','fitness','yoga','running'
# write your code below
Expected Output:
books 'movies'
Problem
Write a code that calculates the largest, smallest and average score in the set of entered scores.
Do the following:
Initialize a variable to an empty list. This variable will hold the scores.
Initialize a counter variable.
Accept the number of scores from the user.
Iterate continuously:
If the counter is less than the number of scores:
Accept a score from the user.
Append the score to the scores list.
increment the counter.
Otherwise:
Calculate the largest score you may use a function
Calculate the smallest score you may use a function
Terminate the loop
Calculate the average score.
Print the average, smallest, and largest score as shown below.
Expected Output:
Given the input below:
How many scores are you entering?
Add another number:
Add another number:
Add another number:
Add another number:
Add another number:
The average score is:
The smallest score is:
The largest score is:
Problem
Complete the function called gcf that calculates the Greatest Common FactorDivisor given two integers. The function accepts two integers x and y as parameters and returns the GCF using the Euclidean algorithm below. You need to use a while loop.
Step : r x y
Step : x y
Step : y r
Step : Repeat Steps through while y is greater than
Step : GCF x
Write code that iterates over the list numberpairs you may use a for statement and calls the function gcf with each pair and prints the output shown below.
# write the function below
# Do not change the line below
numberpairs
# write your code below
Expected Output:
The greatest common factor of is
The greatest common factor of is
The greatest common factor of is
Problem
The problem requires using the function computeScrabbleScore developed in an earlier problem set. Copy the code for the function to the cell below.
Write code that repeatedly prompts the user for a word until the sentinel "None" or "none" is entered. In the loop, call computeScrabbleScore with the word entered then add the word and its value as a keyvalue pair into the dictionary scrabbleWords. Print scrabbleWords.
# Copy the function computeScrabbleScore here
# write your code below
Expected Output:
Given the input below:
Please input a word, enter 'None' or 'none' to cancel: Hello
Please input a word, enter 'None' or 'none' to cancel: World
Please input a word, enter 'None' or 'none' to cancel: None
The expected output is:
hello: 'world':
Problem
Alter the above code so that it iterates over the list things and builds a list of tuples where the first element of the tuple is the list element and the second the Scrabble value of the element. Use the while statement to iterate continuously over things stopping when the list element has a value of 'none' or 'None'. Print the list after the loop terminates.
Use the list pop method to extract elements from things.
things books'movies','fitness','yoga','running','None',ab
# Copy the function computeScrabbleScore here
# write your code below
Expected Output:
booksmoviesfitnessyogarunning
Problem
Write code that divides each value in the list dividend by eac
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started