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

Python Assignments (1) - Copy

The document outlines a series of programming tasks involving basic data structures such as lists, tuples, dictionaries, and control flow statements in Python. Tasks include creating and manipulating lists and dictionaries, calculating sums and averages, checking conditions, and implementing simple algorithms. It serves as a practical guide for beginners to practice fundamental programming concepts.

Uploaded by

sa6382927
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)
2 views5 pages

Python Assignments (1) - Copy

The document outlines a series of programming tasks involving basic data structures such as lists, tuples, dictionaries, and control flow statements in Python. Tasks include creating and manipulating lists and dictionaries, calculating sums and averages, checking conditions, and implementing simple algorithms. It serves as a practical guide for beginners to practice fundamental programming concepts.

Uploaded by

sa6382927
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/ 5

1.

​ Create and Print a List​

○​ Input 5 numbers from the user and store them in a list. Then print the list.​

2.​ Find Length of Tuple​

○​ Create a tuple of 6 items and print its length using len() function.​

3.​ Sum of List Elements using for loop​

○​ Write a program to calculate the sum of all elements in a list using a for
loop.​

4.​ Access Dictionary Values​

○​ Create a dictionary with keys as subjects and values as marks. Print marks
for a given subject.​

5.​ Print All Even Numbers in a List using while loop​

○​ Input a list of 10 numbers and print only the even ones using a while loop.​

6.​ Find Maximum and Minimum from List​

○​ Write a program to find the maximum and minimum values from a list
without using built-in max() or min().​

7.​ Check if Element Exists in Tuple​

○​ Ask user for an item and check whether it exists in a given tuple or not.​

8.​ Count Frequency of Elements in List​

○​ Input a list and create a dictionary where keys are elements and values are
their frequency.​

9.​ Reverse a List Without Using reverse()​

○​ Write a program to reverse a list using a loop.​


10.​Merge Two Dictionaries
●​ Take two dictionaries and merge them into one using a loop (without using
update()).

11.​Student Record System​

●​ Use a dictionary where keys are student names and values are lists of 3 marks.​

●​ Calculate and print each student’s average.​

12.​Remove Duplicates from a List​

●​ Input a list with repeated values and create a new list with unique values only
(without using set()).​

13.​Sort a List (Manual Bubble Sort using Loops)​

●​ Sort a list of numbers in ascending order using a loop (no built-in sort).​

14.​Create a Frequency Dictionary from a Sentence​

●​ Input a sentence from the user and count the frequency of each word using a
dictionary.
15.​Search in Nested Dictionary

Use a nested dictionary of students and their subject marks.​


Example:​

python​
CopyEdit​
data = {
"Ali": {"Math": 85, "Science": 90},
"Sara": {"Math": 78, "Science": 88}
}

●​
●​ Ask user to input a student name and subject, and display the corresponding
mark.​


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
======================================================================
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++​






Greet User​

●​ Input the user's name and print a greeting message.​

●​ Example: Input: Ali → Output: Hello, Ali!​

Simple Addition Calculator​

●​ Input two numbers and print their sum.​

Check Even or Odd​

●​ Input a number and print whether it is even or odd.​

Check Positive or Negative Number​

●​ Input a number and check if it's positive, negative, or zero.​

Find Greater Number​

●​ Input two numbers and print which one is greater or if they are equal.


Voting Eligibility Checker​
●​ Input age, check if the user is eligible to vote (age ≥ 18).​

Grade Calculator​

●​ Input marks and print grade using conditions:

Odd-Even and Divisible by 5​

○​ Input a number, check:​

■​ Is it even?​

■​ Is it divisible by 5?​

Login System (Hardcoded)​

○​ Input username and password. If both match hardcoded values, print "Login
Successful", otherwise "Login Failed".​

Find the Largest Among Three Numbers​

●​ Input three numbers and find the largest one using if, elif, and else.​

Check Leap Year

●​ Input a year and check if it's a leap year.​


(Leap year rule: divisible by 4, not divisible by 100 unless also divisible by 400)​

●​ Basic Calculator (with if-elif)​

●​ Input two numbers and an operator (+, -, *, /)​

●​ Perform and print the operation using conditional statements.​


Simple Number Guessing Game

●​ Hardcode a number (e.g., 7). Ask the user to guess.​

●​ If correct → "You won!", else → "Try again!"

Check if Character is a Vowel or Consonant

●​ Input a single character and check if it is a vowel (a, e, i, o, u) or consonant.

You might also like