0% found this document useful (0 votes)
11 views2 pages

Intro to Programming Lab Guide

The document is a laboratory manual for an introductory programming course. It provides three programming exercises: 1) a program to convert miles to kilometers, 2) identifying valid and invalid Python identifiers, and 3) a program to calculate the area and volume of a cylinder from user input radius and length.

Uploaded by

Sudesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Intro to Programming Lab Guide

The document is a laboratory manual for an introductory programming course. It provides three programming exercises: 1) a program to convert miles to kilometers, 2) identifying valid and invalid Python identifiers, and 3) a program to calculate the area and volume of a cylinder from user input radius and length.

Uploaded by

Sudesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Think Twice

Code Once

The Islamic University of Gaza


Engineering Faculty
Department of Computer Engineering
Fall 2017
LNGG 1003
Khaleel I. Shaheen

Introduction to Computers

Laboratory Manual

Experiment #2 Solution

Elementary Programming, I
Experiment #2: Elementary Programming, I

Homework
1. Write a program that converts miles into kilometers. Use the following algorithm:
a. Use a variable named miles that read value from keyboard.
b. Multiply miles by 1.609 and assign it to a variable named kilometers.
c. Print the value of kilometers.

miles = input("Enter miles: ")


kilometers = miles * 1.609
print(str(miles) + " miles equals " + str(kilometers)
+ " kilometers")

2. Classify the following identifiers as either valid or invalid Python identifier:


Valid is blue. Invalid is red.

basem $a if 2k my app
Test $5 x +9 _a
x+y #44 width my_app _
A# myApp If my-app _5

3. Write a program that reads in the radius and length of a cylinder and computes the
area and volume. Here is a sample output:
Enter the radius and length of a cylinder: 7.5, 15
Area is 176.7144
Volume is 2650.7166

radius, length = input("Enter the radius and length of a


cylinder: ")

area = 2 * radius * radius * 3.14159 + 2 * 3.14159 * radius * length


volume = radius * radius * 3.14159 * length

print("The area is " + str(area))


print("The volume of the cylinder is " + str(volume))

You might also like