Ads Top

Basic Python Programming questions to start learning Python

Basic Python Programs Solved for beginners. Make your first step in Python world with these programming questions. Solved python programs with explanation.

basic python programs crazy coding hub


Basic Python Programs Solved!

Here are the some of the selected python programs for the beginners to start learning Python and understand it's concept. Try to make these programs by yourself. These programs are based on topics like:

1. Program to calculate simple interest

Simple Interest = (Principle (amount) * Rate * Time) / 100
p = float(input("Enter amount: "))
r = float(input("Enter rate: "))
t = float(input("Enter time in years: "))
si = (p*r*t)/100 
print("Simple interest: ",si)

2. Program to convert celsius into fahrenheit

Celsius and Fahrenheit are the units of Temperature and are convertible to each other as:
F = ( 9/5 × C ) + 32
celsius = float(input('Enter temperature in Celsius: '))
fahrenheit = (celsius * 1.8) + 32
print('%0.1f Celsius is equal to %0.1f degree Fahrenheit'%(celsius,fahrenheit))

3. Program to find factorial of a number

Factorial of  0 and 1 is 1, whereas,
5! = 5 × 4 × 3 × 2 × 1 = 120
num = int(input("Enter a number: "))
factorial = 1

#check if the number is negative, positive or zero
if num < 0:
   print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
   print("The factorial of 0 is 1")
else:
   for i in range(1,num + 1):
       factorial = factorial*i
   print("The factorial of",num,"is",factorial)

4.Program to find area of the circle

Area  of the circle = Ï€r²    ; r = radius of circle
PI = 3.142
r = float(input("Enter radius of circle: "))
area = r**2;
print("Area is: ",area)
5. Program to check odd even numbers

All multiples of 2 are even numbers and others are odd.
For e.g. 1 is odd and 2 is even.
num = int(input("Enter a number: "))
if (num % 2) == 0:
   print("{0} is Even".format(num))
else:
   print("{0} is Odd".format(num))

No comments:

Powered by Blogger.