Skip to content

rutuja1302/PythonPrograms

Repository files navigation

PythonPrograms

Basic Projects in the field of python

  1. Prime or not - This program will take a number as an input & tell if the number is a prime number or not.
  2. User input & Replace String template "Hello <>, How are you?" - I/P -> Take username as input.Ensure username has min 3characters O/P -> Replace <> with proper name and print the string.
  3. Multiplication table - Take a number as an input and print its multiplication table upto 10.
  4. Factorial of a number - This program will take an integer as an input and print it's factorial.
  5. Rock Paper Scissors - Rock paper scissors game between two players(player Vs. computer).
  6. Leap Year - Take a year as an input, ensure it is a 4 digit number. Determine if it is a leap year and print it.
  7. Flip Coin and print percentage of Heads and Tails - I/P -> The number of times to flip coin. Ensure it is positive integer. Logic -> Use random function to get value between 1 to 10. If <5 then tails or heads. O/P -> Percentage of heads & tails.
  8. List Comprehensions - You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n. Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n. Here, 0<=i<=x ,0<=j<=y, 0<=k<=z.
  9. Reverse a string - Enter a string & the program will reverse it and print it out.
  10. Runner-Up Score - Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given n scores. Store them in a list and find the score of the runner-up.
  11. Calculate Days - Consider a team meeting on the first friday of every month(of year 2020). Write a program to figure out what days that would be each month using calendar module.
  12. Anagram detection - Check if two strings are anagram or not. (Anagram example: fried & fired)
  13. Nested Lists - Given the names and grades for each student in a class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.
  14. Count Vowels - Enter a string and the program counts the number of vowels in the text.
  15. The Age Calculator - This program will determine the age or interval between two dates. The calculated age will be displayed in years.
  16. Finding the percentage - The provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average of the marks array for the student name provided, showing 2 places after the decimal.
  17. Lists Commands- Initialize your list and read in the value of n followed by n lines of commands where each command will be of the types(insert, print, remove,append, sort, pop, reverse). Iterate through each command in order and perform the corresponding operation on your list.
  18. Tuples - Given an integer, n, and n space-separated integers as input, create a tuple,t, of those n integers. Then compute and print the result of hash(t).
  19. Swap Cases - You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa.
  20. Mutations - We have seen that lists are mutable (they can be changed), and tuples are immutable (they cannot be changed). You are given an immutable string, and you want to make changes to it. For example, Given i/p string: Food, Change string[0]='G', o/p: Good.
  21. Find a String - User input will be a string & a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right.
  22. Pig Latin - A secret language formed from english by transferring the initial consonant to the end of the word and 'ay' is affixed to it. If the word starts with an vowel then 'way' is affixed at the end of the word. Eg: food becomes oodfay & ice becomes iceway.
  23. Password Generator - This program will take password length as an input and provide a new password with random alphabets, numbers, special characters combination.
  24. Credit Card Validator - Takes in a credit card number from a common credit card vendor(Visa, MasterCard, American Express, Discoverer) & validates it to make sure that it is a valid number(Luhn's algorithm).
  25. Fibonacci Sequence - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number.
  26. Harmonic Number - Take a number N as input, ensure N != 0, compute 1+1/2+1/3+...+1/N & print the Nth Harmonic value.
  27. Pangrams - Pangrams are sentences constructed by using every letter of the alphabet atleast once. Given a string as an input, determine whether it is a pangram string or not.
  28. Designer Door Mat - Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications: Mat size must be N X M(N is an odd natural number, and M is 3 times N), The design should have 'WELCOME' written in the center, The design pattern should only use |, . and - characters.
  29. Happy number - Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1, or it loops endlessly in a cycle which does not include 1.
  30. Hangman Game - This is version of the classic letter guessing game called Hangman. User will be shown a set of blank letters that match a word and user have to guess what these letters are to reveal the hidden word. If the user guesses a wrong letter then the program hangs the man otherwise the user wins!
  31. Fortune Cookie teller - This program will simply tell user's fortune for the day. These fortunes will be stored in an array of Strings, use random class to generate a random number.
  32. Text Wrap - You are given a string S and width w.Your task is to wrap the string into a paragraph of width w.
  33. Capitalize - You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck.
  34. Alphabet Rangoli - You are given an integer, N. Your task is to print an alphabet rangoli of size . (Rangoli is a form of Indian folk art based on creation of patterns.)
  35. Encryption and Decryption - Encryption is the process of converting electronic data into another equivalent form, called “ciphertext” that cannot be easily understood by anybody except the authorized personnel. Whereas decryption is the reverse process of encryption. We will create 2 simple programs, first program will encrypt the given text and second will decrypt the code into the text message.
  36. Unit Converter(temp, length, mass, angle)- Converts various units between one another. The user enters the type of unit being entered, the type of unit they want to convert to & then the value. The program will then make the conversion.
  37. Power of 2 - This program takes a command line argumemt N and prints the table of the powers of 2 that are less than or equal to 2^N. Take power value N as an input and print the power table as an input.
  38. Prime Factorization Calculator - This interactive program will take a number N from the user and return all the prime factors of that number.
  39. Phone a friend - Given n names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each name queried, print the associated entry from your phone book on a new line in the form name=phoneNumber; if an entry for is not found, print Not found instead. Note: Your phone book should be a Dictionary/Map/HashMap data structure.
  40. Large Small DIfference - Write a program to return the difference between the largest and smallest numbers from an array of positive integers.(TechMahindra'20)