-
Swap Numbers Without Extra Variable
Create two variables:a = 10andb = 20. Swap their values without using a third variable. Then print both variables to show the swap worked.Example output:
a = 20 b = 10
-
Swap City Names
Create two variables:city1 = "Lahore"andcity2 = "Karachi". Swap their values. Then print both variables.Example output:
city1 = Karachi city2 = Lahore
-
Add Two Numbers from User
Ask the user to enter two numbers (one number per input). Add them and print the sum.Example:
If user enters5and8, output should be:13 -
Say Hello to User
Ask the user to enter their name. Print a greeting in this exact format:Hello Ali! -
Area of Rectangle
Ask the user for length and width (two numbers). Calculate area (length × width) and print:Area =followed by the answer.Example: Input
4and5→Area = 20
Q1. Write a program where first_name = "Ali" and last_name = "Khan", and print the full name using string concatenation.
Q2. Write a program that takes the user’s first name and last name from user and prints them together as a full name.
Q3. Write a program where language = "Python" and print the sentence: I am learning Python
Q4. Write a program that takes the user’s name and age from user and prints: My name is <name> and I am <age> years old
Q5. Write a program that takes the user’s name and uses f-string to print: Hello <name>, welcome to Python
Q6. Write a program where you concatenate three strings to form one meaningful sentence and print it.
Q1. Write a program that takes a number from the user and prints whether the number is even or odd.
Q2. Write a program that takes two numbers from the user and prints which number is greater.
Q3. Write a program that takes the user’s age and prints:
Childif age is less than 13Teenagerif age is between 13 and 19Adultotherwise
Q4. Write a program that takes a student’s marks and prints:
Passif marks are 40 or aboveFailotherwise
Q5. Write a program that takes a number from the user and prints whether the number is zero, positive, or negative.
Q6. Write a program that takes a number from the user and checks whether it is divisible by 3 or not.
Q7. Write a program that takes the user’s percentage and prints:
A Gradeif percentage is 80 or aboveB Gradeif percentage is between 60 and 79C Gradeif percentage is between 40 and 59Failotherwise
Q8. Write a program that asks the user for the day of the week and prints:
- Monday →
Start of the week! - Friday →
Weekend is near! - Saturday / Sunday →
Enjoy your weekend! - Any other day →
Keep going!
Q9. Create a calculator.
Q1. Write a program using a while loop to print numbers from 1 to 10.
Q2. Write a program using a for loop to print numbers from 1 to 10.
Q3. Write a program using a loop to print even numbers from 1 to 20.
Q4. Write a program using a loop to print the table of 5 e.g. 5 x 1 = 5.
Q5. Write a program using a loop to print the sum of numbers from 1 to 10.
Q6. Write a program that takes a number from the user and prints numbers from 1 to that number.
Q7. Write a program that prints numbers from 10 to 1 using a loop.
Q9. Write a program to print given blow outputs using a loop:
1) 2) 3) 4) 05)
* * * * * * * 1 * * * * *
* * * * * * * * 1 2 * *
* * * * * * * * * 1 2 3 * *
* * * * * * * * * * 1 2 3 4 * *
* * * * * * * * * * * 1 2 3 4 5 * * * * *Q1. Create a list of your favorite fruits and print each fruit using a loop.
Q2. Create a list of your weekly tasks and add a new task for tomorrow to take input from user and print the updated list.
Q3. Create a list of five city names and print the first and last city from the list.
Q4. Create a tuple of days in a week and print all the days.
Q5. Convert the tuple of days in a week into a list and add "Holiday" at the end. Print the final list.
Q6. Create a list of shopping items: ['milk', 'bread', 'eggs']. Ask the user one item and check output if it is in the list or not.
Q7. Create a list of your 5 favorite movies. Replace the second movie with a new one and print the updated list.
Q8. Write a program to combine two lists: fruits = ['apple', 'banana'] and vegetables = ['carrot', 'spinach'] and print the combined list.
Q9. Write a program to count how many times an item appears in a list. Example: colors = ['red','blue','red','green','red']
Q1. Create a set of your favorite fruits and print it. Add "mango" to the set and print again.
Q2. Create a set of numbers from 1 to 5 and another set of numbers from 4 to 8. Print the common numbers using set operations.
Q3. Create a dictionary for a student with keys: name, age, grade. Print the dictionary.
Q4. Update the student dictionary to add a new key city and print the updated dictionary.
Q5. Write a program where the user can input a fruit name. If the fruit exists in your dictionary of fruits and their prices, print its price; otherwise print "Not available".
Q6. Create a set of your favorite movies. Remove one movie using discard() and print the set.
Q7. Create two dictionaries: dict1 = {'a': 1, 'b': 2} and dict2 = {'b': 3, 'c': 4}. Merge them and print the result.
Q8. Write a program to find unique words in a sentence entered by the user using a set.
Q9. Create a dictionary with subject names as keys and marks as values. Print all subjects where marks are above 50.
Q10. Write a program to count how many times each word appears in a sentence using a dictionary.
Q1. Write a function named greet() that prints:
Welcome to Python Programming
Q2. Write a function named show_name(name) that takes a name as a parameter and prints:
Hello <name>
Q3. Write a function named add_numbers(a, b) that takes two numbers and prints their sum.
Q4. Write a function named student_info(name, age) that prints the student’s name and age in one sentence.
Q5. Write a function named calculate_bill(price, quantity) that takes price and quantity and prints the total bill.
Q6. Write a function named is_even(number) that returns whether the number is even or odd.
Q7. Write a function named get_full_name(first_name, last_name) that returns the full name using string concatenation.
Q8. Write a function named find_max(a, b) that returns the greater number.
Q9. Write a function named count_items(items) that takes a list and returns the total number of items.
Q10. Write a function named show_menu() that prints a simple food menu and calls the function when the program runs.
Q11. Write a function named calculate_discount(price) that:
- Takes the product price as a parameter
- Applies a 10% discount
- Prints the final price after discount
Q12. Write a function named login_message(username) that:
- Takes a username as a parameter
- Prints a welcome message for that user
Q1. Create variables to store shop name and shop city and print them in one line.
Q2. Take user input for customer name and print a welcome message.
Q3. Create variables for item name and item price, then print them.
Q4. Concatenate customer name and item name to print:
<customer> is buying <item>
Q5. Take input for quantity and print a sentence using concatenation showing quantity and item name.
Q6. If quantity is greater than 5, print Bulk order, otherwise print Regular order.
Q7. If item price is greater than 1000, print Expensive item, else print Affordable item.
Q8. Take input for payment method (cash, card, online) and print a confirmation message based on input.
Q9. Use a loop to print item name quantity number of times.
Q10. Use a loop to print numbers from 1 to quantity.
Q11. Use a loop to calculate total price by adding item price quantity times.
Q12. Create a list named cart and add three item names to it.
Q13. Print all items in the cart using a loop.
Q14. Ask the user to enter an item name and check if it exists in the cart.
Q15. Create a tuple of available payment methods and print them.
Q16. Check whether the user’s selected payment method exists in the tuple.
Q17. Create a set from the cart list to remove duplicate items and print unique items.
Q18. Create a dictionary where:
- keys = item names
- values = item prices
Print the dictionary.
Q19. Use a loop to calculate the total bill from the dictionary.
Q20. Create a function named generate_bill() that:
- Takes customer name, cart dictionary, and payment method
- Prints customer name
- Prints all items with prices
- Prints total bill
- Prints payment confirmation message
Concepts: Variables, input/output, operators Description: Create a console-based calculator that performs addition, subtraction, multiplication, and division based on user choice. Skills Practiced:
input()/print()- Arithmetic operators
- Basic control flow
Concepts: Conditional statements, loops Description: The program generates a random number, and the user guesses until correct. Provide hints (higher/lower). Skills Practiced:
if / elif / elsewhilelooprandommodule
Concepts: Conditions, logical operators Description: Take marks as input and calculate grade (A, B, C, Fail) based on predefined rules. Skills Practiced:
- Conditional logic
- Comparison operators
- Input validation
Concepts: Loops Description: Generate a multiplication table for a given number up to a specified range. Skills Practiced:
forloop- Formatting output
- Iteration logic
Concepts: Lists, loops Description: Allow users to add, view, and remove tasks from a to-do list using a menu-driven program. Skills Practiced:
- Lists
- Menu-based programs
- Loop control
Concepts: Strings, conditions Description: Check whether a password meets criteria (length, digits, uppercase, special character). Skills Practiced:
- String methods
- Logical conditions
- Validation rules
Concepts: Functions, conditionals Description: Simulate ATM operations: check balance, deposit, withdraw, and exit. Skills Practiced:
- Functions
- State management
- Conditional branching
Concepts: Dictionary, functions Description: Store contacts with name and phone number. Support add, search, update, and delete operations. Skills Practiced:
- Dictionaries
- CRUD operations
- Function modularity
Concepts: Lists, dictionaries, loops Description: Create a quiz with multiple questions, track score, and show final results. Skills Practiced:
- Nested data structures
- Looping over data
- Scoring logic
Concepts: Functions, data structures, logic flow Description: Develop a small banking system with user accounts, login, balance tracking, and transaction history. Skills Practiced:
- Functions + dictionaries
- Program flow control
- Real-world problem modeling
