Question

Canvas 10 pts Question 26 Assume a variable score that has already been initialized, write one if/elif/else statement that wi

python

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

Answer:

First of all, we should know the definition of algorithm -

Algorithm: An algorithm is a set of defined rules which is written to do a specific task.

Algorithm for given problem statement is written below:

step 1: start
step 2: initialize score
step 3: if score = 0 then
print 'Test was not taken'
step 4: else if score < 0 or score > 100 then
print 'Error:Score is not valid'
step 5: else
print 'Test score is:', score
step 6: end


Python code for give problem statement is given below:

score = 73 #score variable value is initialized by the user.
if score == 0 : #checking if score is equal to 0 or not
print ('Test was not taken')
elif (score < 0 or score > 100): #checking if score value is out of range or not
print ('Error: Score is not valid')
else: #if score value is neither 0 nor out of range the print it's value
print ('Test score is:', score)

Given below is the screenshot of the python code along with its output for all the three conditions:


1. When the score is 0
<screenshot 1>
2. When the score is out of range
<screenshot 2>
3. When the score is in the range.

<screenshot 3>

  main.py Run Shell 1 Test was not taken >>> #score variable value is initialized by the user. 2 score = 0 3 #checking if score  

main.py Run Shell 1 Error: Score is not valid >>| #score variable value is initialized by the user. 2 score = 145 3 #checking

main.py Run Shell Test score is: 73 1 #score variable value is initialized by the user. 2 score = 73 3 #checking if score is

HOPE YOU GOT IT!!

Add a comment
Know the answer?
Add Answer to:
python Canvas 10 pts Question 26 Assume a variable score that has already been initialized, write...
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
  • python programming X Canvas 4 → XCO Question 26 10 pts (SHORT ANSWER) Define a function...

    python programming X Canvas 4 → XCO Question 26 10 pts (SHORT ANSWER) Define a function named find_even_odd that has 1 parameter: num. When the function is called, it should use an if/else statement to determine whether the variable num is an even or odd number and display appropriate message as follows: • If the value in num is an even number, the progr will output the message: "XX is an EVEN number", where XX is the value in the...

  • python programming Canvas → XCO Question 28 10 pts (SHORT ANSWER) Write Python statements to do...

    python programming Canvas → XCO Question 28 10 pts (SHORT ANSWER) Write Python statements to do the following (number your answers); 1. Create a constant PI and assign it 3.1415 2. Calculate the volume of the cone and store it in the variable volume . Given the formula to compute the volume of a cone is: II-> (5) • Assume: the variables r and h are already assigned with values 3. Display the computed volume on the console as follows...

  • anslate Assume that number is an int variable that has already been initialized. Write a statement...

    anslate Assume that number is an int variable that has already been initialized. Write a statement that prints out the value of number in a field of 10 positions (right-justified within that field). Hint: Assume #include <iomanip> is included in the program. В І ЦА HTML Editor I 5 7 7 7 7 x x = = 1:12pt Paragraf O words 18 ctv A

  • Given an int variable n that has already been declared, write some code in C that repeatedly reads a value into n until at last a number between 1 and 10...

    Given an int variable n that has already been declared, write some code in C that repeatedly reads a value into n until at last a number between 1 and 10 (inclusive) has been entered.

  • python programming → X CIO CIUSCUTETTE TUVOITTEESITTEETTICLE Question 30 10 pts (SHORT ANSWER) Assume the following:...

    python programming → X CIO CIUSCUTETTE TUVOITTEESITTEETTICLE Question 30 10 pts (SHORT ANSWER) Assume the following: • temps is a list of SIZE elements that has been assigned values • limit is a variable that has been assigned a value Write code to do the following: • Create a variable named count to keep track of the number of elements in temps list that are lesser than limit Using a loop, count the number of elements in the temps list...

  • Python GPA calculator: Assume the user has a bunch of courses they took, and need to...

    Python GPA calculator: Assume the user has a bunch of courses they took, and need to calculate the overall GPA. We will need to get the grade and number of units for each course. It is not ideal to ask how many courses they took, as they have to manually count their courses. Programming is about automation and not manual work. We will create a textual menu that shows 3 choices. 1. Input class grade and number of units. 2....

  • Please help as it is very important task for me please write in Python code and...

    Please help as it is very important task for me please write in Python code and divide this into function and write comments for it 1. Ask the player’s name and welcome them to the game using their name. 2. Ask the player what is par for this game (number between 3-5 inclusive) 3. Ask the player what the distance to the hole for this game is (whole number between 195 and 250 inclusive) 4. Show the game menu: (I)nstructions...

  • Please Write in C++ (10-30) @ 11:55pm 1.9 HW7 This homework assignment gives you the opportunity...

    Please Write in C++ (10-30) @ 11:55pm 1.9 HW7 This homework assignment gives you the opportunity to practice functions, functions that call other functions, reference variables, logical statements (what is meant by logical statement is a statement such as if, if/else if, switch), and input validation, HW7 (Graded out of 100) A talent competition has 5 judges, each of whom awards a score between 0 and 10 for each performer. Fractional scores, such as 8.3, are allowed. A performer's final...

  • Can anyone help me with my C hw? Exercise 3 You will write a new program...

    Can anyone help me with my C hw? Exercise 3 You will write a new program that combines dynamically allocating an array and saving that array to a file. These are the tasks your program must perform Open an output file named "data.txt" and prepare it for writing in text mode o If the file handle is NULL, quit the program o By default, it is created and stored in the same directory as your source code file Prompt the...

  • (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the...

    (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...

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