Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A (4 points) - assignments with simple expressions A1 . Write the following 3 assignments: Write a statement that assigns to a variable named

Part A (4 points) - assignments with simple expressions

A1.

Write the following 3 assignments:

Write a statement that assigns to a variable named throws_per_over the int literal 6

Write a statement that assigns to a variable named overs_per_game the int literal 20

Write a statement that assigns to a variable named throws_so_far the int literal 17

A2.

Write a statement that assigns the str literal " after completing over " to a variable named msg_text. Make certain you include 1 space at the start and end of the string literal.

STUDENTS SHOULD DOWNLOAD THEIR main.py FILE AND SUBMIT TO AUTOLAB Lab 1 TO CHECK THEIR CODE

Part B (4 points) - assignments with compound expressions

THIS CODE MUST BE WRITTEN IN YOUR REPL BELOW THE CODE FROM YOUR PART A

B1.

Write a statement that assigns a variable named addl to the remainder when throws_so_far is divided by throws_per_over (or, as we would normally state this, throws_so_far mod throws_per_over).

B2.

Write an assignment that assigns a variable named overs the result of dividing throws_so_far by throws_per_over using whole-number division (e.g., the division that only returns the whole number amount).

STUDENTS SHOULD DOWNLOAD THEIR main.py FILE AND SUBMIT TO AUTOLAB Lab 1 TO CHECK THEIR CODE

Part C (5 points) - assignments with more involved compound expressions

THIS CODE MUST BE WRITTEN IN YOUR REPL BELOW THE CODE FROM YOUR PART A AND PART B

C1.

Assume that throws_so_far is the number of balls thrown ("bowled") this game, that there are throws_per_over balls thrown each over, and that the game will last overs_per_game overs. Write a statement that assigns a variable named pct_thrown to the percentage of the game's throws that have been made. (Hint: Since the percentage is a number between 0.0 - 1.0, you will want to use true division in this expression)

C2.

Write a statement that assigns a variable named display the concatenation of the value of addl, the value of msg_text, and the value of overs. (Hint: If expression evaluates to a numeric value, then str(expression) evaluates to the string representation of that value)

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_2

Step: 3

blur-text-image_3

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions