Sample Practical File XI CS
Sample Practical File XI CS
PUBLIC SCHOOL
(ISO 9001:2015)
Session-2021-22
INDEX
5 Write a python program to input three numbers and display the largest /
smallest number.
6 Write a python program to input two numbers and display the larger /
smaller number.
7 Write a python program that demonstrate number guessing game using if-
elif-else statement
8 Program to print the table of any n natural number
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Program No : 1. Program to print the sum of n natural numbers.
Code:
n=int(input("Enter Number upto which you want to sum : ")) # asks for input
i=1 # suppose if n=3. This is means we have to add numbers between 1 to 3
sum=0 # zero added to any number, doesn't changes its value
while i<=n: # while loop followed until the value of i is less than or equals to n
sum=sum+i
i=i+1
print("Sum = ", sum) # produces output
Output :