Create a function calledlocker to find your answer

Assignment Help Python Programming
Reference no: EM132355625

Question

Help with python 3! Locker Puzzle assignment.

Solve the "locker puzzle." A school has 100 students and 100 lockers. All lockers are closed on the first day of school. As the students enter, the first student (S1) opens every locker. Then the second student (S2) begins with the second locker (L2), and closes every other locker. Student S3 begins with the third locker (L3) and changes every third locker (closes it if it was open, and opens it if it was closed). Student S4 begins with locker L4 and changes every fourth locker. Student S5 begins with locker L5 and changes every fifth locker, and so on, until student S100 changes L100.

After all the students have passed through the building and changed all of the lockers, which lockers are open? Create a function calledlocker_puzzle() to find your answer. The function should print out the list of open locker numbers.

Hint: Use a list of Booleans to indicate whether a locker is open (True) or closed (False). Use main function to call it.

Note that lst = [False] * 100will make a list of 100 booleans, all set to False.

The Output should be this in this order. I've figured out the open lockers I just can't implement the function and how to call it with the main() function

1

4

9

16

25

36

49

64

81

100

Any help or feedback is welcome :-)

#locker puzzle

def locker_puzzle(lst):

num_lockers = 100

num_students = 100

num = 1

locker_list = list(range(1, 100))

locker_list = [False or True] * 100

for i in range(len(locker_list)):

locker_list.append(num**2)

num += 1

return locker_list

def main():

l= list(range(1,100))

print(locker_puzzle(l))

main()

Reference no: EM132355625

Questions Cloud

Compute the sample mean of a list of numbers : The return value should be the sample mean and the input value should be the list of numbers. Do not use a built-in function for the mean. Show an example.
Discussion about the activity adaptation : Now that you have had the opportunity to interview a school psychologist and a teacher, and to observe a classroom, you will apply that knowledge to adapt.
Determine the plan that john would choose : A piano company launches a marketing campaign for its new pianos. There are three different offers provided to its customers:
Sytematic reflection - insane patients soon to go outside : NSB204 - Mental Health: Self and others - Queensland University of Technology Sytematic reflection: Based on Article Article - INSANE PATIENTS SOON TO GO
Create a function calledlocker to find your answer : Solve the "locker puzzle." A school has 100 students and 100 lockers. All lockers are closed on the first day of school. As the students enter.
What impact health insurance has on our economy today : The present health care system relies on public and private health insurance systems. On the basis of your understanding of the health insurance system.
Price has been increasing at 6 percent per year : Today, that company is valued at $53,296. How long has Randy owned the company if the price has been increasing at 6 percent per year?
Describe the semiotic visual elements in the logo design : Describe the semiotic/symbolic visual elements in the logo design. Discuss why having visual symbolic and iconic communication in a logo may be a good strategy.
Foreign exchange risk company faces : As the CFO of a multinational company, which financial securities can you use to manage the foreign exchange risk that your company faces?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd