Python codes with output
Python codes with output
FOR
BASIC PROGRAMMING IN PYTHON
10 To print odd and even number series using loops (while and
for loops)
11 To calculate average marks of 6 subjects (where maximum
marks are 100 for each subject)
CODE
PRACTICAL -2
CODE
PRACTICAL – 3
Learning Outcome: Arithmetic operations
Objective: Using Int() and Input functions
Task: Write a Program to add three numbers
CODE:
OUTPUT-
PRACTICAL – 4
Learning Outcome: Computational Skills , Logical Skills
Objective: Using Multiplication/Division operations
Task: Write a Program to convert bytes into kilobytes.
CODE:
OUTPUT-
PRACTICAL – 5
Learning Outcome: Coding Skills
Objective: Using Arithmetic Operator(**)
Task: Write a Program to find square of any number entered through input()
function.
CODE:
OUTPUT –
PRACTICAL – 6
Learning Outcome: Coding Skills
Objective: Using Mathematical operations
Task: Write a Program to calculate Simple Interest, where
P=35000,T=4 yrs, R=6.5%
CODE:
p=35000
t=4
r=6.5
SI=(p*r*t)/100
print('Simple Interest for the given Principle is=',SI)
output-
PRACTICAL – 7
Learning Outcome: Coding Skills
Objective: Using Mathematical operations
Task: Write a Program to check whether the given
pincode/password is correct or not
CODE:
while(1):
pin='A1B2'
password='15-08-2011'
p=input('Enter pincode:')
pwd=input('Enter password:')
if p==pin and pwd==password:
print('Welcome to device')
else:
print('Wrong Pin or Password ,Sorry')
ch=input('Do u wish to continue')
if ch=='n' or ch=='N' or ch=='No':
break
output-
PRACTICAL -8
CODE
PRACTICAL – 9
Learning Outcome: Decision making using conditional
expressions
Objective: Using if – elif-else
Task: To check the grade of a student.
Data given:
A grade for marks>75
B grade for marks >60
C grade for marks >60
Otherwise display ‘Work Hard’
CODE:
per = float(input("Enter your percentage scored: "))
if per>75:
print(‘You scored A grade')
elif per>60:
print(‘You scored B grade')
elif per>35:
print(‘You scored C grade')
else:
print('Work hard')
output-
PRACTICAL – 10
Learning Outcome: Coding skills
Objective: Iteration expressions
Task: To print odd and even number series using loops (while and
for loops)
CODE:
#odd number program with for loop
for x in range(1,10,2):
print(x)
x=0
while x<=10:
if x%2==0:
print(x)
x=x+1
x=0
while x<=10:
if x%2!=0:
print(x)
x=x+1
output-
Display odd and even number series
PRACTICAL – 11
Learning Outcome: Computational skills
Objective: Using Arithmetic operations
Task: To calculate average marks of 6 subjects (where maximum
marks are 100 for each subject)
CODE:
eng = float(input("Enter your Eng marks : "))
hindi= float(input("Enter your Hindi marks : "))
maths=float(input("Enter your Maths marks : "))
AI=float(input("Enter your AI marks : "))
sci=float(input("Enter your Sci marks : "))
sst=float(input("Enter your Sst marks : "))
Total=eng+hindi+maths+AI+sci+sst
print('Total marks=',Total)
ave=Total/600*100
print('Average=',ave)
output-
PRACTICAL – 12
Learning Outcome: Creative and Logical skills
Objective: Using for loop (Iteration)
Task: To print the following pattern with the help of for loop.
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
CODE:
for x in range(0,5,1):
print('* * * * *')
output-