Question

QUESTION 4 Consider the following block of Python code, where variables age_1, age_2 and age_3 each...

QUESTION 4

  1. Consider the following block of Python code, where variables age_1, age_2 and age_3 each store integer values:

    if age_1 > age_2:
        if age_2 > age_3:
            print(age_3)
        else:
            print(age_2)
    elif age_1 > age_3:
        print(age_3)
    else:
        print(age_1)

    Which of the following options best describes the purpose of the above code?

    To print the largest of the values stored in age_1, age_2 and age_3

    To print the largest of the values stored in age_1 and age_2 only

    To print the largest of the values stored in age_2 and age_3 only

    To print the middle of the values stored in age_1, age_2 and age_3

    To print the smallest of the values stored in age_1 and age_2 only

    To print the smallest of the values stored in age_2 and age_3 only

    To print the values stored in all of the variables

    The code has a different purpose depending on what values are stored in the variables

    To print the smallest of the values stored in age_1, age_2 and age_3

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

To print the smallest of the values stored in age_1, age_2 and age_3

Add a comment
Know the answer?
Add Answer to:
QUESTION 4 Consider the following block of Python code, where variables age_1, age_2 and age_3 each...
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
  • Two variables named largest and smallest are assigned for you. Use these variables to store the...

    Two variables named largest and smallest are assigned for you. Use these variables to store the largest and smallest of the three integer values. You must decide what other variables you will need and initialize them if appropriate. Write the rest of the program using assignment statements, if statements, or elif statements as appropriate. There are comments in the code that tell you where you should write your statements. The output statements are written for you. Execute the program. Your...

  • Using Python The variables x and y refer to numbers. Write a code segment that prompts...

    Using Python The variables x and y refer to numbers. Write a code segment that prompts the user for an arithmetic operator and prints the value obtained by applying that operator to x and y. Using the following information run an example in Python Idle op = input("Enter an arithmetic operator: ") if op == "+":     print(x + y) elif op == "-":     print(x – y) elif op == "*":     print(x * y) elif op == "/":...

  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

  • Create simple python beginners code that outputs a proverb upon request. Find 7 proverbs, wise sayings,...

    Create simple python beginners code that outputs a proverb upon request. Find 7 proverbs, wise sayings, or quotes Store your proverbs in an if-elif-else decision structure (see below) Your application should locate the corresponding proverb Print the proverb and its explanation to the screen, each on a separate line. Write a “welcome” message that greets the user and explains how the program works Ask your user to enter a positive integer. Echo back the user’s choice – for example, “You...

  • For Python 3.8! Copy and paste the following bolded code into IDLE: movies = [[1939, 'Gone...

    For Python 3.8! Copy and paste the following bolded code into IDLE: movies = [[1939, 'Gone with the Wind', 'drama'],           [1943, 'Casablanca', 'drama'],           [1965, 'The Sound of Music', 'musical'],           [1969, 'Midnight Cowboy', 'drama'],           [1972, 'The Godfather', 'drama'],           [1973, 'The Sting', 'comedy'],           [1977, 'Annie Hall', 'comedy'],           [1982, 'Ghandi', 'historical'],           [1986, 'Platoon', 'action'],           [1990, 'Dances with Wolves', 'western'],           [1992, 'Unforgiven', 'western'],           [1994, 'Forrest Gump', 'comedy'],           [1995, 'Braveheart', 'historical'],           [1997,...

  • 1) Which of the following is NOT true about a Python variable? a) A Python variable...

    1) Which of the following is NOT true about a Python variable? a) A Python variable must have a value b) A Python variable can be deleted c) The lifetime of a Python variable is the whole duration of a program execution.   d) A Python variable can have the value None.        2) Given the code segment:        What is the result of executing the code segment? a) Syntax error b) Runtime error c) No error      d) Logic error 3) What...

  • IN PYTHON. We have seen examples of using the python re library. In this practice, you...

    IN PYTHON. We have seen examples of using the python re library. In this practice, you need to write python code and complete following tasks. (You can decide whether you want to define functions and how to organize your code. It is for your own practice.) 1). Define 10 string variables that follows the requirement given an integer, a float, a double, a float end with letter f (4.321f), Capital Letters( followed by small case letters, followed by digits, Exactly...

  • this code is not working for me.. if enter 100 it is not showing the grades...

    this code is not working for me.. if enter 100 it is not showing the grades insted asking for score again.. #Python program that prompts user to enter the valuesof grddes . Then calculate the total scores , #then find average of total score. Then find the letter grade of the average score. Display the #results on python console. #grades.py def main(): #declare a list to store grade values grades=[] repeat=True #Set variables to zero total=0 counter=0 average=0 gradeLetter='' #Repeat...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • Consider the following piece of Python code. Which of the following statements best describes the code?...

    Consider the following piece of Python code. Which of the following statements best describes the code? Note: Python uses pass-by-sharing to pass lists and arrays. def roots (num_list): list = list() for n in num_list: if n >= 0: list.append(sqrt(n)) return list This is a generator that returns the roots of all positive numbers in the list This is a function that returns the roots of all positive numbers in the list This is an iterator and a generator that...

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