Question: Python help, really need help with step 4&5. In this lab you will be making lists, and using loops to execute your functions! If you

Python help, really need help with step 4&5.

Python help, really need help with step 4&5. In this lab youwill be making lists, and using loops to execute your functions! Ifyou have any questions about what lists are, or how to makea loop, go back to your readings or lectures to remind yourselves.Step 1 - Make a List This first step is about lookingover the function called makelist() This function takes in one parameter, an

In this lab you will be making lists, and using loops to execute your functions! If you have any questions about what lists are, or how to make a loop, go back to your readings or lectures to remind yourselves. Step 1 - Make a List This first step is about looking over the function called makelist() This function takes in one parameter, an integer. Within the function, it creates a new empty list. Then, there is a for loop that starts at 0 and ends at the parameter that was passed in. Every iteration of the for loop will be added to the empty list. Once the loop is done, it returns the list. Examples: makelist (10) \# returns [,1,2,3,4,5,6,7,8,9] makelist(3) \# returns [,1,2] In this step, you will be writing function called rocketcountdown() and it will take in one parameter, an integer. In this function you will start by making an empty list, then you will make a for loop that counts DOWN form the parameter to 0 (But not including 0 ). You will be adding each number as it is passed through the for loop to your list and when it hits 0, you will add the string 'We have lift off!' Examples: rocketcountdown (10) \# returns [10,9,8,7,6,5,4,3,2,1, 'We have lift off!'] rocketcountdown(2) \# returns [2, 1, 'We have lift off!'] In this step, you will create a function named doubleloop0 that will take in 2 parameters, both ints. This function will also return a list of numbers. You will want to make a nested loop for the list to parse through all the possible numbers between 0 and parameter one and between 0 and parameter two. You will pair them together with the use of string formatting and then separate them by a colon. Examples: \[ \begin{array}{l} \text { doubleloop(2, 2) \# returns }\left[{ }^{\prime} \theta: \theta^{\prime},{ }^{\prime} \theta: 1^{\prime}, '^{\prime} 1: \theta^{\prime}, '^{\prime} 1: 1^{\prime} ight] \\ \text { doubleloop }(3,4) \text { \# returns }\left[{ }^{\prime} \theta: \theta^{\prime}, ~ ' \theta: 1^{\prime}, \quad ' \theta: 2^{\prime}, ~ ' \theta: 3^{\prime}, '^{\prime} 1: \theta^{\prime} ight. \text {, } \\ \text { '1:1', '1:2', '1:3', '2:0', '2:1', '2:2', '2:3'] } \\ \end{array} \] Here's an example of a nested loop: for i in range(num1): for j in range(num2): list. append(' \{\},{} format (i,j)) In this step, you will be creating a function called howmanycombos() and it will take in 3 parameters, all integers. Like in step 1, you will be creating an empty list. The goal of this function is to return a list of all possible combinations in a lock (like the old ones that you would have to spin left to the first number, right to the second number, and then left again to the third number). You will be using nested for loops to make this function, each loop will go to the desired number that was passed into the parameter. So, the first loop will go from 0 to the first parameter, then the next loop will go from 0 to the second parameter, and the third one will go from 0 to the third parameter. To add the number combination to the list, use string formating (or fstring) to show which numbers that you used! each number will be separated by a ":" Once the list has all possible combinations, return the list to be printed. Hint: This is very similar to step 3, except there will be three loops nested instead of 2 . Examples: In this function, you will be writing a while loop. The function name is called cansofpop() and it will take in 2 parameters, both integers. The first integer will be the total number of cans of pop on the wall and the second integer will be the interval of how many cans of pop to take off the wall. You will be using the format string: ' {0} cans of pop on the wall {0} cans of pop, take {1} down and pass them around, {2} cans of pop on the wall' 5.1 In the beginning of your function you will create a new empty list. Then, you will write a while loop that will run until there are no more cans of pop to grab hint, you might need a conditional statement to check to make sure that you have 0 or

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!