0% found this document useful (0 votes)
20 views2 pages

Python Practice Questions

Uploaded by

supergamerhuman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Python Practice Questions

Uploaded by

supergamerhuman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Scenario: You are supposed to write a Python program that determines if a

person is eligible for a library membership. The program should consider the
person's age and residency status.
Task 1: Write a Python program that accepts the user's age and residency status.
If the person is 12 years or older and a resident, they are eligible for library
membership. If the person is under 12 or not a resident, they are not eligible for
membership. The output should display a message indicating whether the
person is eligible for library membership or not.
Task 2: Write a Python program that determines if a person qualifies for senior
library membership. If a person is 60 years or older and a resident, print "You
qualify for senior library membership." If the person is under 60 or not a resident,
print "You do not qualify for senior library membership."
Task 3: Write a Python program that classifies the person's membership eligibility
based on their age group and residency status. If the person is 12-59 years old
and a resident, print "You qualify for a general library membership." If the person
is 60 years or older and a resident, print "You qualify for senior library
membership." If the person is under 12 or not a resident, print "You are not
eligible for library membership."

Scenario: Imagine you are managing the inventory of a small gadget store.
Each gadget has a name, brand, price, and quantity in stock. You decide to use a
Python dictionary to manage this inventory.
Task: You need to implement an inventory system to manage the gadgets in the
store.
Q1: Create a dictionary where each key is the gadget's name, and the value is
another dictionary containing the brand, price, and quantity. Use the following
example data:

Gadget Price Quanti


Brand
Name (₹) ty

Smartphon Samsu
15,000 25
e ng

Laptop Dell 45,000 10

Tablet Apple 30,000 8

Headphone
Sony 2,000 50
s
Q2: Find the length of the dictionary and add a new gadget to the dictionary.
Print the updated dictionary to confirm that the new gadget has been added.
Q3: Write a Python program to display the quantity of "Laptop" in stock.
Q4: Update/replace the "Tablet" entry, keeping the brand name the same, with
a new price of 32,000 and a quantity of 12.
Scenario: You are working as a Python developer on a project that requires
building a modular Python application. The task is to break down the application
into functions and modules for better maintainability. You are also required to
work with conditionals, loops, and understand script execution flow in Python.
Task1: Write a Python function that takes a number as input and checks if the
number is positive, negative, or zero. The function should print the appropriate
message: "Positive", "Negative", or "Zero."
Task2: Write a Python script ([Link]) that contains a function
greet_user(). This function should print "Welcome to the Python program."
Ensure that this message is only printed if the script is run directly (not imported
as a module).
 Use if __name__ == "__main__": to ensure the message is printed only
when the script is executed directly.

You might also like