Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Python codes with output

The document outlines a series of practical programming exercises in Python, covering basic concepts such as printing information, conditional statements, arithmetic operations, and loops. Each practical includes a task description, learning outcomes, and sample code. The exercises aim to enhance coding skills and understanding of fundamental programming principles.

Uploaded by

soulsociety6954
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python codes with output

The document outlines a series of practical programming exercises in Python, covering basic concepts such as printing information, conditional statements, arithmetic operations, and loops. Each practical includes a task description, learning outcomes, and sample code. The exercises aim to enhance coding skills and understanding of fundamental programming principles.

Uploaded by

soulsociety6954
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

PRACTICALS

FOR
BASIC PROGRAMMING IN PYTHON

SNO PRACTICAL SIGNATURE

1 To print personal information like Name, Father’s Name,


Class, hobbies etc using print() function.

2 To check whether the user is eligible for voting using if-else


condition.
3 To find the sum of three numbers.

4 To convert Bytes into Kilobytes.

5 To find square of any number entered through input()


function.

6 To calculate Simple Interest, where P=35000,T=4 yrs,


R=6.5%

7 Write a Program to check whether the given pincode/


password is correct or not.

8 To calculate travel charges as per the customer category.

9 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’

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)

12 To print the following pattern with the help of for loop.


* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
PRACTICAL -1

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)

#even number program with for loop


for x in range(2,10,2):
print(x)

# even number program with while loop

x=0
while x<=10:
if x%2==0:
print(x)
x=x+1

# odd number program with while loop

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-

You might also like