Repository to store practice lab assignments.
The repository contains 12 weeks of assignments, each consisting of 4-7 simple exercises to build foundational knowledge of Python.
- Write a Python program to display the current date and time.
- Write a Python program to get the Python version you are using.
- Write a Python program that accepts an integer (n) and computes the value of n + nn + nnn.
- Write a Python program to read and print various types of variables.
- Write a Python program to print the calendar of a given month and year.
- Write a Python program to find the square root.
- Write a Python program to calculate the area and perimeter of a triangle and a circle.
- Write a Python program to solve a quadratic equation.
- Write a Python program to swap two variables.
- Write a Python program to convert kilometers to miles.
- Write a Python program to convert Celsius to Fahrenheit.
- Write a Python program to determine whether a given number is even or odd.
- Write a Python program to get the difference between a given number and 17. If the number is greater than 17, return double the absolute difference.
- Write a Python program to test whether a number is within 100, 1000, or 2000.
- Write a Python program to calculate the sum of three given numbers. If the values are equal, return three times their sum.
- Write a Python program to find the factorial of a number.
- Write a Python program to print the maximum of three numbers.
- Write a Python program to determine whether a given year is a leap year.
- Write a Python program to find all numbers divisible by 7 but not a multiple of 5, between 2000 and 3200 (both included). Print the numbers in a comma-separated sequence on a single line. Use the
range(begin, end)
method. - Write a Python program to check whether a number is divisible by both 5 and 11.
- Write a Python program to check whether a character is an alphabet.
- Write a Python program to input any character and check whether it is an alphabet, digit, or special character.
- Write a Python program to check whether a character is an uppercase or lowercase alphabet.
- Write a Python program to input a week number and print the corresponding weekday.
- Write a Python program to count the total number of notes in a given amount.
- Write a Python program to print all natural numbers from 1 to n using a while loop.
- Write a Python program to find the sum of all odd numbers between 1 and n.
- Write a Python program to count the number of digits in a number.
- Write a Python program to find the first and last digits of a number.
- Write a Python program to calculate the sum of digits of a number.
- Write a Python program to enter a number and print its reverse.
- Write a Python program to check whether a number is a palindrome.
- Write a Python program to find the frequency of each digit in a given integer.
- Write a Python program to print all ASCII characters with their values.
- Write a Python program to find all factors of a number.
- Write a Python program to calculate the factorial of a number.
- Write a Python program to print all prime numbers between 1 and n.
- Write a Python program to check whether a number is an Armstrong number, strong number, prime number, perfect number, or magic number.
- Write a Python program to print the Fibonacci series up to n terms.
- Write a Python program to find the largest number in a list.
- Write a Python program to find the second largest number in a list.
- Write a Python program to separate even and odd elements in a list into two different lists.
- Write a Python program to merge two lists and sort them.
- Write a Python program to sort a list according to the second element in a sublist.
- Write a Python program to find the second largest number in a list using bubble sort.
- Write a Python program to sort a list according to the length of its elements.
- Write a Python program to find the union of two lists.
- Write a Python program to find the intersection of two lists.
- Write a Python program to print all odd-indexed elements of a list.
- Write a Python program to get the 4th element and the 4th element from the end of a tuple.
- Write a Python program to find the repeated items in a tuple.
- Write a Python program to check whether an element exists within a tuple.
- Write a Python program to unzip a list of tuples into individual lists.
- Write a Python program to replace the last value of tuples in a list.
Sample list:[(10, 20, 40), (40, 50, 60), (70, 80, 90)]
Expected output:[(10, 20, 100), (40, 50, 100), (70, 80, 100)]
- Write a Python program to remove empty tuples from a list of tuples.
Sample data:[(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
Expected output:[('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
- Write a Python program to convert a list of tuples into a dictionary.
- Write a Python program to find the three highest values of corresponding keys in a dictionary.
- Write a Python function to print the first n rows of Pascal's triangle.
- Write a Python function to create and print a list of squares of numbers between 1 and 30 (both included).
- Write a Python program to detect the number of local variables declared in a function.
- Write a Python program to invoke a given function after a specified number of milliseconds.
- Write a Python program to calculate the sum of a non-negative integer.
- Write a Python program to calculate the harmonic sum of n-1.
- Write a Python program to calculate the sum of positive integers in the sequence n + (n-2) + (n-4) + ... (until n-x ≤ 0).
- Write a Python program to find the greatest common divisor (GCD) of two integers using recursion.
- Implement any sorting algorithm using recursion.
- Write a Python program to replace all occurrences of 'a' with 'b' in a string. If 'a' is not present, print an appropriate message.
- Write a Python program to remove the nth index character from a non-empty string.
- Write a Python program to detect if two strings are anagrams.
- Write a Python program to form a new string where the first and last characters have been exchanged.
- Write a Python program to get the last part of a string before a specified character.
- Write a Python program to count the occurrences of each word in a given sentence.
- Write a Python function to insert a string in the middle of another string.
- Write a Python function to get a string made of the first three characters of a specified string. If the string length is less than 3, return the original string.
- Write a Python program to add a prefix text to all lines in a string.
- Write a Python program to convert a given string into a list of words.