Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The assignment is to get an integer from input, and output that integer squared, ending with newline. (Note: This assignment is configured to have students

The assignment is to get an integer from input, and output that integer squared, ending with newline. (Note: This assignment is configured to have students programming directly in the zyBook. Instructors may instead require students to upload a file). Below is a program that's been nearly completed for you.

Click "Run program". The output is wrong. Sometimes a program lacking input will produce wrong output (as in this case), or no output. Remember to always pre-enter needed input.

  1. Type 2 in the input box, then click "Run program", and note the output is 4.
  2. Type 3 in the input box instead, run, and note the output is 6.

When students are done developing their program, they can submit the program for automated grading.

  1. Click the "Submit mode" tab
  2. Click "Submit for grading".
  3. The first test case failed (as did all test cases, but focus on the first test case first). The highlighted arrow symbol means an ending newline was expected but is missing from your program's output.

Matching output exactly, even whitespace, is often required. Change the program to output an ending newline.

  1. Click on "Develop mode", and change the output statement to output a newline: print(userNumSquared). Type 2 in the input box and run.
  2. Click on "Submit mode", click "Submit for grading", and observe that now the first test case passes and 1 point was earned.

The last two test cases failed, due to a bug, yielding only 1 of 3 possible points. Fix that bug.

  1. Click on "Develop mode", change the program to use * rather than +, and try running with input 2 (output is 4) and 3 (output is now 9, not 6 as before).
  2. Click on "Submit mode" again, and click "Submit for grading". Observe that all test cases are passed, and you've earned 3 of 3 points.

userNum = int(input()) userNumSquared = userNum + userNum # Bug here; fix it when instructed print(userNumSquared, end=' ') # Output formatting issue here; fix it when instructed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Vector Mechanics for Engineers Statics and Dynamics

Authors: Ferdinand Beer, E. Russell Johnston, Jr., Elliot Eisenberg, William Clausen, David Mazurek, Phillip Cornwell

8th Edition

73212229, 978-0073212227

More Books

Students also viewed these Mechanical Engineering questions

Question

LO5.2 Discuss government failure and explain why it happens.

Answered: 1 week ago