0% found this document useful (0 votes)
5 views

Assignment 6

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)
5 views

Assignment 6

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/ 4

Quiz Project - Using dictionary, string functions, for loop

• The key of the dictionary is the question


• The value of the dictionary is a list of 4 items
– Here the 1st three items are the choices, and the last item is the correct answer
• You need to ask each question at a time to the user
– also display all the three choices
– let the user enter the correct choice number [1/2/3]
• Match the user's choice with the correct answer in the dictionary
– update score depending on the correct answer
• display the correct answer in case of the wrong choice entered by the user
• Calculate and display the total marks obtained by the user
# Quiz program using dictionary, string functions, for loop

# The key of the dictionary is the question


# The value of the dictionary is a list of 4 items
# Here the 1st three items are the coices, and the last item is the
correct answer

# Here are some of the sample questions


quiz = {'Japan must a name of a? ':
['country','city','town','country'],
'Is green light on the top of red light[yes/no]?':['yes','not
sure','no','no'],
'Chitah has strips/spots?':
['strips','spots','nothing','spots'],
'Zebra is a name of an?':['animal','bird','reptile','animal'],
'peacock is a [mammal/bird]?':
['mammal','animal','bird','bird'],
}

'''
Sample Output:

***** Let's play a QUIZ today *****


Enter your character's name: Trupti

Choose the correct alternative...

Japan must a name of a?


1. country 2. city 3. town
Enter your answer[1/2/3]:1
Correct answer!!!
---------------------------------------------
Is green light on the top of red light[yes/no]?
1. yes 2. not sure 3. no
Enter your answer[1/2/3]:3
Correct answer!!!
---------------------------------------------
Chitah has strips/spots?
1. strips 2. spots 3. nothing
Enter your answer[1/2/3]:1
Sorry... The correct answer is spots
---------------------------------------------
Zebra is a name of an?
1. animal 2. bird 3. reptile
Enter your answer[1/2/3]:2
Sorry... The correct answer is animal
---------------------------------------------
peacock is a [mammal/bird]?
1. mammal 2. animal 3. bird
Enter your answer[1/2/3]:3
Correct answer!!!
---------------------------------------------
Well Done Trupti!!! you scored 3 out of 5.

'''

Phone/Contact Book Project in Python


• Everyone uses a contact book to save contact details, including
– name, address, phone number, and even email address.
• Design a contact book application that users can use to save and find contact details.
• The application should also allow users to update contact information, delete contacts,
and list saved contacts.
• To handle a phone book project with Python can be helpful for and a good start.
# Creating a Phone Book using List, conditions and Loop

numberList=[]
nameList=[]
emailList=[]

'''
Sample Output:

********************************************************************
SMARTPHONE DIRECTORY
********************************************************************
You can now perform the following operations on this phonebook

1. Add a new contact


2. Remove an existing contact
3. Delete all contacts
4. Search for a contact
5. Display all contacts
6. Exit phonebook
Enter your choice [1/2/3/4/5/6]: 1
Enter contact number [10 digit number]: 98987987979
Enter name of a person: John
Enter email id of a person: [email protected]
--------------------------------------------------------
SNo Contact No. Name Email id
1 98987987979 John [email protected]
--------------------------------------------------------
********************************************************************
SMARTPHONE DIRECTORY
********************************************************************
You can now perform the following operations on this phonebook

1. Add a new contact


2. Remove an existing contact
3. Delete all contacts
4. Search for a contact
5. Display all contacts
6. Exit phonebook
Enter your choice [1/2/3/4/5/6]: 2
Please enter the contact number you wish to remove: 98798798
Sorry! Contact not found. Try again...
********************************************************************
SMARTPHONE DIRECTORY
********************************************************************
You can now perform the following operations on this phonebook

1. Add a new contact


2. Remove an existing contact
3. Delete all contacts
4. Search for a contact
5. Display all contacts
6. Exit phonebook
Enter your choice [1/2/3/4/5/6]: 4
Please enter the contact number you wish to search: 98987987979
SNo Contact No. Name Email id
1 98987987979 John [email protected]
********************************************************************
SMARTPHONE DIRECTORY
********************************************************************
You can now perform the following operations on this phonebook

1. Add a new contact


2. Remove an existing contact
3. Delete all contacts
4. Search for a contact
5. Display all contacts
6. Exit phonebook
Enter your choice [1/2/3/4/5/6]: 5
--------------------------------------------------------
SNo Contact No. Name Email id
--------------------------------------------------------
1 98987987979 John [email protected]
--------------------------------------------------------
********************************************************************
SMARTPHONE DIRECTORY
********************************************************************
You can now perform the following operations on this phonebook

1. Add a new contact


2. Remove an existing contact
3. Delete all contacts
4. Search for a contact
5. Display all contacts
6. Exit phonebook
Enter your choice [1/2/3/4/5/6]: 6
'''

You might also like