Learn Python With Data Science Challenge [ Day-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.
Why *args and **kwargs is used in some functions? Create a function each for *args and **kwargs to demonstrate their use.
What is an iterator in python? Name the method used to initialise 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].
What is a generator function in python? Why yield keyword is used? Give an example of a generator function.
Create a generator function for prime numbers less than 1000. Use the next() method to print the first 20 prime numbers.
Write a python program to print the first 10 Fibonacci numbers using a while loop.
print("Ans: 'def' is used to create a function in python.")
def odd_nums():
l = [i for i in range(1,26) if i%2 != 0]
return l
odd_nums()
Write a List Comprehension to iterate through the given string: ‘pwskills’.
Expected output: ['p', 'w', 's', 'k', 'i', 'l', 'l', 's']
Write a python program to check whether a given number is Palindrome or not using a while loop.
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.