Skip to content

SurfyPenguin/python-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Lab Assignments

Repository to store practice lab assignments.

Structure

The repository contains 12 weeks of assignments, each consisting of 4-7 simple exercises to build foundational knowledge of Python.

Problem List

Week 1

  1. Write a Python program to display the current date and time.
  2. Write a Python program to get the Python version you are using.
  3. Write a Python program that accepts an integer (n) and computes the value of n + nn + nnn.
  4. Write a Python program to read and print various types of variables.
  5. Write a Python program to print the calendar of a given month and year.

Week 2

  1. Write a Python program to find the square root.
  2. Write a Python program to calculate the area and perimeter of a triangle and a circle.
  3. Write a Python program to solve a quadratic equation.
  4. Write a Python program to swap two variables.
  5. Write a Python program to convert kilometers to miles.
  6. Write a Python program to convert Celsius to Fahrenheit.

Week 3

  1. Write a Python program to determine whether a given number is even or odd.
  2. 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.
  3. Write a Python program to test whether a number is within 100, 1000, or 2000.
  4. Write a Python program to calculate the sum of three given numbers. If the values are equal, return three times their sum.
  5. Write a Python program to find the factorial of a number.
  6. Write a Python program to print the maximum of three numbers.
  7. Write a Python program to determine whether a given year is a leap year.

Week 4

  1. 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.
  2. Write a Python program to check whether a number is divisible by both 5 and 11.
  3. Write a Python program to check whether a character is an alphabet.
  4. Write a Python program to input any character and check whether it is an alphabet, digit, or special character.
  5. Write a Python program to check whether a character is an uppercase or lowercase alphabet.
  6. Write a Python program to input a week number and print the corresponding weekday.
  7. Write a Python program to count the total number of notes in a given amount.

Week 5

  1. Write a Python program to print all natural numbers from 1 to n using a while loop.
  2. Write a Python program to find the sum of all odd numbers between 1 and n.
  3. Write a Python program to count the number of digits in a number.
  4. Write a Python program to find the first and last digits of a number.
  5. Write a Python program to calculate the sum of digits of a number.
  6. Write a Python program to enter a number and print its reverse.

Week 6

  1. Write a Python program to check whether a number is a palindrome.
  2. Write a Python program to find the frequency of each digit in a given integer.
  3. Write a Python program to print all ASCII characters with their values.
  4. Write a Python program to find all factors of a number.
  5. Write a Python program to calculate the factorial of a number.
  6. Write a Python program to print all prime numbers between 1 and n.
  7. Write a Python program to check whether a number is an Armstrong number, strong number, prime number, perfect number, or magic number.
  8. Write a Python program to print the Fibonacci series up to n terms.

Week 7

  1. Write a Python program to find the largest number in a list.
  2. Write a Python program to find the second largest number in a list.
  3. Write a Python program to separate even and odd elements in a list into two different lists.
  4. Write a Python program to merge two lists and sort them.
  5. Write a Python program to sort a list according to the second element in a sublist.
  6. Write a Python program to find the second largest number in a list using bubble sort.
  7. Write a Python program to sort a list according to the length of its elements.
  8. Write a Python program to find the union of two lists.
  9. Write a Python program to find the intersection of two lists.
  10. Write a Python program to print all odd-indexed elements of a list.

Week 8

  1. Write a Python program to get the 4th element and the 4th element from the end of a tuple.
  2. Write a Python program to find the repeated items in a tuple.
  3. Write a Python program to check whether an element exists within a tuple.
  4. Write a Python program to unzip a list of tuples into individual lists.
  5. 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)]
  6. 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')]
  7. Write a Python program to convert a list of tuples into a dictionary.
  8. Write a Python program to find the three highest values of corresponding keys in a dictionary.

Week 9

  1. Write a Python function to print the first n rows of Pascal's triangle.
  2. Write a Python function to create and print a list of squares of numbers between 1 and 30 (both included).
  3. Write a Python program to detect the number of local variables declared in a function.
  4. Write a Python program to invoke a given function after a specified number of milliseconds.
  5. Write a Python program to calculate the sum of a non-negative integer.

Week 10

  1. Write a Python program to calculate the harmonic sum of n-1.
  2. Write a Python program to calculate the sum of positive integers in the sequence n + (n-2) + (n-4) + ... (until n-x ≤ 0).
  3. Write a Python program to find the greatest common divisor (GCD) of two integers using recursion.
  4. Implement any sorting algorithm using recursion.

Week 11

  1. Write a Python program to replace all occurrences of 'a' with 'b' in a string. If 'a' is not present, print an appropriate message.
  2. Write a Python program to remove the nth index character from a non-empty string.
  3. Write a Python program to detect if two strings are anagrams.
  4. Write a Python program to form a new string where the first and last characters have been exchanged.

Week 12

  1. Write a Python program to get the last part of a string before a specified character.
  2. Write a Python program to count the occurrences of each word in a given sentence.
  3. Write a Python function to insert a string in the middle of another string.
  4. 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.
  5. Write a Python program to add a prefix text to all lines in a string.
  6. Write a Python program to convert a given string into a list of words.

About

Repository to store practice lab assignments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages