Skip to main content

GRADE XI - PYTHON DICTIONARY

 PYTHON DICTIONARY 

PRACTICAL QUESTIONS 

IP - GRADE XI


Q1. WAP to create a dictionary containing names of competition winner students as KEY and number of their wins as values.


n=int(input("How Many Students ?")) 

compwinner={ }

for i in range(n):

    key=input("Enter Name of the Student:")

    value=int(input("Enter No of Wins:"))

    compwinner[key]=value

print("The Dictionary is:", compwinner)


Q2.WAP TO INPUT TOTAL NO OF SECTIONS AND STREAM IN 11TH CLASS AND DISPLAY ALL.

cxi={}

n=int(input("Enter n no of sections:"))

i=1

while i<=n:

    sec=input("Enter section:")

    stre=input("Enter Stream:")

    cxi[sec]=stre

    i+=1

print("class section  stream")

for i in cxi:

    print("XI", i , cxi[i])


Q3. WAP to create a dictionary containing roll number of students and percentage as

values for n number of students display the total number of students scoring more than 80

stud={ }# Empty dictionary created

n=int(input("enter mumber of students - "))

for i in range(n):

    rno = input("enter Roll No - ")

    stud[rno] = float(input("Enter percentage –"))

ctr=0

for rno in stud:

    if stud[rno]>80:

        ctr+=1

print("No. of students scoring percentage above 80 –" ,ctr)


Q4. Program to create a dictionary which stores names(key) of employees and their salary(value)


num = int(input("Enter the number of employees whose data to be stored: "))

count = 1

employee = {}

for count in range (num):

    name = input("Enter the name of the Employee: ")

    salary = int(input("Enter the salary: "))

    employee[name] = salary

    print("\n\nEMPLOYEE_NAME \tSALARY")

    

    for k in employee:

        print(k,'\t\t',employee[k])


Q5.Dictionary key pointing to different values

dic = {}

while True :

    nam = input("Enter name :-")

    phone = float(input("Enter phone number :-"))

    cost = float(input("Enter cost :-"))

    item = input("Enter item :-")

    dic[ nam ] = [ phone , item , cost ]

    a = input("Do you want to enter more records enter (Yes/ No) :- ")

    if a == "No" or a == "no":

        break

for i in dic :

    print()

    print("Name : ", i )

    print("Phone : ", dic[ i ][ 0 ] , "\t"

          , "Cost : ", dic[ i ][ 1 ] , "\t", 

          "Item : ",  dic[ i ][ 2 ])


Q6.Display product if present in the dictionary otherwise invalid message

dic = { }


while True :

    product = input("enter the name of product (enter q for quit )= ")

    if product == "q" or product == "Q" :

        break

    else :

        price = int(input("enter the price of product = "))

        dic [ product ] = price


while True :

    name = input("enter the name of product those you are 

                 entered (enter q for quit )= ")

    if name == "q" or name == "Q" :

        break

    else :

        if name not in dic :

            print("name of product is invaild")

        else :

            print("price of product = ",dic[name])

Q6. Write a Python program that accepts a value and checks whether the inputted value is part of given dictionary or not. If it is present, check for the frequency of its occurrence and print the corresponding key otherwise print an error message.

'''

dic = eval(input("Enter a dictionary :- "))

val = eval(input("Enter a value :-"))


lst = list( dic.values() )

if val in lst :

    print("Frequency of occurrence of ",val ," is ", lst.count( val ))

    print("Its key are :-" )

    for i in dic :

        if dic [i] == val :

            print(i)

else :

    print("Not found !!")

Comments

Popular posts from this blog

GRADE XII - Python Connectivity with MySQL

  Python Connectivity with MySQL In real-life applications, the data inputted by the user and processed by the application needs to be saved permanently, so that it can be used for future manipulation. Usually, input and output data is displayed during execution but not stored, as it resides in main memory , which is temporary — i.e., it gets erased once the application is closed. This limitation can be overcome by sending the data to be stored in a database , which is made accessible to the user through a Front-End interface . Key Concepts Database A database is an organized collection of data that is stored and accessed electronically from a computer system. DBMS (Database Management System) A DBMS is software that interacts with end-users, applications, and the database to capture and analyze data. Front-End The Front-End is the user interface of the application, responsible for input/output interaction with the user. Back-End The Back-End refe...

GRADE XI | DESIGN THINKING & INNOVATION (848) | INTRO | CH-1

  DESIGN THINKING &  INNOVATION (848)  INTRODUCTION LINK : INTRODUCTION PPT PPT LINK Notes: Design Thinking and Innovation Grade XI Introduction Section   I. What is Design? (0.1.1) Definitions from Experts: John Maeda: "Design is solution to a problem". Saul Bass: "Design is thinking made visual". Charles Eames:   “Design is a plan for arranging elements in such a way as best to accomplish a particular purpose.” Steve Jobs:  "Design is not just what it looks like and feels like. Design is how it works". Prof. Sudhakar Nadkarni:  "Essentials of design are— purity, precision, details". Design is a way of understanding needs, identifying problems, and creating appropriate and innovative solutions. It is not only about appearance, but also about usefulness and sustainability. Design is explained as something that helps solve problems and make a positive difference. Key ...