0% found this document useful (0 votes)
39 views6 pages

Python Assignment

The document discusses Python programs to store and manipulate student data. It includes functions to store student details like roll number, name, and marks or attendance in a dictionary, write the data to a text file, sort and display the data, find minimum attendance, and search by student name. The main program allows the user to choose these options and call the corresponding functions to perform operations on the student data.

Uploaded by

Jinitha
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)
39 views6 pages

Python Assignment

The document discusses Python programs to store and manipulate student data. It includes functions to store student details like roll number, name, and marks or attendance in a dictionary, write the data to a text file, sort and display the data, find minimum attendance, and search by student name. The main program allows the user to choose these options and call the corresponding functions to perform operations on the student data.

Uploaded by

Jinitha
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/ 6

Assignment

PYTHON FOR MACHINE LEARNING

Jinitha mol k
S3 EEE
PKD21EE030
ROLL NO-30
1) Write a Python program to store the student details (Rollno,name & mark) as a dictionary. Use

rollno as the key for the dictionary and a tuple containing name & mark as value. Display the
details

of all students. Also display the details of the student having the highest mark.

Example:

marks_report ={1:(“ARUN”,45) , 2:(“JOHN”,48)}

def students(n):

marks_report = {}

for i in range(n):

rollno = int(input("Roll No: "))

name = input("Student Name: ")

mark = int(input("Marks: "))

marks_report[rollno] = (name, mark)

print(marks_report)

n = int(input("Enter No of Students:"))

students(n)
2) Write a Python program to store the student’s attendance details (Rollno,Name & Attendance

percentage) into a text file. Display the complete attendance report. Also display the details of

students having attedance lessthan 75%.

D = dict()

n = int(input('How many student record you want to store?? '))

# Add student information

# to the dictionary

for i in range(0,n):

x, y = input("Enter the complete name (First and last name) of student: ").split()

z = input("Enter roll number: ")

m = input('Enter attendence percentage: ')

D[x, y] = (z, m)

# define a function for sorting

# names based on first name

def sort():

ls = list()

# fetch key and value using

# items() method

for sname,details in D.items():

# store key parts as an tuple

tup = (sname[0],sname[1])

# add tuple to the list

ls.append(tup)

# sort the final list of tuples

ls = sorted(ls)
for i in ls:

# print first name and second name

print(i[0],i[1])

return

# define a function for

# finding the minimum attendence

# in stored data

def minattend():

ls = list()

# fetch key and value using

# items() methods

for sname,details in D.items():

# add details second element

# (marks) to the list

ls.append(details[1])

# sort the list elements

ls = sorted(ls)

print("Minimum attendence: ", min(ls))

return

# define a function for searching

# student roll number

def searchdetail(fname):

ls = list()

for sname,details in D.items():

tup=(sname,details)
ls.append(tup)

for i in ls:

if i[0][0] == fname:

print(i[1][0])

return

# define a function for

# asking the options

def option():

choice = int(input('Enter the operation detail: \n \

1: Sorting using first name \n \

2: Finding Minimum attendence \n \

3: Search roll number using first name: \n \

4: Exit\n \

Option: '))

if choice == 1:

# function call

sort()

print('Want to perform some other operation??? Y or N: ')

inp = input()

if inp == 'Y':

option()

# exit function call

exit()

elif choice == 2:

minattend()
print('Want to perform some other operation??? Y or N: ')

inp = input()

if inp == 'Y':

option()

exit()

elif choice == 3:

first = input('Enter first name of student: ')

searchdetail(first)

print('Want to perform some other operation??? Y or N: ')

inp = input()

if inp == 'Y':

option()

exit()

else:

print('Thanks for executing me!!!!')

exit()

option()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy