Create a new program called, "PassingValues" in Repl.it using python. In this program you are going to make a couple of functions that will use parameters. Follow the prompts below in order to create your program. Writing step-by-step instructions for programming so that everyone understands them is hard, so be careful and do exactly what is said below. Add the beginning comments at the top of the program. In the first part of your program, create a for loop that runs three times: Inside the for loop, prompt the user for an integer Prompt the user for another integer Call the function compare (you are going to create this function next) Pass the variables that you used for the integer inputs from above Create a function called compare (remember the function definition should go at the top of the program) and use two variables in the parameters of the function: Inside of the function, create an if / elif / else structure that compares the two values passed into the function If one value is less than the other, output that to the user (Ex: 2 is less than 4) Elif the other value is less than the other output something similar (Ex: 4 is less than 9) Else, output that they are equal to each other That is it for the first part of the program. Next, create an empty list called names. Create a loop that runs 6 times: Inside of the for loop, prompt the user for a name Append the name to the list Outside of the for loop, prompt the user for how many people they would like to vote off the island. Call the function eliminate and pass the variable you used from step 7 to it. Also, this function will return a value, so store this back function call back to a new variable. Create a function called eliminate and create a variable to use as the parameter: Inside the function, randomly shuffle (use the shuffle() method) all the values in the list (you will need to import random at the top of the program) Then using a for loop, loop it as many times as the value that was passed to the function: Inside the for loop, remove one name from the list (use the pop() method) Outside the for loop, but still inside the function, return the list of remaining people Underneath where you left off in step 8, print the remaining people that are left: those that did not get voted off the island. Again, these steps are very challenging (not because of functions and parameters) because it is hard to explain exactly how to create a program line-by-line. Do your best and if needed, ask your teacher for assistance (   they have an answer key :)   ) NOTE: You MUST use a procedure / function that includes parameters as part of the Create Performance Task.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a new program called, "PassingValues" in Repl.it using python. In this program you are going to make a couple of functions that will use parameters. Follow the prompts below in order to create your program. Writing step-by-step instructions for programming so that everyone understands them is hard, so be careful and do exactly what is said below.

  1. Add the beginning comments at the top of the program.
  2. In the first part of your program, create a for loop that runs three times:
    • Inside the for loop, prompt the user for an integer
    • Prompt the user for another integer
    • Call the function compare (you are going to create this function next)
    • Pass the variables that you used for the integer inputs from above
  3. Create a function called compare (remember the function definition should go at the top of the program) and use two variables in the parameters of the function:
    • Inside of the function, create an if / elif / else structure that compares the two values passed into the function
    • If one value is less than the other, output that to the user (Ex: 2 is less than 4)
    • Elif the other value is less than the other output something similar (Ex: 4 is less than 9)
    • Else, output that they are equal to each other
  4. That is it for the first part of the program.
  5. Next, create an empty list called names.
  6. Create a loop that runs 6 times:
    • Inside of the for loop, prompt the user for a name
    • Append the name to the list
  7. Outside of the for loop, prompt the user for how many people they would like to vote off the island.
  8. Call the function eliminate and pass the variable you used from step 7 to it.
  9. Also, this function will return a value, so store this back function call back to a new variable.
  10. Create a function called eliminate and create a variable to use as the parameter:
    • Inside the function, randomly shuffle (use the shuffle() method) all the values in the list (you will need to import random at the top of the program)
    • Then using a for loop, loop it as many times as the value that was passed to the function:
      • Inside the for loop, remove one name from the list (use the pop() method)
    • Outside the for loop, but still inside the function, return the list of remaining people
  11. Underneath where you left off in step 8, print the remaining people that are left: those that did not get voted off the island.

Again, these steps are very challenging (not because of functions and parameters) because it is hard to explain exactly how to create a program line-by-line. Do your best and if needed, ask your teacher for assistance (   they have an answer key :)   )

NOTE: You MUST use a procedure / function that includes parameters as part of the Create Performance Task.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education