0% found this document useful (0 votes)
16 views1 page

Python Basic Ws

Uploaded by

sonor46926
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)
16 views1 page

Python Basic Ws

Uploaded by

sonor46926
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/ 1

Work Sheet 1

Issued date : 10/10/24 summation date : 14/10.24

Section 1: Basics of Python (e.g., variable swapping)

1. Swap two variables without using a third variable.

x = 5
y = 10
# Swap x and y

2. Write a Python program to calculate the sum of two numbers provided by the
user.

# Input: 3, 5
# Output: 8

3. Write a program that takes a number as input and prints whether it is even or
odd.
4. Write a Python program to find the largest of three numbers.
5. Write a Python program to swap two variables using a temporary variable.

Section 2: Lists, Dictionaries, Tuples, and Sets

1. Create a list of 5 integers and print the list in reverse order.


2. Write a program to count the number of occurrences of an element in a list.
3. Given a list, remove the duplicates and return a new list.
4. Create a dictionary to store student names and their scores. Write a program to
display the highest-scoring student.
5. Write a Python program to update a value in a dictionary.
6. Create a tuple with mixed data types and print each element.
7. Write a program to find the intersection and union of two sets.
8. Convert a list into a tuple and a tuple into a list.
9. Write a Python program to check if a given key exists in a dictionary.

Section 3: Variables and Data Types

1. Write a program to display the type of variable for the following inputs: 5, 5.0,
"Hello", [1, 2, 3], (1, 2, 3), {1, 2, 3}.
2. Write a program to accept a string from the user and print it in reverse.
3. Create a variable of type float, then convert it into an integer and print the
result.
4. Create a program to demonstrate implicit and explicit type conversion.
5. Write a program that takes two inputs and checks if they are of the same data
type.

You might also like