1 / 11

# Computer Science 111 - PowerPoint PPT Presentation

Computer Science 111. Fundamentals of Programming I Developing and Testing Programs. Start with a User Request. Write a program that converts pounds to kilograms. Determine the Inputs and Outputs. The input will be the number of pounds, as an integer or floating-point number

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Computer Science 111' - camdyn

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Computer Science 111

Fundamentals of Programming I

Developing and Testing Programs

Write a program that converts pounds to kilograms.

• The input will be the number of pounds, as an integer or floating-point number

• The output will be

• a prompt for the number of pounds

• A label, and the number of kilograms as a floating-point number

Enter the number of pounds: 330

The number of kilograms is 150.0

There are 2.2 pounds in a kilogram

Prompt the user for the number of pounds

Input pounds

Set kilograms to pounds / 2.2

Output the number of kilograms

Code as the convert Script

"""

File: convert.py

This program converts pounds to kilograms.

Input: the number of pounds, as an integer or float.

Output: the number of kilograms, as a float, suitably

labeled.

"""

convert.py

Code as the convert Script

pounds = float(input('Enter the number of pounds: '))

kilograms = pounds / 2.2

print('The number of kilograms is', kilograms)

convert.py

The Python shell

Test the program in IDLE first!

pounds = float(input('Enter the number of pounds: '))

kilograms = pounds / 2.2

print('The number of kilograms is', kilograms)

convert.py

The Python shell

pounds = float(input('Enter the number of pounds: '))

kilograms = pounds / 2.2

print('The number of kilograms is', kilograms)

convert.py

The terminal

Start Chapter 3