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

Python Practice Questions

The document contains a series of Python practice questions focusing on control structures, data types, and basic operations. It includes exercises on if-elif-else statements, lists, tuples, dictionaries, and sets, encouraging users to implement various functionalities such as checking number signs, creating a login system, and performing lookups. Each exercise provides a specific task for users to complete, enhancing their programming skills.
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)
2 views2 pages

Python Practice Questions

The document contains a series of Python practice questions focusing on control structures, data types, and basic operations. It includes exercises on if-elif-else statements, lists, tuples, dictionaries, and sets, encouraging users to implement various functionalities such as checking number signs, creating a login system, and performing lookups. Each exercise provides a specific task for users to complete, enhancing their programming skills.
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

Python Practice Questions

If-Elif-Else
1. 1. Check Number Sign
- Ask the user for a number and print if it’s positive, negative, or zero.
2. 2. Login System
- Hardcode a username and password. Ask the user for both, and print:
- "Login successful" if both match
- "Wrong username" or "Wrong password" if only one is incorrect
- "Access denied" if both are wrong
3. 3. Simple Calculator
- Ask the user for two numbers and an operator (+, -, *, /). Use if-elif-else to perform
the correct operation.

List & Tuple


4. 1. Check Membership in List
- my_list = [2, 4, 6, 8]
- Ask the user for a number. Check if it’s in the list. Print "Found" or "Not found".
5. 2. Indexing Practice
- fruits = ["apple", "banana", "cherry"]
- Ask the user to enter 0, 1, or 2 and print the corresponding fruit. If invalid, print
"Invalid index".
6. 3. Compare First and Last Item of Tuple
- t = (5, 10, 15, 20, 5)
- Print "First and last are equal" or "Not equal".

Dictionary
7. 1. Phone Book Lookup
- phone_book = {"Alice": "1234", "Bob": "5678"}
- Ask the user for a name. Print the phone number if it exists. Otherwise, print "Not in
phone book".
8. 2. Subject Marks Evaluation
- marks = {"Math": 78, "Science": 88, "English": 65}
- Ask the user to enter a subject name. If it exists, print:
- "Pass" if marks ≥ 40
- "Fail" otherwise
- If subject not found, print "Subject not found".
Set Practice
9. 1. Is It a Weekend?
- weekend = {"Saturday", "Sunday"}
- Ask the user to enter a day of the week. Print "Weekend" or "Weekday".
10. 2. Element Belongs to Both Sets?
- A = {1, 2, 3}, B = {3, 4, 5}
- Ask the user for a number. Check if it’s in both sets. Print appropriate message.

You might also like