Computer Science, asked by temp8722388999, 2 months ago

1.Write a program to create a phone dictionary for the students of class XI and print their
Index values.

2.Create a nested dictionary that stores the marks details along with student names and
then prints the output.

3.Write a program to input ‘n’ words and store them in a list. Display letter count (in ascending order) for each by storing the same in a dictionary. If letter count is more than 5 then replace it with a new word and also edit the list.

Answers

Answered by shobhabidlan01
1

Answer:

This is a Python Program to generate a dictionary that contains numbers (between 1 and n) in the form (x,x*x).

Problem Description

The program takes a number from the user

Answered by surajnegi0600
0

Answer:

  1. A program to create a phone dictionary for the students of class XI and print their
  2. Create a nested dictionary that stores the marks details along with student names and then prints the output.
  3. A program to input ‘n’ words and store them in a list. Display letter count (in ascending order) for each by storing the same in a dictionary. If letter count is more than 5 then replace it with a new word and also edit the list.

Explanation:

1.

Index values.

def create_phone_dictionary():

   phone_dictionary = {}

   n = int(input("Enter the number of students: "))

   for i in range(n):

       name = input("Enter student name: ")

       phone = input("Enter student phone number: ")

       phone_dictionary[name] = phone

   return phone_dictionary

def print_index_values(phone_dictionary):

   for i, (name, phone) in enumerate(phone_dictionary.items()):

       print("Index:", i, "Student Name:", name, "Phone Number:", phone)

phone_dictionary = create_phone_dictionary()

print_index_values(phone_dictionary)

2.

def create_marks_dictionary():

   marks_dictionary = {}

   n = int(input("Enter the number of students: "))

   for i in range(n):

       name = input("Enter student name: ")

       physics = int(input("Enter Physics marks: "))

       chemistry = int(input("Enter Chemistry marks: "))

       maths = int(input("Enter Maths marks: "))

       marks_dictionary[name] = {"Physics": physics, "Chemistry": chemistry, "Maths": maths}

   return marks_dictionary

def print_marks_dictionary(marks_dictionary):

   for name, marks in marks_dictionary.items():

       print("Student Name:", name)

       for subject, mark in marks.items():

           print(subject, ":", mark)

marks_dictionary = create_marks_dictionary()

print_marks_dictionary(marks_dictionary)

3.

def word_letter_count():

   words = []

   n = int(input("Enter the number of words: "))

   for i in range(n):

       word = input("Enter word: ")

       words.append(word)

   letter_count_dictionary = {}

   for word in words:

       letter_count = len(word)

       if letter_count in letter_count_dictionary:

           letter_count_dictionary[letter_count].append(word)

       else:

           letter_count_dictionary[letter_count] = [word]

   for letter_count, words_list in sorted(letter_count_dictionary.items()):

       for word in words_list:

           if letter_count > 5:

               word_index = words.index(word)

               words[word_index] = "****"

           print(word, ":", letter_count)

word_letter_count()

More questions and answers

https://brainly.in/question/14309106?referrer=searchResults

https://brainly.in/question/31617605?referrer=searchResults

#SPJ3

Answered by surajnegi0600
0

Answer:

  1. A program to create a phone dictionary for the students of class XI and print their
  2. Create a nested dictionary that stores the marks details along with student names and then prints the output.
  3. A program to input ‘n’ words and store them in a list. Display letter count (in ascending order) for each by storing the same in a dictionary. If letter count is more than 5 then replace it with a new word and also edit the list.

Explanation:

1.

Index values.

def create_phone_dictionary():

   phone_dictionary = {}

   n = int(input("Enter the number of students: "))

   for i in range(n):

       name = input("Enter student name: ")

       phone = input("Enter student phone number: ")

       phone_dictionary[name] = phone

   return phone_dictionary

def print_index_values(phone_dictionary):

   for i, (name, phone) in enumerate(phone_dictionary.items()):

       print("Index:", i, "Student Name:", name, "Phone Number:", phone)

phone_dictionary = create_phone_dictionary()

print_index_values(phone_dictionary)

2.

def create_marks_dictionary():

   marks_dictionary = {}

   n = int(input("Enter the number of students: "))

   for i in range(n):

       name = input("Enter student name: ")

       physics = int(input("Enter Physics marks: "))

       chemistry = int(input("Enter Chemistry marks: "))

       maths = int(input("Enter Maths marks: "))

       marks_dictionary[name] = {"Physics": physics, "Chemistry": chemistry, "Maths": maths}

   return marks_dictionary

def print_marks_dictionary(marks_dictionary):

   for name, marks in marks_dictionary.items():

       print("Student Name:", name)

       for subject, mark in marks.items():

           print(subject, ":", mark)

marks_dictionary = create_marks_dictionary()

print_marks_dictionary(marks_dictionary)

3.

def word_letter_count():

   words = []

   n = int(input("Enter the number of words: "))

   for i in range(n):

       word = input("Enter word: ")

       words.append(word)

   letter_count_dictionary = {}

   for word in words:

       letter_count = len(word)

       if letter_count in letter_count_dictionary:

           letter_count_dictionary[letter_count].append(word)

       else:

           letter_count_dictionary[letter_count] = [word]

   for letter_count, words_list in sorted(letter_count_dictionary.items()):

       for word in words_list:

           if letter_count > 5:

               word_index = words.index(word)

               words[word_index] = "****"

           print(word, ":", letter_count)

word_letter_count()

More questions and answers

https://brainly.in/question/14309106?referrer=searchResults

https://brainly.in/question/31617605?referrer=searchResults

#SPJ3

Similar questions