Question

IN PYTHON USING VERY BASIC FUNCTIONS * ALSO THIS IS TYPICALLY RUN THROUGH JDK AT THE...

 IN PYTHON USING VERY BASIC FUNCTIONS * ALSO THIS IS TYPICALLY RUN THROUGH JDK AT THE END TO GET 100% SCORE. EXAMPLES BELOW MUST BE FACTORED IN. KEEPING THE PROGRAM AS BASIC AS POSSIBLE.
 WLargestSmallest.py
  1. ask the user for a number n
  2. ask user for n numbers
  3. print smallest, largest 
  
  Here are some sample runs:
% python3 LargestSmallest.py
enter how many numbers you want to test: 4
enter number 1: 1
enter number 2: 100
enter number 3: -3
enter number 4: 2
largest:  100
smallest:  -3
% python3 LargestSmallest.py
enter how many numbers you want to test: 0
number must be positive
% python3 LargestSmallest.py
enter how many numbers you want to test: -1
number must be positive
% python3 LargestSmallest.py
enter how many numbers you want to test: 10
enter number 1: 10
enter number 2: 1
enter number 3: 2
enter number 4: 3
enter number 5: 4
enter number 6: 5
enter number 7: 6
enter number 8: 7
enter number 9: 8
enter number 10: 9
largest:  10
smallest:  1
% 
0 0
Add a comment Improve this question Transcribed image text
Answer #1
print("Enter how many numbers you want to test:",end = " ")
n = int(input())
if n <= 0:
    print("Number must be positive")
else:
    num = []
    for i in range(n):
        print("Enter number", i+1, end=":")
        num.append(int(input()))
    print("Largest: ", max(num))
    print("Smallest: ", min(num))

Output:

Screenshot of code:

Add a comment
Know the answer?
Add Answer to:
IN PYTHON USING VERY BASIC FUNCTIONS * ALSO THIS IS TYPICALLY RUN THROUGH JDK AT THE...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

  • Write a program using M.I.P.S that asks user “how many positive number that is devisable by...

    Write a program using M.I.P.S that asks user “how many positive number that is devisable by 6 you want to add?” .Then your loopcounter would be the user input. If the user enters a positive number between 1 and 100 that is devisable by 6, you increment your loop counter and add it to the sum.. You need to decide if the positive number entered by the user is divisible by 6 or not. Your program should print an error...

  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • use python: Write a program that reads in X whole numbers and outputs (1) the sum...

    use python: Write a program that reads in X whole numbers and outputs (1) the sum of all positive numbers, (2) the sum of all negative numbers, and (3) the sum of all positive and negative numbers. The user can enter the X numbers in any different order every time, and can repeat the program if desired. Sample Run How many numbers would you like to enter? 4 Please enter number 1: 3 Please enter number 2: -4 Please enter...

  • c++ fibonacci code using loops Here are 8 Fibonacci numbers: 1, 1, 2, 3, 5, 8,...

    c++ fibonacci code using loops Here are 8 Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21 Note that the first Fibonacci number is 1, F(1) = 1 The second Fibonacci number is 1, i.e. F(2) = 1 Other Fibonacci numbers in the sequence is the sum of two previous Fibonacci numbers. For example F(3) = F(2) + F(1). In general F(n) = F(n-1) + F(n-2) Write a program to do the following tasks. User entries are shown in...

  • important don't use arrays or listed pleaseeeee in python 3 Write a program that given a...

    important don't use arrays or listed pleaseeeee in python 3 Write a program that given a collection of ?N numbers will find the largest value, its frequency and the average of the ?N numbers. Get the value of ?N from the user. If ?≤0N≤0, display an appropriate error message and terminate the program; otherwise Read the values as entered from the user. (If ?=5N=5, then there are 5 values the user is going to enter). Find the largest, its frequency...

  • Python Script format please! 1. Write a script that takes in three integer numbers from the...

    Python Script format please! 1. Write a script that takes in three integer numbers from the user, calculates, and displays the sum, average, product, smallest, and largest of the numbers input. Important things to note: a. You cannot use the min() or max() functions, you must provide the logic yourself b. The calculated average must be displayed as an integer value (ex. If the sum of the three values is 7, the average displayed should be 2, not 2.3333). Example:...

  • IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we...

    IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we do the following: If the integer is odd, we multiply by 3 and add 1. If the integer is even, we divide by 2. It is hypothesized that the above sequence will always converge to the value of 1, regardless of any valid initial choice. This hypothesis is known as the Collatz Conjecture. For example, if we start at 5, the numbers generated by...

  • Must be done in python and using linux mint Write a program to create a text...

    Must be done in python and using linux mint Write a program to create a text file which contains a sequence of test scores. Each score will be between 0 and 100 inclusive. There will be one value per line, with no additional text in the file. Stop adding information to the file when the user enters -1 The program will first ask for a file name and then the scores. Use a sentinel of -1 to indicate the user...

  • Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST b...

    Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST be written as specified. In your main code test all of the specified functions. Each function must have a comment block explaining what it does, what the parameters are and what the return value is. Please remember the following two guidelines: unless the purpose of the function is to generate output DO NOT write to the screen within the function unless the purpose...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT