Question

PLEASE DO THIS IN PYTHON!! Question 5 (Which CASE? - 10 pts) – What is the...

PLEASE DO THIS IN PYTHON!!

Question 5 (Which CASE? - 10 pts) – What is the output of the following code?

CREATE x <-- 5

SWITCH (x)

CASE 1: PRINTLINE (“hello world”)

BREAK

CASE 2: PRINTLINE (“hELLO wORLD”)

CASE 3: PRINT (“HELLO WORLD”)

                        BREAK

CASE 4: PRINTLINE(“Hello”)

CASE 5: PRINT(“World”)

                        BREAK

            DEFAULT: BREAK

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

Solution:

Switch case is not available in python. So it is replaced by if and else if statements and the program will be as follows

Program:

x=5
if x == 1:
print "hello world "
elif x == 2:
print "hELLO wORLD "
elif x == 3:
print "HELLO WORLD "
elif x == 4:
print "Hello "
elif x == 5:
print "World"
else :
print ""

The output of the program is World .

Add a comment
Know the answer?
Add Answer to:
PLEASE DO THIS IN PYTHON!! Question 5 (Which CASE? - 10 pts) – What is 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 java - Question 5 (Which CASE? - 10 pts) – What is the output of...

    In java - Question 5 (Which CASE? - 10 pts) – What is the output of the following code? CREATE x <-- 5 SWITCH (x) C ASE 1: PRINTLINE (“hello world”) BREAK CASE 2: PRINTLINE (“hELLO wORLD”) CASE 3: PRINT (“HELLO WORLD”) BREAK CASE 4: PRINTLINE(“Hello”) CASE 5: PRINT(“World”) BREAK DEFAULT: BREAK

  • PSUEDOCODE ONLY!! What is the output of the following code? CREATE x 1 SWITCH (x) Print...

    PSUEDOCODE ONLY!! What is the output of the following code? CREATE x 1 SWITCH (x) Print output here: Print output here: BREAK CASE 2: PRINTLINE (“hELLO wORLD”) CASE 3: PRINT (“HELLO WORLD”) BREAK CASE 4: PRINTLINE(“Hello”) CASE 5: PRINT(“World”) BREAK DEFAULT: BREAK

  • all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function,...

    all in pseudocode Question 1) Warmup question: Write a function named True False() (only the function, no main is needed) that takes in a number and determines if it is evenly divisible by 5 (le, returns true or false). (15 points) Answer is in: Pseudocode CHO Java0 C+0 Page 17 Question 3) 2D Arrays The IRS has contracted you to process a 10x10 array of floating point numbers called Taxes and sum up all negative numbers in the array so...

  • Python Please, If possible, please continue with/ use code already given File Commands: u/a Write a...

    Python Please, If possible, please continue with/ use code already given File Commands: u/a Write a function named, file_commands, that takes the name of a file as a parameter. The function processes the contents the file as follows: For file lines that begin with the letter 'a', calculate & print the integer average of the numbers on the line. For file lines that begin with the letter 'u', print the upper case format for each word following the u. Sample...

  • Question 5: Consider the following C++ program. switch(x) case 1: if (x > 1) case 2:...

    Question 5: Consider the following C++ program. switch(x) case 1: if (x > 1) case 2: if (x > 3) case 3: cout<<"Epic Beats!" << endl; case 4: cout << "Chill Vibes" << endl; break; case 5: cout << "Sweet Jazz" << endl; break; default: cout << "Invalid input. Try again."; A. What is the output if x = 1? B. What is the output if x = 3? C. What is the output if x = 2? D. What...

  • Question 5 (1 point) userGuess ← 0, secretNumber ← 5 PRINT “Enter a number between 1...

    Question 5 (1 point) userGuess ← 0, secretNumber ← 5 PRINT “Enter a number between 1 and 10” READ userGuess WHILE (userGuess < 1 OR userGuess > 10) PRINTLINE “That is not between 1 and 10. Try again.” READ userGuess ENDWHILE IF (userGuess == secretNum) THEN PRINTLINE “That’s right! ”, userGuess, “ is the secret!” ELSE PRINTLINE userGuess, “ is not the secret!” ENDIF What is the first WHILE loop being used for? Question 5 options: Input validation Random number...

  • Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point...

    Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point (graded)       hot_plate = True if hot_plate:     print("Be careful, hot plate!") else:     print("The plate is ready.") The output of from running the above code is ___ "Be careful, hot plate!" "The plate is ready." "True" NameError Question 3 0.0/1.0 point (graded)       vehicle_type = "Truck" if vehicle_type.upper().startswith("P"):     print(vehicle_type, 'starts with "P"') else:     print(vehicle_type, 'does not start with "P"')     The...

  • please answer in C code and leave comments on what the code does in the code...

    please answer in C code and leave comments on what the code does in the code switch (n % 10) case 1: x = n; break: case 3: - y = 10; case 5: x-n.2: break; default: x=0; y = 0; break; ] What will be values of x and y equal to after exiting this switch operator if right before the switch, values of and y were both equal to -35, and n was one of these: n before...

  • need help with java questions The following snippet of code would produce what outcome? public static...

    need help with java questions The following snippet of code would produce what outcome? public static void main(String 2 [] args) { int day = 5; switch (day) { case 1: System.out.println("Monday "); case 2: System.out.println("Tuesday "); case 3: System.out.println("Wednesday "); case 4: System.out.println("Thursday "); case 5: System.out.println("Friday "); case 6: System.out.println("Saturday "); case 7: System.out.println("Sunday "); break; default: System.out.println("Invalid Day "); } } Invalid Day Friday Saturday Sunday Invalid Day Friday Friday Saturday Sunday What will be the output...

  • 1. What would be the output of the following lines of code: int num = 2;...

    1. What would be the output of the following lines of code: int num = 2; switch(num){ case 1: cout << "1"; case 2: cout << "2"; case 3: cout << "3"; case 4: cout << "4"; } 2. What would be the output of the following code: char op = '*'; switch(op){ case '+': cout << "Addition"; break; case '-': cout << "Subtraction"; break; case '/': cout << "Division"; break; default: cout << "Invalid"; } 3. What would be...

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