4.7 LAB: Translate pseudocode into Python program Translate the following pseudocode for finding the minimum value from a set of inputs into a Python program. • Set a Boolean variable "first" to true. • While another value has been read successfully ? If first is true ? Set the minimum to the value. ? Set first to false ? Else if the value is less than the minimum ? Set the minimum to the value. • Print the minimum. Ex: If the input is 4 13 7 9 11 Enter a value (blank line to quit): 4 Enter a value (blank line to quit): 13 Enter a value (blank line to quit): 7 Enter a value (blank line to quit): 9 Enter a value (blank line to quit): 11 Enter a value (blank line to quit): the output would be: The minimum value is 4.0
Added by Susan L.
Close
Step 1
#!/usr/bin/env python import sys def findMinimum(inputs): first = True while True: if first: min = inputs[0] else: min = inputs[1] if min < input_list[0]: input_list[0] = min elif input_list[0] > min: input_list[0] = min print("The minimum value is %d" Show more…
Show all steps
Your feedback will help us improve your experience
Aarya B and 81 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Aarya B.
Python Please: Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3, the output is: 3.
Liam H.
Write a program in the file MinMax.py that accepts an arbitrary number of integer inputs from the user and prints out the minimum and maximum of the numbers entered. The user will end the input loop by typing in the string 'stop'. When the user enters 'stop', your program should print out the minimum integer entered and the maximum integer entered. If the user enters 'stop' immediately (i.e., before any numbers are entered), you'll print a slightly different message. See the examples below: You can assume that the values entered are integers (positive, negative, or zero) or the string 'stop' (lowercase). You don't have to validate the inputs. > python MinMax.py Enter an integer or 'stop' to end: stop You didn't enter any numbers > python MinMax.py Enter an integer or 'stop' to end: -10 Enter an integer or 'stop' to end: 0 Enter an integer or 'stop' to end: +42 Enter an integer or 'stop' to end: 87 Enter an integer or 'stop' to end: -100 Enter an integer or 'stop' to end: stop The maximum is 87 The minimum is -100
Shelayah R.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD