REAL TIME PROJECTS IN PYTHON
Python Project :
1.Program for showing details of the students[above75%] :
- Get input(Name, age, Percentage.....) from user and update to the list(Student_details) and print the details if only the percentage is higher than 75.
Program :
details = []
total_no_of_students = int(input("Enter total no of students : "))
for i in range(total_no_of_students):
name,age,percentage = input('Enter your name,age,percentage seperated by spaces : ').split()
details.append(name)
details.append(age)
details.append(percentage)
print('Students details : ',details)
count = 1
j = 0
while(j<=len(details)):
if((count%3==0)):
if(int(details[j])>=75):
print('Name of the student : ',details[count-3])
print('Age of the student : ', details[count-2])
print('Percentage of the student : ', details[count-1])
count += 1
j += 1
Output :
Enter total no of students : 3
Enter your name,age,percentage seperated by spaces : Elon 21 90
Enter your name,age,percentage seperated by spaces : Mark 22 89
Enter your name,age,percentage seperated by spaces : Jeff 25 74
Students details : ['Elon', '21', '90', 'Mark', '22', '89', 'Jeff', '25', '74']
Name of the student : Elon
Age of the student : 21
Percentage of the student : 90
Name of the student : Mark
Age of the student : 22
Percentage of the student : 89
2.Program for guess the number :
Program :
import random
mind = random.randrange(1,50)
guess = int(input('Enter your guess : '))
while(True): # run loop again and again until find the correct number
if(guess==mind):
print('You guessed it')
break # breaks the loop after found the correct number
elif(guess>mind):
print('Your guess is high')
guess = int(input('Enter your guess : '))
elif(guess<mind):
print('Your guess is low')
guess = int(input('Enter your guess : '))
Output :
Enter your guess : 25
Your guess is high
Enter your guess : 12
Your guess is low
Enter your guess : 18
Your guess is low
Enter your guess : 22
Your guess is low
Enter your guess : 23
Your guess is low
Enter your guess : 24
You guessed it
3.Basic Calculator :
Program :
to_continue = 'Y'
while to_continue == 'Y':
num1 = float(input('Enter the first number : '))
operator = input('Enter the operator(+,-,*,/,**) : ')
num2 = float(input('Enter the second number : '))
if operator == '+':
answer = num1 + num2
print(num1,operator,num2,' : ',answer)
elif operator == '-':
answer = num1 - num2
print(num1,operator,num2,' : ',answer)
elif operator == '*':
answer = num1 * num2
print(num1,operator,num2,' : ',answer)
elif operator == '/':
answer = num1 / num2
print(num1,operator,num2,' : ',answer)
elif operator == '**':
answer = num1 ** num2
print(num1,operator,num2,' : ',answer)
to_continue = input('Enter "Y" to continue or "N" to quit : ').upper()
if to_continue == 'N':
print('Thank you')
Output :
Enter the first number : 20
Enter the operator(+,-,*,/,**) : +
Enter the second number : 10
20.0 + 10.0 : 30.0
Enter "Y" to continue or "N" to quit : y
Enter the first number : 5
Enter the operator(+,-,*,/,**) : **
Enter the second number : 2
5.0 ** 2.0 : 25.0
Enter "Y" to continue or "N" to quit : n
Thank you
4.Stone,Paper,Scissor game :
Program :
import random
choices = ['stone','paper','scissor']
to_continue = 'Y'
while to_continue == 'Y':
computer = random.randint(0, 2)
computer = choices[computer]
print(choices)
player = input('Enter your choice : ')
print(computer)
if computer == player :
print('The game ended up with Tie')
elif computer == 'stone' :
if player == 'paper' :
print('The computer won the match')
elif player == 'scissor':
print('The computer won the match')
elif computer == 'paper' :
if player == 'stone' :
print('The player won the match')
elif player == 'scissor':
print('The player won the match')
elif computer == 'scissor' :
if player == 'stone':
print('The player won the match')
elif player == 'paper':
print('The computer won the match')
to_continue = input('Enter "Y" to continue or "N" to quit : ').upper()
if to_continue == 'N':
print('''Bye Bye\nCome again soon!!!!!!!!!!!!''')
Output :
['stone', 'paper', 'scissor']
Enter your choice : stone
stone
The game ended up with Tie
Enter "Y" to continue or "N" to quit : y
['stone', 'paper', 'scissor']
Enter your choice : paper
scissor
The computer won the match
Enter "Y" to continue or "N" to quit : y
['stone', 'paper', 'scissor']
Enter your choice : scissor
scissor
The game ended up with Tie
Enter "Y" to continue or "N" to quit : n
Bye Bye
Come again soon!!!!!!!!!!!!
5.Student Mark Report :
Program :
student_count = int(input("Enter the no. of students : "))
subjects = ('Tamil','English','Maths','Science','Social')
report = {}
for j in range(student_count) :
name = input('Enter the name of student %d:'%(j+1))
marks = []
for i in subjects:
mark = int(input('Enter your mark for %s :'%i))
marks.append(mark)
report[name] = marks
print(report)
to_search_marks = input('Enter "Y" to know the marks for particular students : ').upper()
while to_search_marks == 'Y':
student_name = input('Enter the name : ')
for k in report[student_name] :
if k<35:
print('Failed')
else :
print(k)
to_search_marks = input('Enter "Y" to know the marks for particular students : ').upper()
Output :
Enter the no. of students : 3
Enter the name of student 1:Elon
Enter your mark for Tamil :90
Enter your mark for English :98
Enter your mark for Maths :100
Enter your mark for Science :100
Enter your mark for Social :90
Enter the name of student 2:Sundhar
Enter your mark for Tamil :90
Enter your mark for English :91
Enter your mark for Maths :100
Enter your mark for Science :99
Enter your mark for Social :34
Enter the name of student 3:Sathya
Enter your mark for Tamil :90
Enter your mark for English :94
Enter your mark for Maths :100
Enter your mark for Science :98
Enter your mark for Social :45
{'Elon': [90, 98, 100, 100, 90], 'Sundhar': [90, 91, 100, 99, 34], 'Sathya': [90, 94, 100, 98, 45]}
Enter "Y" to know the marks for particular students : y
Enter the name : Elon
90
98
100
100
90
Enter "Y" to know the marks for particular students : y
Enter the name : Sundhar
90
91
100
99
Failed
Enter "Y" to know the marks for particular students : n
Comments