2021 Bme 104
2021 Bme 104
2021 Bme 104
(NAROWAL CAMPUS)
(UET)
Course Title:
Introduction to Computer Programming for Data Science
Course Code:
CS-103
Submitted By:
Submitted To:
Ma’am Fatima Shehzadi
Assignment No:
#1
Introduction to Computer
Programming for Data Science
CS-103
Assignment #01 (CLO Mapping -> CLO 1)
Objective:
Theoretical experience over the ground knowledge.
Practical experience over the control structures.
In each of the Programming problems, you are required to
draw the flow chart
Write it as Python code.
Programming Problem# 1:
Design a solution of problem to check leap year.
Leap years are perfectly divisible by 4.00. For example: 2012, 2004, 1968 etc. are leap year but, 1971, 2006
etc. are not leap year. Similarly, 1200, 1600, 2000, 2400 are leap years but, 1700, 1800, 1900 etc. are not.
In this program, user is asked to enter a year and this program checks whether the year entered by user is
leap year or not.
(you are encouraged to use Nested if else)
Code for Problem1:
start
No
End
Programming Problem# 2:
Design a program which takes CGP (cumulative grade point) of a person and allocates room in hostel after
first year. (We have 8 hostels for consideration after first year)
Person having CGP above 2 will only be considered for single room in Hostel (1…7).
Person having CGP lower than 2 would be allotted seat in double room (Hostel 8)
CGP lower than 2.5 would be considered for having single room on 2nd floor.
Person having CGP above 2.5, 3 would be allotted as 1st floor and ground floor room
respectively.
(Use the sentinel controlled repetition to allocate the hostel seats)
while True:
cgp = float(input("Enter your CGP: "))
if cgp > 3:
print("You have been allotted a single room on the ground floor.")
elif cgp > 2.5:
print("You have been allotted a single room on the first floor.")
elif cgp > 2:
print("you have been allotted a single room in hostel 1 to 7 randomly")
elif cgp > 0:
print("You have been allotted a double room in Hostel 8.")
else:
print("Invalid CGP. Please enter a valid CGP.")
choice = input("Do you want to continue? (Y/N): ")
if choice.lower() != "y":
break
Start
single room on
Yes
cgp > 3
the ground
floor
No
No
Yes
single room in cgp >
hostel 1 to 7 2>2.5
randomly
No
Yes
cgp > 0>2 double room in
Hostel 8
End
Programming Problem# 3:
Design a Python program which takes size of diamond and display hollow diamond using nested while loop
and asterisk character.
Output should be look like below
User can enter its desired size of diamond either even or odd
For Example
If user enters size of 3
3 lines of will be formed above middle and 3 lines will be formed below middle
line.
Code for Problem3:
Start
Size of diamond
Initialize Row
Row
size
Yes
Yes
Row
size
No
End
Programming Problem# 4:
A palindrome is a number or a text phrase that reads the same backwards as forwards. For example, each
of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that
reads in a five-digit integer and determines whether it is a palindrome or not using loops.
Code for Problem3:
Start
Enter 5 digit
number
Check the
Yes No
number is a
palindrome or
not
End