Skip to content

I created the Python Practice Questions Project by solving a collection of advanced-level Python problems to strengthen core programming skills. This project covers topics like data structures, algorithms, file handling, and problem-solving techniques.

Notifications You must be signed in to change notification settings

Abdullah321Umar/Python-Practice-Questions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Python-Practice-Questions

  1. Write a program that will find all such numbers divisible by 7 but not a multiple of 5, between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-separated sequence on a single line.
  2. Write a program that can compute the factorial of a given number. The results should be printed in a comma-separated sequence on a single line.Suppose the following input is supplied to the program: 8 Then, the output should be: 40320.
  3. With a given integral number n, write a program to generate a dictionary that contains (i, i*i), an integral number between 1 and n (both included). Then, the program should print the dictionary. Suppose the following input is supplied to the program:8 Then, the output should be: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}.
  4. Write a program that accepts a sequence of comma-separated numbers from the console and generates a listand a tuple that contains every number. Suppose the following input issupplied to the program: 34,67,55,33,12,98 Then, the output should be:['34', '67', '55', '33', '12', '98'] ('34', '67', '55', '33', '12', '98').
  5. Define a class that has at least two methods: getString:to get a string from the console input printString: to print the string in upper case. Also, please include a simple test function to test the class methods.
  6. A program that calculates and prints the value according to the given formula:Q = Square root of [(2 * C * D)/H] Following are the fixed values of C and H: C is 50. H is 30. D is the variable whose values should be input to your program in a comma-separated sequence. Example: Let us assume the following comma-separated input sequence is given to the program: 100,150,180 The output of the program should be 18,22,24.
  7. Program which takes 2 digits, X, Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Note: i=0,1.., X-1; j=0,1,¡Y-1. Example: Suppose the following inputs are given to the program: 3,5 Then, the output of the program should be: [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]].
  8. The program accepts a comma-separated sequence of words as input and prints the words in a comma-separated sequence after sorting them alphabetically. Suppose the following input is supplied to the program: without, hello, bag, world. Then, the output should be: bag, hello, without, world.
  9. The program accepts a sequence of lines as input and prints the lines after making all characters in the sentence capitalized. Suppose the following input is supplied to the program: Hello world Practice makes perfect. Then, the output should be: HELLO WORLD PRACTICE MAKES PERFECT.
  10. A program that accepts a sequence of whitespace-separated words as input and prints the words after removing all duplicate wordsand sorting them alphanumerically. Suppose the following input is supplied to the program: hello world and practice make perfect and hello world again.Then, the output should be: again and hello make perfect practice world.
  11. A program that accepts a sequence of comma-separated 4-digit binary numbers as its input and then checks whether they are divisible by 5 or not. The numbers that are divisible by 5 are to be printed in a comma-separated sequence.Example: 0100,0011,1010,1001 Then the output should be: 1010 Notes: Assume the data is input by the console.
  12. A program that will find all such numbers between 1000 and 3000 (both included) such that each digit of the number is an even number. The numbers obtained should be printed in a comma-separated sequence on a single line.
  13. A program that accepts a sentence and calculates the number of letters and digits. Suppose the following input is supplied to the program: hello world! 123 Then, the output should be LETTERS 10 DIGITS 3.
  14. A program that accepts a sentence and calculates the number of upper case letters and lower case letters. Suppose the following wvnvewnnninputefwcnwev is supplied to the program: Hello world! Then, the output should be: UPPER CASE 1 LOWER CASE 9.
  15. A program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a. Suppose the following input is supplied to the program: 9 Then, the output should be: 11106.
  16. Use a list comprehension to square each odd number in a list. The list is input as a sequence of comma-separated numbers.Suppose the following input is supplied to the program: 1,2,3,4,5,6,7,8,9. Then, the outputshould be 1,3,5,7,9.
  17. A program that computes the net amount of a bank account based on a transaction log from console input.The transaction log format is shown as follows: D 100 W 200. D means a deposit, while W means withdrawal. Suppose the following input is supplied to the program: D 300 D 300 W 200 D 100 Then, the output should be: 500.
  18. With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155],write a program to make a list whose elements are the intersection of the above-given lists.AA.
  19. A program to compute 1/2+2/3+3/4+...+n/n+1 with a given n input by console (n>0).If the following n is provided as input to the program: 5. Then, the output of the program should be: 3.55.
  20. With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], write a program to make a list whose elements are the intersection of the above-given lists.
  21. A program that counts and prints each character's numbers in a string input by the console. Example: If the following string is given as input to the program: abcdefgabc Then, the output of the program should be: a,2 c,2 b,2 e,1 d,1 g,1 f,1.
  22. Write a function to determine if a given year is a leap year in the Gregorian calendar, based on these rules:
  • Divisible by 4: Leap year
  • Divisible by 100: Not a leap year, unless also divisible by 400
  • Input
  • An integer y where 1900≤y≤2050
  • Output
  • Return True if the year is a leap year, otherwise, return False.
  1. Given the scores of participants in a sports event, find the second-highest (runner-up) score.
  • Input
  • The first line contains an integer n (the number of scores).
  • The second line contains n space-separated integers, representing the scores.
  • Output
  • Print the second-highest score.
  • Input: 5
  • 2 3 6 6 5
  • Output: 5
  1. Given a string, swap the case of each letter: convert lowercase letters to uppercase, and uppercase letters to lowercase.
  • Input A single string S.
  • Output The modified string with swapped cases.
  1. You are given records of N students, each containing their name and marks in three subjects (Maths, Physics, Chemistry). Save this data in a dictionary, then output the average marks for a specific student, rounded to two decimal places.
  • Input
  • The first line contains an integer N (number of students).
  • The next N lines each contain a student's name and their three marks.
  • The final line contains the name of a student for whom the average needs to be calculated.
  • Output
  • Print the average marks of the specified student, rounded to two decimal places.

About

I created the Python Practice Questions Project by solving a collection of advanced-level Python problems to strengthen core programming skills. This project covers topics like data structures, algorithms, file handling, and problem-solving techniques.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published