Practice Programs

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

INTRODUCTION TO PYTHON

BASIC PROGRAMMING PRACTICE QUESTIONS


Question 1 write a Python Program to Check if a Number is Positive, Negative or 0

Solution:

In [ ]:

Question 2: A leap year is exactly divisible by 4 except for century years (years ending with 00).
The century year is a leap year only if it is perfectly divisible by 400. For example,

2017 is not a leap year


1900 is a not leap year
2012 is a leap year
2000 is a leap year write a Python Program to Check if the year assigned to a variable 'year'
is a Leap Year.

Solution:

In [ ]:

Question 3: A positive integer greater than 1 which has no other factors except 1 and the
number itself is called a prime number. 2, 3, 5, 7 etc. are prime numbers as they do not have any
other factors. But 6 is not prime (it is composite) since, 2 x 3 = 6 . Write a Python Program to
Check Prime Number.

Solution:

In [ ]:

Question 4: Write a Pyhton Program to calculate simple interest on a given investment at


specific rate of interest.

Solution:

In [ ]:

Question 5: Write a Python program to calculate compound amount on a given investment at a


specific rate of interest

Solution:
In [ ]:

Question 6: Write a Python program to calculate compound interest on a given investment at a


specific rate of interest

Solution:

In [ ]:

Question 7: Write a program to find the sum of digits of a number using the for loop.

Solution

In [ ]:

Question 8 Write a Python program that takes a specified number of integers as input, stores
them in a list, and then calculates the arithmetic mean (average) of the given numbers.

Solution

In [ ]:

Question 9 Write a Python program that takes a specified number of integers as input, stores
them in a list, and then calculates the median of the given numbers.

Solution

In [ ]:

Question 10 Write a Python program that takes a specified number of integers as input, stores
them in a list, and then calculates the variance of the given numbers.

Solution

In [ ]:

Question 11: Write a Python program that prompts the user to enter a series of cash flows,
adds them into a list, and then calculates the present values and the Net Present Value (NPV) of
the cash flows.

Solution

In [ ]:

Question 12: Basic Statistical analysis we will create a program in which user will have to input
some numbers, once the input is complete, the user has to enter "e". the program will

sort the given numbers


find the sum of the numbers
find the number of values entered
find the maximum value
find the minimum value
find the mean
find the median

Solution

In [ ]:

You might also like