0% found this document useful (0 votes)
50 views4 pages

Python Basics: Simple Programs Guide

Uploaded by

bhuwye
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

Python Basics: Simple Programs Guide

Uploaded by

bhuwye
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#[Link] print personal information like Name, Father’s Name, Class, School Name.

print("Name : ..........")
print("Father's Name : ...............")
print("Class : ...............")
print("School Name : ...............")

/*[Link] print the following patterns using multiple print commands-


*
**
***
****
*****

*/

print("*")
print("**")
print("***")
print("****")
print("*****")

#[Link] find square of number 7

Square=7*7
print(Square)

#[Link] find the sum of two numbers 15 and 20.

a=20
b=15
Sum=a+b
print(Sum)

#[Link] convert length given in kilometers into meters.

km=int(input("Enter value:"))
m=km*1000
print(m)

#[Link] print the table of 5 up to five terms.

for i in range(1,6):
print(5*i)

#[Link] calculate Simple Interest if the principle_amount = 2000 rate_of_interest =


4.5 time = 10

P=2000
R=4.5
T=10
SI=P*R*T/100
print(SI)

#[Link] calculate Area and Perimeter of a rectangle

L=int(input("enter value"))
B=int(input("enter value"))
Area=L*B
Perimeter=2*(L+B)
print(Area)
print(Perimeter)

#[Link] calculate Area of a triangle with Base and Height

Base=int(input("enter value:"))
Hieght=int(input("enter value:"))

Area=1/2*Base*Hieght
print(Area)

#[Link] calculating average marks of 3 subjects

S1=int(input("Enter Subject1 marks :"))


S2=int(input("Enter Subject2 marks :"))
S3=int(input("Enter Subject3 marks :"))
avg=(S1+S2+S3)/3
print("Average marks are :", avg)

#[Link] calculate discounted amount with discount %

CP=int(input("Enter value"))
D=int(input("Enter discount percentage"))
discount=CP/100*D
print("Discounted amount is ", discount)

#[Link] calculate Surface Area and Volume of a Cuboid

L=int(input("Enter value:"))
B=int(input("Enter value:"))
H=int(input("Enter value:"))

Area=2*(L*B+B*H+L*H)
print(Area)

#[Link] to check if a person can vote

Age=int(input("Enter age"))
if(Age>=18):
print("you are eligible to vote")
else :
print("you are not eligible to vote ")
'''[Link] check the grade of a [Link] as follows:
90+ - A
80-89 - B
70-79 - C
60-69 - D
50-59 - E
Below 50 - Fail''

p=int(input("Enter percentage"))
if(p>=90):
print("A Grade")
elif(p>=80 and p<=89):
print("B Grade")
elif(p>=70 and p<=79):
print("C Grade")
elif(p>=60 and p<=69):
print("D Grade")
elif(p>=50 and p<=59):
print("E Grade")
else:
print("Fail")

#[Link] a number and check if the number is positive, negative or zero and
display an appropriate message

n=int(input("Enter number"))
if(n>0):
print("It is positive number")
elif(n<0):
print("It is negative number")
else:
print("It is zero")

#[Link] print first 10 natural numbers

for i in range(1,11,1):
print(i)

#[Link] print first 10 even numbers

for i in range(2,21,2):
print(i)

#[Link] print odd numbers from 1 to n

n=int(input("Enter value:"))
for i in range(1,n,2):
print(i)

#[Link] print sum of first 10 natural numbers

Sum=0
for i in range(1,11,1):
Sum=Sum+i
print(Sum)

You might also like