Lab 1
Download the ipynb
file python.ipynb.
Arrays
Write a Python program to find the second largest element in an array.
Write a python program that moves all the zeros in the array to the end while keeping the order of other elements same
Functions
Write a Python program to generate the first n numbers from the Fibonacci sequence. In the Fibonacci sequence, each number is sum of the previous two numbers and the series looks like this: 0, 1, 1, 2, 3, 5, 8, 13, \ldots
Write a Python program that takes an integer and returns the sum of its digits.
Strings
Write a Python program to count the number of strings where the string length is 2.
Write a Python program to check if string ‘s2’ is subset of string ‘s1’.
Write a Python program to check if a string is a palindrome.
Loops
In Python, matrix is represented as a list of lists. Write python program to perform matrix multiplication.
Write a Python program to reverse the word in a given sentence without changing the word order in sentence. For example, “hello world” to “olleh dlrow”.
Conditionals
Write a Python program to check if the year is a leap year.
Write a Python program that returns grade based on the following criteria: * 90 to 100 -> Grade A * 80 to 89 -> Grade B * 70 to 79 -> Grade C * 60 to 69 -> Grade D * Below 60 -> Fail