Question

Question 17 (3 points) Predict the output of the following code segment: a = 99.98 if a + 0.01 >= 100: print(A) elif a + 0.
Question 16 (3 points) Predict the output of the following code segment: X = 6 if x % 2 == 0: print (x is even.) else: prin
Please use the decimal point to distinguish int and float. For example, number 3 + number 4 is float. so we must write 15.0 i
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hey, I am telling the output along with the reason for that output-

1) 
a=99.98
if a+0.01>=100:
    print('A')
elif a+0.02>=100:
    print('B')
    print('C')
else:
    print('D')


print('E')

So, the output is-

B
C
E


This is because a=99.98, if we add 0.01 then, it is less than 100, so it will not enter the if condition, so, it will move to eilf condition where in a+0.02=100, hence , it goes inside the elif condition and print B and C.

After that, E gets printed as it is outside if-else .

********************************************************************************************************************************

2)

x=6
if x%2==0:
    print("x is even")
else:
    print("x is odd")

Output is-

x is even

This is because 6%2==0, so it goes inside the if condition and print ' x is even'.It does not go in else condition.

****************************************************************************************************************************

3)

Hey, here values for number1, number2, number3 and number4 are not mentioned, so I'm assuming by myself.

Let, number1=5

number2=20

number3=10.0

number4=5.0

number1 and number2 are int,

number3 and number4 are float

number1=5
number2=20
number3=10.0
number4=5.0

value2=number1//number2
print(value2)

value2=number1/number2
print(value2)

value3=number4/number3
print(value3)

number1=number1+number1
number2=number1*number1
number1=number1+number2
print(number1, number2)

number3=number3+number4
number4=number4*2
number3=number3+number4
print(number3,number4)

Output is-

0
0.25
0.5
110 100
25.0 10.0

Initially,

number1=5

number2=20

number3=10.0

number4=5.0

1) value2=5//20=0 (gives floor result)

2) value2=5/20=0.25 (gives actual result)

3) value3=5.0/10.0=0.5(float)

4) number1=number1+number1=5+5=10

number2=number1*number1=100

number1=number1+number2=10+100=110

5) number3=number3+number4=15.0

number4=number4*2=5.0*2=10.0

number3=number3+number4=10.0+15.0=25.0

Add a comment
Know the answer?
Add Answer to:
Question 17 (3 points) Predict the output of the following code segment: a = 99.98 if...
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
  • Need Help With The TODO Numbers Tools Configure Window Help Edit View Project Build Run BB9-...

    Need Help With The TODO Numbers Tools Configure Window Help Edit View Project Build Run BB9- Projectl_NumberCalculationsja... X public static void main(String[] args) Scanner input = new Scanner(System.in); int numberl; //first number int number2; //second number int number 3; //third number int largest; //largest value int smallest; // smallest value int sum // sum of numbers int product; //product of numbers int average: //average of numbers /* TODO#1: write a series of statements to read in three numbers and assign...

  • Debug the following java code so that it will have given out put at the bottom....

    Debug the following java code so that it will have given out put at the bottom. Make sure to fix all syntax and logical errors. import java.util.Scanner; public class Graphs { // draws 5 histograms public void drawHistograms() Scanner input = new Scanner( System.in ); int number1 = 0; // first number int number2 = 0; // second number int number3 = 0; // third number int number4 = 0; // fourth number int number5 = 0; // fifth number...

  • What is the output of the following pseudo-code segment? A, B, C, or None of the...

    What is the output of the following pseudo-code segment? A, B, C, or None of the above ** In pseudo-code, you ignore syntax errors and focus on the logic ** score = 60 if (score >= 70) print "C" else if (score >= 80) print "B" else if (score >= 90) print "A" and score = 105 if (score >= 90 && score <= 100) print "A" else if (score >= 80) print "B" else print "C"

  • Python: 1) What output is generated by the following code segment? table = [["T", "U", "V"],...

    Python: 1) What output is generated by the following code segment? table = [["T", "U", "V"], ["W", "X", "Y"]] print(table[0]) Group of answer choices a- T b- ["T", "W"] c- ["T", "U", "V"] d- [["T", "U", "V"], ["W", "X", "Y"]] 2) Consider the following code segment: values = [4, 12, 0, 1, 5] print(values[1]) What is displayed when it runs? Group of answer choices a- 0 b- 1 c- 4 d- 12 3) Consider the following code segment: x =...

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • 31. The following code segment is syntactically correct:              int number{20};          cout << number <<...

    31. The following code segment is syntactically correct:              int number{20};          cout << number << setbase(16) << " " << number                               << setbase(10) << " " << number                                 << showpos << " " << number << endl;                 T__   F__       32. The following statement wants to determine if ‘count’ is outside the     range of 0 through 100:             if (count < 0 && count > 100)                                             T__   F__ 33. There is...

  • c# QUESTION 1 owing code segment? What is the output for the foll Stack myStack new...

    c# QUESTION 1 owing code segment? What is the output for the foll Stack myStack new Stack0: myStack.Push One"); myStack.Pushl Two"); myStack.Push( Three"); myStack Push Four" myStack.Push Five" Console.WriteLine(myStack.PopO): O One Two O Three O Four Five QUESTION 2 What must x be to print out a 'G' in the the following code fragment? char i = (char)((int)x + 3); Console.WriteLine(); O charx 65; O charx 75; char x = 'A'; O char x-D O intx 68; QUESTION 3 What...

  • Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int...

    Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int main0 // define two integers int x-3; int y = 4; //print out a message telling which is bigger if (x >y) i cout << "x is bigger than y" << endl: else cout << "x is smaller than y" << endl; return 0; Example (5) Write a C++ program that takes from the user a number in SR (Saudi Riyal) then the program...

  • Question 1 The code used to output messages to the screen begins with run # print...

    Question 1 The code used to output messages to the screen begins with run # print output Flag this Question Question 2 The code used to begin a comment in the Python program source code is # Hello * Comment Flag this Question Question 3 A variable name is like a(n) input typed on a keyboard address in computer memory where values can be stored output to a computer screen value assigned to an address in computer memory Flag this...

  • 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...

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