Skip to content

surajkiron/PythonAssignments

Repository files navigation

PythonClass

Assignment1

  1. Design and implement a program a) To prompt the user for hours ad rate per hour to compute gross pay b) To print the python version that is used.

  2. Design and implement a python program to get a new string from a give string where ‘is’ has been added to the front. If the string already begins with “is” the return the string unchanged.

  3. Design and implement a program that evaluates the value of the quadratic equation ax2+bx+c by prompting the user to enter the values of a,b,c and x.

  4. Write a Python program to check a triangle is equilateral, isosceles or scalene.

  5. design and implement a python program that accepts an integer n and computes the value of n+nn+nnn

  6. Design and implement a python program to test whether a number is within 100 of 1000 0r 2000.

  7. Write a program that sums a series of (positive) integers entered by the user, excluding all numbers that are greater than 100.

  8. Write a python program that asks the user how many coins of various types they have, and then print the total amount of money in rupees.

  9. Write a Python program to get the Fibonacci series between 0 to 50.

  10. Write a python program to check for validity of the password using if statement.

  11. Write a Python program in which a student enters the number of college credits earned. If the number of credits is greater than 90, 'Senior Status' is displayed; if greater than 60, 'Junior Status' is displayed; if greater than 30, 'Sophomore Status' is displayed; else, 'Freshman Status' is displayed.

    1. Design and implement a program to count the number of individual characters in a string. Sample string:”yahoo.com” Result:{‘0’:3,’y’:1,’.’:1,’a’:1,’h’:1,’m’:1,’c’:1}
  12. Write a program that sums a series of integers entered by the user, excluding all numbers that are greater than 100.

  13. Write a Python program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Test Data : Rows = 3, Columns = 4 Expected Result : [[0, 0, 0, 0], [0, 1, 2, 3], [0, 2, 4, 6]]

  14. Write a Python program to find numbers between 100 and 400 (both included) where each digit of a number is an odd number. The numbers obtained should be printed in a comma-separated sequence

  15. Write a Python program that accepts a word from the user and reverse it.

  16. Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between 1500 and 2700 (both included).

  17. Write a Python program to construct the following pattern, using a nested for loop.






  1. Write a Python program that allows the user to enter a four-digit binary number and displays its value in base 10. Each binary digit should be entered one per line, starting with the leftmost digit , as shown below. Enter leftmost digit: 1 Enter the next digit: 0 Enter the next digit: 0 Enter the next digit: 1
    The value is 9

  2. Write a Python program to check the validity of password input by users. Go to the editor Validation : At least 1 letter between [a-z] and 1 letter between [A-Z]. At least 1 number between [0-9]. At least 1 character from [$#@]. Minimum length 6 characters. Maximum length 16 characters

  3. Write a Python program to find numbers between 100 and 400 (both included) where each digit of a number is an even number. The numbers obtained should be printed in a comma-separated sequence

  4. Write a Python program that accepts a string and calculate the number of digits and letters. Sample Data : Python 3.2 Expected Output : Letters 6  Digits 2

  5. a) Write a Python program to convert temperatures to and from celsius, fahrenheit. [ Formula : c/5 = f-32/9 [ where c = temperature in celsius and f = temperature in fahrenheit ] Expected Output : 60°C is 140 in Fahrenheit.45°F is 7 in Celsius

  6. Write a Python program to count the number of even and odd numbers from a series of numbers

  7. Write a Python program to check a string represent an integer or not.  Expected Output: Input a string: Python
    The string is not an integer.

  8. Write a Python program to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers

  9. Write a Python program to convert a decimal number to binary number.

  10. Write a Python program to create the multiplication table (from 1 to 10) of a number.

  11. Write a Python program to construct the following pattern, using a nested loop number Expected Output: 1 22 333 4444 55555 666666 7777777

  12. Write a Python program to get a single string from two given strings, separated by a space and swap the first two characters of each string. Sample String : 'abc', 'xyz' Expected Result : 'xyc abz'

  13. Write a Python program to count the number of even and odd numbers from a series of numbers.

  14. Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself.  Sample String : 'restart' Expected Result : 'resta$t'


Assignment 2

  1. Design and implement a python program to get a string made of the first 2 and the last 2 chars from a given string. If the string length is less than 2 return instead the empty string.

  2. Design and implement a python program to count the number 4 in a given list.

  3. Design and implement a python program to generate and print list except the first 5 elements, where the values are square of numbers between 1 and 30(both included).

  4. Design and implement a python function that takes two lists and returns true if they have at least one common.

  5. Design and implement a python program to find the list of words that are no longer than n from a given list of words.

  6. Design and implement a program to count the number of vowels present in a given list of strings using ‘in’ or ‘not in’ operator.

  7. Write a function char_freq() that takes a string and builds a frequency listing of the characters contained in it. Represent the frequency listing as a python dictionary.

  8. Design and implement a program to count the number of vowels present in a given list of strings using ‘in’ or ‘not in’ operator.

  9. Write a function called dict_intersect that takes two dictionaries as arguments and returns a dictionary that contains only the key/value pairs found in both of the original dictionaries.

  10. Write a Python program to remove duplicates from a list.

  11. Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String : 'The quick Brown Fox' Expected Output : No. of Upper case characters : 3 No. of Lower case Characters : 13

  12. Write a Python function that takes a list and returns a new list with unique elements of the first list Sample List : [1,2,3,3,3,3,4,5] Unique List : [1, 2, 3, 4, 5]

  13. Write a Python function that takes a number as a parameter and check the number is prime or not

  14. Write a Python program to check whether a list contains a sublist.

  15. Define a function which can generate a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys. The function should just print the keys only.

    1. Write a program which count and print the numbers of each character in a string input by console. Example: If the following string is given as input to the program: abcdeabc Then, the output of the program should be: a,2 c,2 b,2 e,1 d,1
  16. Write a Python program to check whether a list contains a sublist.

  17. Write a program to generate and print another tuple whose values are even numbers in the given tuple (1,2,3,4,5,6,7,8,9,10).

  18. Write a function called count_values that takes a single dictionary as an argument and returns the number of distinct values it contains. Given the input {‘red’:1,’green’:1,’blue’:2}, for example it should return 2.

  19. Write a Python program to generate and print a list except for the first 5 elements, where the values are square of numbers between 1 and 30 (both included)

  20. Write a Python Program using function to Sort Words in Alphabetic Order

  21. Write a program to read details of the student(name as string ,usn as int ,semester as int) in comma separated values from the keyboard and split & typecast the input based on comma delimiter and store it in list before displaying it.


Assignment3

1.Design and implement a program to create and read the contents of a file that resembles a phone book with names and phone numbers. Now alphabetically sort the phonebook.

2.Design and implement a python program to create and read a file, store it in a list of lists, with each inner list containing the product name, net weight and the unit price of a product, by name shopper_list.txt that contains the name, weight and the unit price of the products in supermarket: Wheat flour 1kg 25.00 Rice flour 1kg 40.00

3.Design and implement a program to open a file and count the occurrences of each letter in the file.

4.Design and implement a program that reads a file and outputs a new file with the lines in a sorted order.

5.Write a program segment that reads a text file named original_text, and displays how many times the letter ‘c’ occurs.

6.Write a Python program to count the number of lines in a text file.

7.Write a Python program to get current time in milliseconds in Python using the time module.

8.Write a Python program to generate random even integers in a specific numerical range using the random module

9.Write a function that takes a list of integers, and returns the number of primes in the list.

10.Write a program that reads a file and writes out a new file with the lines in reversed order (i.e. the first line in the old file becomes the last one in the new file.)

11.Write a Python program to generate a series of unique random numbers using the random module.

12.Write a python program to find the longest words..

13.Write a python program to produce a list of unique element from the input list which contains duplicates of the elements in the list Expected output: Input list: [1,2,3,3,3,3,5,6,9,9] Output list: [1,2,3,5,6,9]

14.Write a program that reads a file and prints only those lines that contain the substring snake.

15.Write a Python program to get a single random element from a specified string.

16.Write a Python program to get a single random element from a specified string using the random module.

17.Write a Python program to print a string five times, delay three seconds using the time module.

18.Write a Python program to count the frequency of words in a file.

19.Design and implement a program that reads a file and prints only those lines that contain the substring “msrit”


Assignment 4

  1. a) Design and implement a python class named circle constructed by a radius and two methods which will compute the area and the perimeter of the circle. b) Implement a class called country, which represents a country with a name, a population, and an area. Define country with a constructor that has four parameters: country, name, population and its area.
  2. Design and implement a python program that describes the class rocket with its attributes as x and y values. Create a fleet of 5 rockets and display its x and y positions using suitable methods inside the class.
  3. Design and implement a program with class student having two methods with name set () but accepts different number of arguments. Include necessary methods to display the student details.
  4. Write a function named readposint that uses the input dialog to prompt the user for a positive integer and then checks the input to confirm that it meets the requirements. It should be able to handle inputs that cannot be converted to int, as well as negative ints.
  5. Design and implement a program that accepts two numbers separated by comma and performs a division of two numbers. Include exceptions for the necessary conditions with finally clause.
  6. Write a Python class to find the three elements that sum to zero from a set of n real numbers.
  7. Write an interactive program to compute the square root of a number. The input values must be tested for validity. if it is negative the user defined method MySqrt() should raise an exception.
  8. Write a Python class to implement pow(x, n)
  9. Write a Python class to find a pair of elements (indices of the two numbers) from a given array whose sum equals a specific target number.
  10. Write a Python class to reverse a string word by word. Input string : 'hello .py' Expected Output : '.py hello'
  11. Write a Python class to get all possible unique subsets from a set of distinct integers
  12. Write a Python class which has two methods get_String and print_String. get_String accept a string from the user and print_String print the string in upper case.
  13. Write a Python class to convert a roman numeral to an integer
  14. Write a Python class named Rectangle constructed by a length and width and a method which will compute the area of a rectangle
  15. Design and implement a program that accepts two numbers separated by comma and performs a division of two numbers. Include exceptions for the necessary conditions with finally clause.
  16. Write a Python class to find a pair of elements (indices of the two numbers) from a given array whose sum equals a specific target number Input: numbers= [10,20,10,40,50,60,70], target=50 Output: 3, 4

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published