Docsity

Python problems questions, Exercises of Computer Science

Toggle sidebar
bg1
Python Practice Problems
1. User will input (3ages).Find the oldest one
2. Write a program that will convert celsius value to fahrenheit
3. User will input (2numbers).Write a program to swap the numbers
4. Write a program that will give you the sum of 3 digits
5. Write a program that will reverse a four digit number.Also it checks
whether the reverse is true.
6. Write a program that will tell whether the number entered by the
user is odd or even.
7. Write a program that will tell whether the given year is a leap year
or not.
8. Write a program to find the euclidean distance between two
coordinates.
9. Write a program that take a user inputr of three angles and will
find out whether it can form a triangle or not.
10. Write a program that will take user input of cost price and selling
price and determines whether its a loss or a profit
11. Write a program to find the simple interest when the value of
principle,rate of interest and time period is given.
12. Write a program to find the volume of the cylinder. Also find the
cost when ,when the cost of 1litre milk is 40Rs.
13. Write a program that will tell whether the given number is divisible
by 3 & 6.
14. https://practice.geeksforgeeks.org/problems/angle-between-hou
r-and-minute-hand0545/1?page=2&category[]=Mathematical&c
ategory[]=Numbers&category[]=number-theory&sortBy=submis
sions
pf3
pf4
pf5

Partial preview of the text

Download Python problems questions and more Exercises Computer Science in PDF only on Docsity!

Python Practice Problems

1. User will input (3ages).Find the oldest one

2. Write a program that will convert celsius value to fahrenheit

3. User will input (2numbers).Write a program to swap the numbers

4. Write a program that will give you the sum of 3 digits

5. Write a program that will reverse a four digit number.Also it checks

whether the reverse is true.

6. Write a program that will tell whether the number entered by the

user is odd or even.

7. Write a program that will tell whether the given year is a leap year

or not.

8. Write a program to find the euclidean distance between two

coordinates.

9. Write a program that take a user inputr of three angles and will

find out whether it can form a triangle or not.

10. Write a program that will take user input of cost price and selling

price and determines whether its a loss or a profit

11. Write a program to find the simple interest when the value of

principle,rate of interest and time period is given.

12. Write a program to find the volume of the cylinder. Also find the

cost when ,when the cost of 1litre milk is 40Rs.

13. Write a program that will tell whether the given number is divisible

by 3 & 6.

14. https://practice.geeksforgeeks.org/problems/angle-between-hou

r-and-minute-hand0545/1?page=2&category[]=Mathematical&c

ategory[]=Numbers&category[]=number-theory&sortBy=submis

sions

15. https://practice.geeksforgeeks.org/problems/overlapping-rectan

gles1924/1?page=3&category[]=Mathematical&category[]=Numb

ers&category[]=number-theory&sortBy=submissions

16. Write a program that will determine weather when the value of

temperature and humidity is provided by the user.

TEMPERATURE(C) HUMIDITY(%) WEATHER

>= 30 >=90 Hot and Humid

>= 30 < 90 Hot

<30 >= 90 Cool and Humid

<30 <90 Cool

17. Write a program that will take three digits from the user and add

the square of each digit.

18. Write a program that will check whether the number is armstrong

number or not.

19. Write a program that will take user input of (4 digits number) and

check whether the number is narcissist number or not.

20. Write a program that will give you the in hand salary after

deduction of HRA(10%),DA(5%),PF(3%), and tax(if salary is between

5-10 lakh–10%),(11-20lakh–20%),(20< _ – 30%)(0-1lakh print k).

21. Write a menu driven program - 1.cm to ft 2.kl to miles 3.usd to inr

4.exit

22.Write a program that will tell the number of dogs and chicken are

there when the user will provide the value of total heads and legs.

23.Write a program that will swap numbers

  1. Write a program to find the sum of first n numbers, where n will be provided by the user. Eg if the user provides n=10 the output should be

  2. Write a program to print the following pattern

    **

    **

  3. Write a program to print the following pattern

* * * * * * * * *
  1. Write a program to print the following pattern 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1
  2. Write a program to print the following pattern 1 2 3 4 5 6 7 8 9 10
  3. Write a program to calculate the sum of the following series till the nth term 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n! n will be provided by the user

47. Write a Python Program to Find the Sum of the Series till the nth term:

1 + x^2/2 + x^3/3 + … x^n/n n will be provided by the user

48.The natural logarithm can be approximated by the following series.

If x is input through the keyboard, write a program to calculate the sum of the first seven terms of this series.

  1. Write a program that keeps on accepting a number from the user until the user enters Zero. Display the sum and average of all the numbers.
  2. Write a program that accepts 2 numbers from the user a numerator and a denominator and then simplifies it Eg if the num = 5, den = 15 the answer should be ⅓ Eg if the num = 6, den = 9 the answer should be ⅔
  3. Find the length of a given string without using the len() function.
  4. Extract username from a given email. Eg if the email is [email protected] then the username should be nitish24singh
  5. Count the frequency of a particular character in a provided string. Eg 'hello how are you' is the string, the frequency of h in this string is 2.
  6. Find the index position of a particular character in another string.
  7. Count the number of vowels in a string provided by the user. 56.Write a program which can remove a particular character from a string.
  8. Write a program that can check whether a given string is palindrome or not.
  1. Write a program to perform matrix multiplication on 2 matrices
  2. Write a program that can sort a given unsorted list. Dont use any built in function for sorting.
  3. Write a program that can find the most used word in a bollywood song
  4. Assume a list with numbers from 1 to 10 and then convert it into a dictionary where the key would be the numbers of the list and the values would be the square of those numbers.
  5. Write a program to merge two given dictionary
  6. Write a program to swap the key value pair for max and min values Eg if the dict is like this {‘a’:1,’b’:2,’c’:3} Output should be {a:3,b:2,c:1}
  7. Write a program to find histogram of a given set of numbers. Take bin size from user. Print the result in the form of a dictionary.
  8. Write a function that accepts a string and returns the number of upper case chars and lower case chars as a dictionary 84.Write a function that accepts a list of strings and performs Bag of words and convert it to numerical vectors. https://en.wikipedia.org/wiki/Bag-of-words_model
  9. Write a dummy program that can perform login and registration using a menu driven program 86.Write a program that accepts neighbors(set of 2D co-ordinates) and a point(single 2D co-ordinate) and tells nearest neighbor(in terms of euclidean distance)
  10. Write a function that accepts a number and returns it’s factorial. You can not use any loop