Question

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: If I were to input 3, 4, and 5 for my integers, the output would be:

Problem 1 Solution Please enter the first number 3 Please enter the second number: 4 Please enter the third number: 5 The sum is: 12 The average is: The product is: 60 The largest number is 5 The smallest number is 3

2. Write a script that calculates the squares and cubes of the integers from 0 to 10, printing the results in a table format, shown below:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

\color{red}\underline{1:}

n1 = int(input("Please enter the first number: "))
n2 = int(input("Please enter the second number: "))
n3 = int(input("Please enter the third number: "))
n4 = int(input("Please enter the fourth number: "))
n5 = int(input("Please enter the fifth number: "))

smallest = n1
if n2 < smallest:
    smallest = n1
if n3 < smallest:
    smallest = n2
if n4 < smallest:
    smallest = n4
if n5 < smallest:
    smallest = n5

largest = n1
if n2 > largest:
    largest = n1
if n3 > largest:
    largest = n2
if n4 > largest:
    largest = n4
if n5 > largest:
    largest = n5

print("The sum is:              " + str(n1 + n2 + n3 + n4 + n5))
print("The average is:          " + str((n1 + n2 + n3 + n4 + n5)/5))
print("The product is:          " + str(n1 * n2 * n3 * n4 * n5))
print("The largest number is:   " + str(largest))
print("The smallest number is:  " + str(smallest))

\color{red}\underline{2:}

print("Number  Square  Cube")
i = 0
while i <= 10:
    print("{:<8d}{:<8d}{:d}".format(i, i*i, i*i*i))
    i += 1

Add a comment
Know the answer?
Add Answer to:
Python Script format please! 1. Write a script that takes in three integer numbers from 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
  • Unix classes Write a bash script that take in three integer numbers from the command line...

    Unix classes Write a bash script that take in three integer numbers from the command line and print out the sum and the average. Name the script awesum.sh hb1170uxb4:~$ ./awesum.sh 100 200 300 sum: 600 average: 200 hb1170uxb4: ~S

  • Please write a C++ program that will accept 3 integer numbers from the user, and output...

    Please write a C++ program that will accept 3 integer numbers from the user, and output these 3 numbers in order, the sum, and the average of these 3 numbers. You must stop your program when the first number from the user is -7. Design Specifications: (1) You must use your full name on your output statements. (2) You must specify 3 prototypes in your program as follows: int max(int, int, int); // prototype to return maximum of 3 integers...

  • I need to write a C++ program that reads two integers from a data filed called...

    I need to write a C++ program that reads two integers from a data filed called "integers.dat" The first integer should be low and the other one high. The program should loop through all integers between the low and high values and include the low and high integers and then display Display the integers in the file Displays the number of integers divisible by 5 OR 6, but not both. Displays the sum of the integers from condition 2 as...

  • UNIX QUESTION Write an argument-less shell script "Sum4.csh", which reads four integer values from the keyboard,...

    UNIX QUESTION Write an argument-less shell script "Sum4.csh", which reads four integer values from the keyboard, computes their sum, then displays the sum in expression format. EXAMPLE: % Sum4.csh Enter the first number: 4 Enter the second number: 7 Enter the third number: 3 Enter the fourth number: 11 RESULT: 4 + 7 + 3 + 11 = 25

  • In Python 3 - Write a program that reads a sequence of integer inputs from the...

    In Python 3 - Write a program that reads a sequence of integer inputs from the user. When the user is finished entering the integers, they will enter a 'q'. There is no need to check if the entry is a valid integer. All integers in the test data (input) will be between -255 and 255. The program should then print: The smallest and largest of the inputs. The number of even and odd inputs (0 should be considered even)...

  • Write a Unix shell script that takes three integers and sorts them from largest to smallest....

    Write a Unix shell script that takes three integers and sorts them from largest to smallest. An example execution is as follows (assume the name of the script is shs): % shs 3 9 4 The order is: 9 4 3 % shs -1 0 3 The order is: 0 -1 -3

  • d printAllIntegers () Write a C++ program that defines and tests a function largest(....) that takes...

    d printAllIntegers () Write a C++ program that defines and tests a function largest(....) that takes as parame- ters any three integers and returns the largest of the three integers. Your output should have the same format and should work for any integers a user enters Desired output: Enter three integers: 6 15 8 The largest integer is: 15 7.3 Recursive Functions Write a program that uses a function sum(int) that takes as an argument a positive integer n and...

  • Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds...

    Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds the sum and average of a series of numbers he program should first prompt the user to enter total numbers of numbers are to be summed and averaged. It should then as for input for each of the numbers, add them, and print the total of the numbers and their average 2. Write a progra m that finds the area of a circle. The...

  • 3. Write a Java method (called sumOfSquares) that reads in a sequence of integer numbers using...

    3. Write a Java method (called sumOfSquares) that reads in a sequence of integer numbers using a Scanner object. As each integer is read, the method displays that integer. The method also accumulates the sum of the squares of the integers and displays the sum when all integers are read. The method reads integers until a negative integer is read. The negative integer should not be display or added to the sum of squares. The method will not return a...

  • C++ Write a program that reads three positive integers (> 0) from the command line (one...

    C++ Write a program that reads three positive integers (> 0) from the command line (one at a time), then computes and prints the smallest entered number. Use if-else statements for three integer comparison. Example: Enter an integer: 5 Enter an integer: 23 Enter an integer: 7 The smallest number is: 5 Example 2: Enter an integer: 3 Enter an integer: 3 Enter an integer: 6 The smallest number is: 3 "The input must be positive number. The program should...

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