Question

How to ues Python dictionary, enter the student information and get the following classification.

The student id is "key" and the subject name and grade is "value" to form the following form.

04차시 실습3을 활용하여, 학생의 학번을 key로, 학과, 이름, 과제성적 을 value로 하는 딕셔너리 구성 >> 학생 정보 딕셔너리 (학번 학과 이름 과제성적 을 띄어 쓰기로 입력할 것) | 1번째 학생의 정보를 입력하

This is my code, I don't know how to use the dictionary..

student_list = []
a = input("Student information 1: ")
b = input("Student information 2: ")

student_list.append(a[])
student_list.append(b)

print(student_list)

print(" {}".format([a] + [b]));

- D X thin 5 minutes Le 1.py - C:/Users/67816/Desktop/hw2/1.py (3.7.2) File Edit Format Run Options Window Help student_list

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program :

#dictionary for storing student details
#dictionary is of the form "key" : "value"
#here key is student id
#here value is subject, name and grade

student_dict = {}

#read the number of students
#whose data is to be entered
num_of_students = int(input("Enter the number of students : "))

#read the students data
#number_of_students + 1 is used, because range() start from 1
for i in range(1,num_of_students + 1):


a = input("Student information %d : "%i).split()
  
#here data is read in the form
# 2018000 CS peter 70
# it is split into a list as
# a = [2018000,CS,Peter,70]
#here key is a[0] , i.e., 2018000
#here value is a[1:] , i.e., [CS,Peter,70]
# a[1:] returns a list from index 1 to the end

#enter the split data to dictionary
#student["key"] = value
student_dict[a[0]] = a[1:]

#display the values in student dictionary
#in the form key [ value ]

for stu in student_dict:


print(stu,student_dict[stu])

  

Output :

ryPython.py Enter the number of students : 4 Student information 1 : 2018000 CS Peter 70 Student information 2 : 2019000 CS A

Source code screenshot :

File Edit Format Run Options Window Help S #dictionary for storing student details #dictionary is of the form key : value

Add a comment
Know the answer?
Add Answer to:
How to ues Python dictionary, enter the student information and get the following classification. The student...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as...

    In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as keys and an array for key containing a list of values (words from file of respective size) associated with those keys I am reading from a file of strings, where I am only interested with words of length 4, 5, and 6 to compute my program reading the text file line by line: At first, I have an empty dictionary then to that I...

  • Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following:

    Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following:How to format each dictionary item as a text string in the input file.How to covert each input string into a dictionary item.How to format each item of your inverted dictionary as a text string in the output file.Create an input file with your original three-or-more items and add at...

  • use python code complete this question 'Assignment 3 o Get information until getting 'n' from user...

    use python code complete this question 'Assignment 3 o Get information until getting 'n' from user Input the name of 1th student : 84 Input the math score of 1th student : 90 Input the english score of 1th student : 80 Input the science score of lth student : 100 Keep moving? (y/n): y Input the name of 2th student : 981 Input the math score of 2th student : 70 Input the english score of 2th student :...

  • Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Ini...

    Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...

  • For my computer class I have to create a program that deals with making and searching...

    For my computer class I have to create a program that deals with making and searching tweets. I am done with the program but keep getting the error below when I try the first option in the shell. Can someone please explain this error and show me how to fix it in my code below? Thanks! twitter.py - C:/Users/Owner/AppData/Local/Programs/Python/Python38/twitter.py (3.8.3) File Edit Format Run Options Window Help import pickle as pk from Tweet import Tweet import os def show menu():...

  • I am having trouble with my Python code in this dictionary and pickle program. Here is...

    I am having trouble with my Python code in this dictionary and pickle program. Here is my code but it is not running as i am receiving synthax error on the second line. class Student: def__init__(self,id,name,midterm,final): self.id=id self.name=name self.midterm=midterm self.final=final def calculate_grade(self): self.avg=(self.midterm+self.final)/2 if self.avg>=60 and self.avg<=80: self.g='A' elif self.avg>80 and self.avg<=100: self.g='A+' elif self.avg<60 and self.avg>=40: self.g='B' else: self.g='C' def getdata(self): return self.id,self.name.self.midterm,self.final,self.g CIT101 = {} CIT101["123"] = Student("123", "smith, john", 78, 86) CIT101["124"] = Student("124", "tom, alter", 50,...

  • need help debugging please need to know why isn't running and how to fix it Users\trinv\Downloads\Test...

    need help debugging please need to know why isn't running and how to fix it Users\trinv\Downloads\Test 3_Debugging Question(1).py - Notepad++ dit Search View Encoding Language Settings Tools Macro Run Plugins Window? ha LJ P2py x Test3 Plpy x B new i py Test_3_Debugging Question(1) py ") 6 str = input("Enter some text: ") 7 8 9 while (a < 0): 0 print(a) 1 a = a - 2 2 3 print(" 4 # # -5 26 for kin [1, 2,...

  • Something is preventing this python code from running properly. Can you please go through it and...

    Something is preventing this python code from running properly. Can you please go through it and improve it so it can work. The specifications are below the code. Thanks list1=[] list2=[] def add_player(): d={} name=input("Enter name of the player:") d["name"]=name position=input ("Enter a position:") if position in Pos: d["position"]=position at_bats=int(input("Enter AB:")) d["at_bats"] = at_bats hits= int(input("Enter H:")) d["hits"] = hits d["AVG"]= hits/at_bats list1.append(d) def display(): if len(list1)==0: print("{:15} {:8} {:8} {:8} {:8}".format("Player", "Pos", "AB", "H", "AVG")) print("ORIGINAL TEAM") for x...

  • Don't understand why code isn't running properly Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options...

    Don't understand why code isn't running properly Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options Window Help #Declare a variab i e and initialize it def displayInstructions (1angCode): 3tr . ENGLISHPROMPT = "Please enter your weight in poundョ >> " str.SPANISH PROMPT Por favor entre en su peso en libras > if langCode1: - print ("ENGLISH prompt) print ("SPANISH prompt") print ("Stop") elif langCode2 else: code input ( Enter code for instructions") num code weight = input ("Enter weight...

  • Question: I am unable to get a output of my function on my label1 when I...

    Question: I am unable to get a output of my function on my label1 when I click on button 1, please help? - x Lè DRAFT P1.py - C:\Users\Darren Louw\Desktop\DRAFT P1.py (3.8.2)* File Edit Format Run Options Window Help from tkinter import* HEIGHT=300 WIDTH=400 root=Tk) lowerframe=Frame (root, bg='green', bd=10) lowerframe.place (relx=0.5, rely=0.6, relwidth=0.75, relheight=0.2, anchor='n') labell-Label (lowerframe, bg='white', font=30) labell.place (relwidth=0.25, relheight=0.8, relx=0) def countl(): countl=0 for i in range (1,1001): num= i*i if num>1000: countl=countlul print('numbers in range 1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT