Question: please help me complete these 4 questions for my python lab Lab Exercise 1: Printing numbers using a while loop (Note: Create a new python



Lab Exercise 1: Printing numbers using a while loop (Note: Create a new python file named last_name_lab7_exercise1.py to work on the lab exercise 1. Submit the screenshot of your code and your output in brightspace) 1) In example 1. we looked over printing numbers from 1 to 5 . Using a while loop. write a program that prints numbers from 10 to 1. 2) Write a program that prints even numbers from 1-20 using a while loop in the same python file. You are only allowed to use a while loop for this exercise Ftead the code above, and answer the following questions. You can try running the code yourself and check what it does. Some of the things you can explain are: 1) How many times does the loop execute in the program? 2) In 2-3 sentences, explain what the program does. 3) What does the break command do in the above code? Try googling it if you are not sure. 4) How can you make the loop execute 10 times? 5) How can you make the loop execute for infinite times? What condition would make the loop execute an infinite number of times? Exercise 3: Password Guessing (Note: Create a new python file named last_name_lab7_exercise3.py to work on the lab exercise 3. Submit the screenshot of your code and your output in brightspace) Write a while loop that prompts the user to enter a password. If the password is " cos120 ". print "Access granted," and terminate the program. If the password is incorrect, print "Access denied. Try again.". The user will be given 4 chances to enter the right password. If the user can't guess the password in 4 chances, print "You ran out of guesses". Hint: This program is similar to Exercise 2, code. Make sure to use the break command to terminate the loop when the password entered by the user is correct. Example output: Enter the password: hello Access denied. Try again. Enter the password: aayush Access denied. Try again. Enter the password: cos 120 Access granted. Exercise 4: Printing item from a list using while loop (Note: Create a new python file named last_name_lab7_exercise4.py to work on lab exercise 4. Submit the screenshot of your code and your output in bright space) 1) Create a list named food with the following items: pizza, burrito, salad, burger, fries, lobster. 2) Using a while loop, print all the items in the list in sequential order. Your result should look similar to the example output below. Hint: One way to access an item from a list is through its index value. Example food[1] will retum burrito. If you can generate a range of index values using a while loop, you will be able to print all the items in the list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
