You notice that users are entering upper case letters, complete responses, and other hard to deal with input. To help them out, you will extend your program so that if the user enters something other than 'a', 'b', or 'c' the program will immediately respond with
Invalid input! Enter a, b, or c next time.
Your program will go on to mark them incorrect.
This behavior will apply to the multiple choice questions only. Below is how your output should look for the first question:
ART AND LITERATURE: Who painted Starry Night? a. Vincent van Gogh b. Michelangelo c. Leonardo da Vinci Enter your choice:d Invalid input! Enter a, b, or c next time. The correct answer was a
Save this and submit it
----------------
result = 0
print('ART AND LITERATURE: Who painted Starry Night?')
print('a. Vincent van Gogh')
print('b. Michelangelo')
print('c. Leonardo da Vinci')
answer = input('Enter your choice:')
if answer == 'a':
print('Correct!')
result = result + 1
else:
print ('The correct answer was a')
CODE:
result = 0
print('ART AND LITERATURE: Who painted Starry Night?')
print('a. Vincent van Gogh')
print('b. Michelangelo')
print('c. Leonardo da Vinci')
while True: #Using an infinite loop for asking user until a valid input
answer = input('Enter your choice:')
#If it is a valid input in both upper and lower cases then we are verfying the input
if(answer.lower() == 'a' or answer.lower() == 'b' or answer.lower() == 'c'):
if answer.lower() == 'a': #If it is a valid input and correct answer
print('Correct!')
result = result + 1
else: #If it is a valid input and wrong answer, i.e in this case
print ('The correct answer was a')
break
#If it is not valid reponse, we are asking user to again enter input
else:
print('Invalid input! Enter a, b, or c next time.')
CODE SCREENSHOT:

OUTPUT SCREENSHOT:

Hope this will help you. Let me know, still if you have any queries..
Please rate the answer if you like it.
You notice that users are entering upper case letters, complete responses, and other hard to deal...
Please I need help with this c++ code. please show all
steps , write comments and show sample runs. Thank you.
1. The Federal Bureau of Investigation (FBI) has recently changed its Universal Control Numbers (UCN) for identifying individuals who are in the FBI's fingerprint database to an eight-digit base 27 value with a ninth check digit. The digits used are: 0123456789ACDE FHJKLMNPRTVWX Some letters are not used because of possible confusion with other digits: B->8, G->C, I- >1, 0->0,...
Programming Assignment #2 EE 2372 MAKE SURE TO FOLLOW INSTRUCTIONS CAREFULLY, IF YOU HAVE ANY DOUBTS PLEASE EMAIL ME! This programming assignment will just be a small extension to programming assignment 1. In the first assignment each of the functions could only take a predefined number of inputs. This time the objective is to be able to complete these functions with any amount of inputs. The user will pass arguments through the command line (this means you will have to...
C PROGRAMMING Introduction In this part, you will solve a problem described in English. Although you may discuss ideas with your classmates, etc., everyone must write and submit their own version of the program. Do NOT use anyone else’s code, as this will result in a zero for you and the other person! Shipping Calculator Speedy Shipping Company will ship your package based on the weight and how far you are sending the package, which can be anywhere in the...
You will be writing a simple Java program that implements an ancient form of encryption known as a substitution cipher or a Caesar cipher (after Julius Caesar, who reportedly used it to send messages to his armies) or a shift cipher. In a Caesar cipher, the letters in a message are replaced by the letters of a "shifted" alphabet. So for example if we had a shift of 3 we might have the following replacements: Original alphabet: A B C...
Need code written for a java eclipse program that will follow
the skeleton code.
Exams and assignments are weighted
You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...
CS 1102 Unit 5 – Programming Assignment In this assignment, you will again modify your Quiz program from the previous assignment. You will create an abstract class called "Question", modify "MultipleChoiceQuestion" to inherit from it, and add a new subclass of "Question" called "TrueFalseQuestion". This assignment will again involve cutting and pasting from existing classes. Because you are learning new features each week, you are retroactively applying those new features. In a typical programming project, you would start with the...
CS 1102 Unit 5 – Programming Assignment In this assignment, you will again modify your Quiz program from the previous assignment. You will create an abstract class called "Question", modify "MultipleChoiceQuestion" to inherit from it, and add a new subclass of "Question" called "TrueFalseQuestion". This assignment will again involve cutting and pasting from existing classes. Because you are learning new features each week, you are retroactively applying those new features. In a typical programming project, you would start with the...
Project Objectives: To develop ability to write void and value returning methods and to call them -- Introduction: Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct order. This also allows for efficiencies, since the method can...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...