Write a function, sublist, that takes in a list of numbers as the parameter. In the function, use a while loop to return a sublist of the input list. The sublist should contain the same values of the original list up until it reaches the number 5 (it should not contain the number 5).
Checkpoint11.9.2.
Write a function called check_nums that takes a list as its parameter, and contains a while loop that only stops once the element of the list is the number 7. What is returned is a list of all of the numbers up until it reaches 7.
Checkpoint11.9.3.
Write a function, sublist, that takes in a list of strings as the parameter. In the function, use a while loop to return a sublist of the input list. The sublist should contain the same values of the original list up until it reaches the string βSTOPβ (it should not contain the string βSTOPβ).
Checkpoint11.9.4.
Write a function called stop_at_z that iterates through a list of strings. Using a while loop, append each string to a new list until the string that appears is βzβ. The function should return the new list.
Checkpoint11.9.5.
Below is a for loop that works. Underneath the for loop, rewrite the problem so that it does the same thing, but using a while loop instead of a for loop. Assign the accumulated total in the while loop code to the variable sum2. Once complete, sum2 should equal sum1.
Checkpoint11.9.6.
Challenge: Write a function called beginning that takes a list as input and contains a while loop that only stops once the element of the list is the string βbyeβ. What is returned is a list that contains up to the first 10 strings, regardless of where the loop stops. (i.e., if it stops on the 32nd element, the first 10 are returned. If βbyeβ is the 5th element, the first 4 are returned.) If you want to make this even more of a challenge, do this without slicing
Checkpoint11.9.7.
Consider the above screenshot of CodeLens animation. What line number has the exit condition for the while loop?
How many more times will the exit condition be checked?
Checkpoint11.9.8.
The above screenshot shows a program in mid execution. What will the variable score be equal to after the current iteration of the loop completes?
Checkpoint11.9.9.
:
The above screenshot is in mid execution. Assuming the user enters 0 next, select all that are true.
The loop exits and number_sum is printed
Incorrect, take another look at our exit condition and the variable that the user is changing
number_sum is now equal to 36
Incorrect, number_sum is currently equal to 29 and the next number added will be 0
The loop continues to execute
Correct, this is an infinte loop since we never alter the variable exitβs value
num is now equal to 0
Correct, the user has entered 0, overwriting nums previous value of 7