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

Output 2

The document contains questions about Python programming concepts like variables, data types, functions, lists, strings, loops, lambda functions, map, filter and reduce functions. The questions cover basic syntax and usage of these concepts.

Uploaded by

Sunil Jaswal
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)
27 views1 page

Output 2

The document contains questions about Python programming concepts like variables, data types, functions, lists, strings, loops, lambda functions, map, filter and reduce functions. The questions cover basic syntax and usage of these concepts.

Uploaded by

Sunil Jaswal
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

1.

How do you comment code in Python? What are the different types of comments?
2. What are variables in Python? How do you declare and assign values to variables?
3. How do you convert one data type to another in Python?
4. How do you write and execute a Python script from the command line?
5. Given a list my_list = [1, 2, 3, 4, 5], write the code to slice the list and obtain the sub-list [2, 3].
6. What is a complex number in mathematics, and how is it represented in Python?
7. What is the correct way to declare a variable named age and assign the value 25 to it?
8. Declare a variable named price and assign the value 9.99 to it. What data type does this variable
belong to?
9. Create a variable named name and assign your full name to it as a string. How would you print the
value of this variable?
10. Given the string "Hello, World!", extract the substring "World".
11. Create a variable named is_student and assign it a boolean value indicating whether you are currently a
student or not.

function

1. Which keyword is used to create a function? Create a function to return a list of odd numbers in the
range of 1 to 25.
2. Why *args and **kwargs is used in some functions? Create a function each for *args and **kwargs to
demonstrate their use.
3. What is an iterator in Python? Name the method used to initialize the iterator object and the method
used for iteration. Use these methods to print the first five elements of the given list [2, 4, 6, 8,
10, 12, 14, 16, 18, 20].
4. What is a generator function in Python? Why is the yield keyword used? Give an example of a generator
function.
5. Create a generator function for prime numbers less than 1000. Use the next() method to print the first
20 prime numbers.
6. Write a Python program to print the first 10 Fibonacci numbers using a while loop.
7. Write a List Comprehension to iterate through the given string: 'pwskills'.
Expected output: ['p', 'w', 's', 'k', 'i', 'l', 'l', 's']
8. Write a Python program to check whether a given number is a Palindrome or not using a while loop.
9. Write a code to print odd numbers from 1 to 100 using list comprehension.
Note: Use a list comprehension to create a list from 1 to 100 and use another list comprehension to
filter out odd numbers.

1. Create a Python program to sort the given list of tuples based on the integer value using a lambda
function.
[('Sachin Tendulkar', 34357), ('Ricky Ponting', 27483), ('Jack Kallis', 25534), ('Virat Kohli', 24936)]
2. Write a Python program to find the squares of all the numbers in the given list of integers using
lambda and map functions.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
3. Write a Python program to convert the given list of integers into a tuple of strings using map and
lambda functions.
Given list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Expected output: ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10')
4. Write a Python program using the reduce function to compute the product of a list containing numbers
from 1 to 25.
5. Write a Python program to filter the numbers in a given list that are divisible by 2 and 3 using the
filter function.
[2, 3, 6, 9, 27, 60, 90, 120, 55, 46]
6. Write a Python program to find palindromes in the given list of strings using lambda and filter
functions.
['python', 'php', 'aba', 'radar', 'level']

You might also like