Subhan
Subhan
Computer Programing
lab(1009)
Lab Title
Objective:
Tools/Software Requirement:
Python 3 Anaconda
Theoretical Explanation:
1. if Statement:
The if statement is used when you want to make a decision. It checks if a certain condition is true
or not. If the condition is true, the block of code inside the if statement gets executed.
2. if-else Statement:
An if-else statement is like a choice between two options. If the condition is true, the if part is
executed; if it’s false, the else part is executed.
3. Nested if-else:
A nested if-else is when you place an if-else statement inside another if or else statement. It’s
useful when you want to check multiple conditions step by step.
Lab Tasks:
Task #1:
Your university registration number shows the year of your intake. For example, in the
enrolment 201918 the first two numbers show your intake i.e. 20. Write a python
program which takes enrolment as an input and finds in which year you are enrolled ?
Code :
print('subhan afzal:-:')
Input:
Output:
Flow chart:
Start
Input num
Display num[3:5]
End
Task #2:
Write a python program to find the largest number among the three user input numbers.
Code:
Output:
Flow chart:
Start
Input a,b,c
Task #3:
Code:
if number%3==0:
print('\nits an odd number')
else:
Input:
Output:
Flow chart:
Start
Post lab task: -
Task 1:
Input:
Output:
I =1
Range
Display
(1,n+
i
1)
End
Task #2:
Input:
Output:
Flow-chart
end Print c
Task #3:
Input:
Output:
Flow-chart:
Start
Input n
Sum_even=0
For i
Range(1,n
+1)
End Even_number=2*i
Sum_even=sumn+even_numb
Task #4: er
Input:
Output:
Flow-chart:
Start
Input n
For I
Range(n)
Stars=”*”*(2*(i)-1)
Task #5:
Input:
Output:
Flow-chart: Start
Input s
If
s==s[::-
1]
Its not a
plaindrome It’s a plaindrome
End
Task #6:
Input :
Output: