Python Assessment
Python Assessment
1.Using print()
1. To display a statement. For example, "Hello, How are you?"
3. Write the alphabets 'A', 'B', 'C' on new lines using a single print function
2. Data types
4. Create a string, a numeric and boolean variables by assigning variable names. Further, check their
datatype. For numeric variable check for whole numbers and numbers with decimal point.
i. An interger variable.
3. Arithmetic Operations
7. Evaluate 145 into 354 minus 1345 divided by 45 plus (462 plus 23) divided by 3.
25 divided by 6
33 raised to 4
2 raised to 10
5. Concatenation
10. Concatenate the variables 'num = 34 and 'string ='How old are you?' using '+' operator.
1. String Operations
11. Create a string with the name 'country' and 'India' as its element. Perform the following on it:
2. List
1. Write a program to perform following list operations on the list given below:
num_list_1 = [1, 2, 3, 4]
num_list_2 = [0, 5, 2, 1]6. Write a program to perform following built-in list operations:
a. Min(list)
b. Max(list)
a. First element
d. Slice the list from 1st index till the last index with an increment of an index by 2
4. Manipulating a list:
3. Tuple
5. Write a code to perform operations on tuple:
num_tuple = (4, 4, 8)
mix_tuple = 'John', 5, -2
4. Set
8. Write the program to perform following manipulations:
num_set = {1, 2, 3, 4, 5, 6}
9. Create two sets of words from the given sentences and perform the following operations:
a. Union
b. Intersection
e. Symmetric difference
5. Dictionary
11. Write a code to add a key to a dictionary
13. Write a program to get the value for 'Age' from the dictionary
14. Write a program to create a dictionary using given keys and values
key = ['a','b','c','d']
value = [1, 2, 3, 4]
15. Set the country of an employee as 'India' in the given employee record
emp_record = {'Emp_ID': 'ES001', 'Weight': 67, 'BMI': 25, 'Age': 27, 'Profession': 'CA'}
1. Conditional Statements
1. Write a program to check whether a given number is multiple of 7 (use if statement)
3. Write a program to check whether a number is positive, negative or zero (use if-elif)
5. Write a program for generating a fibonacci series starting with 0 and 1 for the next 10 values using a
while loop.
6. Write a program to check whether a number is greater than the other using if statement (take the
input from user).
7. Write a code to check whether a number is divisible by 7 or not (take the input from user).
8. Write a code to find factorial of a number (take the input from user).
9. Write a program to check whether a number is prime or not (take the input from user).
10. Write a program to check whether two numbers are amicable or not (take the input from user).
11. Reverse string using a for loop (take the input from user).
12. Write a code to find the average of given numbers (take the input from user).
13. Write a program to find the area of a circle for a given radius (take the input from user).
14. Write a code to find the simple interest (take the input from user).
3. List Comprehension
15. Use list comprehension to obtain the squre root of first 10 natural numbers.
16. Use list comprehension to find the used vowels in a given sentence and/or word (take the input from
user).
17. Create a dictionary and access it values using a condition on its key. The data is given below. Let the
condidtion on the key is that it should be a even number.
Key 1 2 3 4 5
Marks 24 25 26 24 27
18. Use list comprehension to find even and odd numbers from first 20 whole numbers.
19. Use list comprehension to print numbers divisible by 2 and 3 in between 1 and 100.
20. Use list comprehension to create a dictionary such that its keys are numbers from 1 to 10 and values
are the corresponding to that key are its cube.
21. Use list comprehension to extract numbers from a string
1. User-Define Function:
1. Define the python function to swap first and last value of the given list
2. Define the python function which adds two global numeric variables (1204 and 344536)
3. Define the python function to check whether the number 33 is even or odd
6. Write a python function to test whether the two words start with the same character or not (take the
inputs from the user)
7. Check if the string contains a vowel or not (take the inputs from the user)
8. Write the python program to get the unique values from the given list
my_list = [1,2,3,3,11,34,3,3,4,5]
string1 = 'Angel'
string2 = 'apple'
10. Define a function to perform addition, multiplication, and subtraction of the given two numbers
Use the number given below:
a = 15
b=4
11. Define a function to find the sum of all elements in the list
2. Lambda Functions
12. Find the minimum of the two numbers(34 and 78) using the lambda function
14. Read the given sentence and print the length of each word in a sentence in a list using the map
function
15. Find the remainder of all the numbers present in a list after dividing by 5
16. Concatenate elements from the list1 with the corresponding element of list2
list1 = ['I', 'felt', 'happy', 'because', 'I', 'saw', 'the', 'others', 'were', 'happy']
list2 = [11,22,33,44,55,66,77,88,99]
2.2 Filter Function
17. Find the common elements from the given array using filter method
arr1 = ['t','u','t','o','r','i','a','l']
arr2 = ['p','o','i','n','t']
numbers = [21, 23, 443, 355, 743, 823, 110, 1241, 3673, 352, 278, 37, 7]
my_list = [47,11,42,102,13].