Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab, you add a loop and the statements that make up the loop body to a Python program. When completed, the program should

In this lab, you add a loop and the statements that make up the loop body to a Python program. When completed, the program should calculate two totals: the number of left-handed people and the number of right-handed people in your class. Your loop should execute until the user enters the character X instead of a Lfor left-handed or a R for right-handed.

The inputs for this program are as follows: R, R, R, L, L, L, R, L, R, R, L, X.

Note that variables have been assigned for you, and the input and output statements have been written for you.

Instructions

Make sure the file LeftOrRight.py is selected and open.

Write a loop and a loop body that allows you to calculate a total of left-handed and a total of right-handed people in your class.

Execute the program using the "Run Code" bottom at the bottom of the screen. Input the data listed above and verify that the output is correct.

CODE GIVEN:

""" LeftOrRight.py - This program calculates the total number of left-handed and right-handed students in a class. Input: L for left-handed; R for right handed; X to quit. Output: Prints the number of left-handed students and the number of right-handed students. """

rightTotal = 0 # Number of right-handed students. leftTotal = 0 # Number of left-handed students.

leftOrRight = input("Enter an L if you are left-handed,a R if you are right-handed or X to quit.")

# Write your loop here.

# Output number of left or right-handed students. print("Number of left-handed students: " + str(leftTotal)) print("Number of right-handed students: " + str(rightTotal))

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

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

Name and briefly describe the five product mix pricing decisions.

Answered: 1 week ago