Python Programs for Beginners – Part2

Basic Python Programs for Beginners – Part 2

# program to display employee salary information
name=input(“Enter Name:”)
dept=input(“Enter Department:”)
basic=int(input(“Enter Basic salary:”))
bonus=basic*(5/100)
pf=basic*(10/100)
net=basic+bonus-pf
print(“Employee Details”)
print(“—————————–“)
print(“Name=”, name)
print(“Basic=”, basic)
print(“Bonus=”, bonus)
print(“Provident Fund=”, pf)
print(“Net salary=”, net)

OUTPUT:

Enter Name:Ganesh
Enter Department:Finance
Enter Basic salary:25000
Employee Details
—————————–
Name= Ganesh
Basic= 25000
Bonus= 1250.0
Provident Fund= 2500.0
Net salary= 23750.0

# Program to display Marks information
name=input(“Enter Student Name:”)
p=int(input(“Enter Physics Marks:”))
c=int(input(“Enter Chemistry Marks:”))
m=int(input(“Enter Math Marks:”))
b=int(input(“Enter Biology Marks:”))
tot=p+c+m+b
avg=float(tot)/4;

print(“\tStudent Name=”,name)
print(“\tPhysic Marks=”,p)
print(“\tChemistry Marks=”,c)
print(“\tMath Marks=”,m)
print(“\tBiology Marks=”,b)
print(“\t=============”)
print(“\tTotal Marks=”,tot)
print(“\tAverage Marks=”,avg)

if ((avg>80) and (avg<=100)):
print(“\tResult is Distinction”)
elif((avg>60) and (avg<80)):
print(“\tFirst Class”)
elif((avg>50) and (avg<60)):
print(“\tSecond Class”)
elif((avg>35) and (avg<50)):
print(“\tSecond Class”)
else:
print(“\tFail .. Try again”)

OUTPUT

Enter Student Name:Sharan
Enter Physics Marks:59
Enter Chemistry Marks:95
Enter Math Marks:86
Enter Biology Marks:65
Student Name= Sharan
Physic Marks= 59
Chemistry Marks= 95
Math Marks= 86
Biology Marks= 65
=============
Total Marks= 305
Average Marks= 76.25
First Class

# Looping Program using Python : prints 0-10 numbers
for x in range(11):
print(x)

OUTPUT:

0
1
2
3
4
5
6
7
8
9
10

# Looping Program using Python: prints 5-10 numbers
for y in range(5,11):
print(y)

OUTPUT: 

5
6
7
8
9
10

# Looping Program using Python : prints 1-10 numbers with 2 increments
for z in range(1,11,2):
print(z)

OUTPUT:

1
3
5
7
9

# program to print table of entered number
num=int(input(“Enter Number:”))
for x in range(1,11):
print(num*x)
else:
print(“Printed Finally!!!”)

OUTPUT:

Enter Number:5
5
10
15
20
25
30
35
40
45
50
Printed Finally!!!

# Program to use Nested loop in python
for x in range(1,11):
for y in range(1,11):
print(x*y, end=”\t”)
print()

OUTPUT:

Click here for Python Programs for Beginners – Part1

Share
Share
Scroll to Top