Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

PRESTON UNIVERSITY KOHAT, ISLAMABAD CAMPUS

DEPARTMENT OF COMPUTER SCIENCES

LAB SHEET # 1

PROGRAMMING FUNDAMENTALS LAB REPORT


SUBMITTED BY

REGN NO: 1442-320007


NAME: M WAQAS KHALIL

SUBMITTED TO

DEPARTMENT OF COMPUTER SCIENCE

Marks & Signature


Lab Date:
Submission Date: 09 Feb 2021
[2]
Lab Sheet # 1 Programming Fundamentals

Title:
1. Personal Information:
Write a program that displays the following information:
• Your name
• Your address, with city, state, and ZIP
• Your telephone number
• Your college major
Algorithm:
a. Start
b. Ask user to enter personal info
c. Save the info into variables
d. Print the info
e. Stop
Flowchart:

Start

read name, address, tel and major

Display the name, address, tel and major

End

Code:
name = input('What is your name? ')
address =input('Your address with city, state and ZIP ? ')
telephone = int(input('Your Telephone number ? '))
college = input('Your college major ? ')
print('Here is the data you entered:')
print('Name:', name)
print('address:', address)
print('telephone:', telephone)
print('college:', college)
Output (Compilation, Debugging & Testing):
What is your name? M Waqas Khalil
Your address with city, state and ZIP ? Rawalpindi, Punjab 46000
Your Telephone number ? 03123456789
Your college major ? Computer Science
Here is the data you entered:
Name: M Waqas Khalil
address: Rawalpindi, Punjab 46000
telephone: 3123456789
college: Computer Science

Regn No.1442-320007 Muhammad Waqas Khalil MCS (Eve), Preston University Islamabad
[3]
Lab Sheet # 1 Programming Fundamentals

***END***
Title:
2. Sales Prediction
A company has determined that its annual profit is typically 23 percent of total sales. Write
a program that asks the user to enter the projected amount of total sales, then displays the
profit that will be made from that amount. Hint: Use the value 0.23 to represent 23
percent.
Algorithm:
a. Start
b. Initialize variable percentage
c. Ask user to enter the projected sale and save in variable
d. Conclude the profit by the formula
e. Display the value of the profit
f. Stop

Flowchart:

Start

percentage = 0.23

read proj amount

profit = projAmount * percentage

Display Profit

End

Code:
percentage = 0.23
projAmount=float(input("Enter the projected amount of total sales:"))
profit = projAmount * percentage
print(‘Profit : ’,profit)
Output (Compilation, Debugging & Testing):
Enter the projected amount of total sales:1000
Profit : 230.0

***END***

Regn No.1442-320007 Muhammad Waqas Khalil MCS (Eve), Preston University Islamabad
[4]
Lab Sheet # 1 Programming Fundamentals

Regn No.1442-320007 Muhammad Waqas Khalil MCS (Eve), Preston University Islamabad
[5]
Lab Sheet # 1 Programming Fundamentals

Title:
3. Pounds to Kilograms
One pound is equivalent to 0.454 kilograms. Write a program that asks the user to enter the
mass of an object in pounds and then calculates and displays the mass of the object in
kilograms.
Algorithm:
a. Start
b. Ask used to enter the mass in pounds and save it in a variable
c. Using formula covert pounds into kgs
d. Print the values in kgs
e. Stop

Flowchart:

Start

read pounds

kg = pounds * .454

Display Kgs

End

Code:
pounds = float(input('Enter mass of an object in pounds: '))
kg = pounds * .454 # One pound is equivalent to 0.454 kilograms
print('Object in kgs =', kg)
Output (Compilation, Debugging & Testing):
Enter mass of an object in pounds: 1000
Object in kgs = 454.0

***END***

Regn No.1442-320007 Muhammad Waqas Khalil MCS (Eve), Preston University Islamabad
[6]
Lab Sheet # 1 Programming Fundamentals

Title:
4. Total Purchase
A customer in a store is purchasing five items. Write a program that asks for the price of
each item, then displays the subtotal of the sale, the amount of sales tax, and the total.
Assume the sales tax is 7 percent.
Algorithm:
a. Start
b. Initialize the salestax value
c. Ask user to enter the values of 5 items
d. Subtotal the values
e. Calculate the sales tax
f. Calculate the total amount including sale tax
g. Print the total amount
h. Stop

Flowchart:

Start

salestax = 0.07

read item1, item2, item3, item4 & item5

subtotal =item1+item2+item3+item4+item5

amountofsalestax = subtotal * salestax

Total = subtotal + amountofsalestax

Display Total

End

Code:
salestax = 0.07
item1=float(input("Enter the price of first item:"))
item2=float(input("Enter the price of second item:"))
item3=float(input("Enter the price of third item:"))

Regn No.1442-320007 Muhammad Waqas Khalil MCS (Eve), Preston University Islamabad
[7]
Lab Sheet # 1 Programming Fundamentals

item4=float(input("Enter the price of four item:"))


item5=float(input("Enter the price of five item:"))
subtotal =item1+item2+item3+item4+item5
print("Subtotal:",subtotal)
amountofsalestax = subtotal * salestax
print("Sales tax:",amountofsalestax)
Total = subtotal + amountofsalestax
print("Total:",Total)
Output (Compilation, Debugging & Testing):
Enter the price of first item:495
Enter the price of second item:2999
Enter the price of third item:1550
Enter the price of four item:799
Enter the price of five item:70
Subtotal: 5913.0
Sales tax: 413.91
Total: 6326.91

***END***

Regn No.1442-320007 Muhammad Waqas Khalil MCS (Eve), Preston University Islamabad
[8]
Lab Sheet # 1 Programming Fundamentals

Title:
5. Distance Traveled
Assuming there are no accidents or delays, the distance that a car travels down the
interstate can be calculated with the following formula:
Distance = Speed x Time
A car is traveling at 70 miles per hour. Write a program that displays the following:
• The distance the car will travel in 6 hours
• The distance the car will travel in 10 hours
• The distance the car will travel in 15 hours
Algorithm:
a. Start
b. Calculated the 3 x distances travelled by car at different times
c. Saved them in 3 x variables
d. Display the distances
e. Stop

Flowchart:

Start

distance1 = 70 * 6
distance2 = 70 * 10
distance3 = 70 * 15

Display distance1, distance2 & distance3

End

Code:
distance1 = 70 * 6
distance2 = 70 * 10
distance3 = 70 * 15
print('The distance the car will travel in 6 hours :', distance1,'km/h')
print('The distance the car will travel in 10 hours :', distance2,'km/h')
print('The distance the car will travel in 15 hours :', distance3,'km/h')
Output (Compilation, Debugging & Testing):
The distance the car will travel in 6 hours : 420 km/h
The distance the car will travel in 10 hours : 700 km/h
The distance the car will travel in 15 hours : 1050 km/h
***END***

Regn No.1442-320007 Muhammad Waqas Khalil MCS (Eve), Preston University Islamabad

You might also like