15 Python Programs by Abdul Rafay
15 Python Programs by Abdul Rafay
Presented to:
Shahzad Sir
Made by:
ABDUL RAFAY XIC
ACKNOWLEDGEMENT
I would like to express my special thanks
to my teacher MR. SHAHZAD ALI who
gave me such an opportunity to complete
this practical file. He has been a source of
inspiration and helped me to understand
and remember important details of
practical file. My practical file has been
success only because of his guidance.
CERTIFICATE
This is certify this Informatics Practices
PRACTICAL FILE is prepared by
___________
ABDUL RAFAY for the partial fulfilment
Term end Examination 2023-24).
Output:
Enter first number: 5
Enter second number: 7
Sum: 12
rows = 5
for i in range (1, rows + 1):
for j in range (1, i + 1):
print(j, end=" ")
print()
Output : 1
12
123
1234
12345
rows = 5
for i in range(1, rows + 1):
for j in range(1, i + 1):
print("*", end=" ")
print()
Output : *
**
***
****
*****
numbers = [1, 2, 3, 4, 5]
Sum of elements = sum(numbers)
print("Sum of elements:", Sum of elements)
Output :
Sum of elements: 15
# Creating a dictionary
student = {'name': 'John', 'age': 20, 'grade': 'A'}
# Accessing values
print("Name:", student['name'])
print("Age:", student['age'])
print("Grade:", student['grade'])
Output : Name: John
Age: 20
Grade: A