0% found this document useful (0 votes)
80 views15 pages

Phython Project Class 11th

COPY GUYZZZ ENJOY : )

Uploaded by

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

Phython Project Class 11th

COPY GUYZZZ ENJOY : )

Uploaded by

avditrajpoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

(1) Python program to create number

variables, print their types and values

# Python code to create number variables,


# print types and values

# creating number variables and assigning values


a = 10 # integer
b = 10.23 # float
c = 10+2j # complex

# printing types
print("type(a): ", type(a))
print("type(b): ", type(b))
print("type(c): ", type(c))

# printing values
print("value of a: ", a)
print("value of b: ", b)
print("value of c: ", c)

Output
2)Python program to define an integer
value and print it

# Python program to define an


# integer value and print it

# declare and assign an integer value


num = 10

# print num
print "num =",num
# print using format
print "num = {0}".format(num)

# assign another value


num = 100

# print num
print "num =",num
# print using format
print "num = {0}".format(num)

Output

3)Python program for adding two


given integers
# input two numbers: value of a and b
a = int(input("Enter A: "))
b = int(input("Enter B: "))

# find sum of a and b and assign to c


c = a+b

# print sum (c)


print("Sum: ",c)

Output

4)Python Arithmetic Operators


Example
# Python program to demonstrate the
# example of arithmetic operators

a = 10
b = 3

# addition
result = a+b
print("a+b :", result)

# subtraction
result = a-b
print("a-b :", result)

# division
result = a/b
print("a/b :", result)

# modulus
result = a%b
print("a%b :", result)

# exponent
result = a**b
print("a**b :", result)

# floor division
result = a//b
print("a//b :", result)

# updating the values of a & b


a = -10
b = 3
print("a:", a, "b:", b)
result = a//b
print("a//b :", result)

Output

5) Python program to print


maximum number using if-else
ladder

# Python program to return maximum of two numbers


# Getting input from user
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))

# printing the maximum value


if(num1 > num2):
print(num1, "is greater")
elif(num1 < num2):
print(num2, "is greater")
else:
print("Both are equal")

Output

6) Program to find area and perimeter


of a circle

# Python program to find the


# area and perimeter of circle in python

# Initialising the value of PI


PI = 3.14
# Getting input from user
R = float(input("Enter radius of the circle: "))

# Finding the area and perimeter of the circle


area = (PI*R*R)
perimeter = (2*PI*R)

# Printing the area and perimeter of the circle


print("The area of circle is", area)
print("The perimeter of circle is", perimeter)

Output

7)Python Program for Simple Interest


# Python program to find simple interest

p = float(input("Enter the principle amount : "))


r = float(input("Enter the rate of interest : "))
t = float(input("Enter the time in the years: "))

# calculating simple interest


si = (p*r*t)/100
# printing the values
print("Principle amount: ", p)
print("Interest rate : ", r)
print("Time in years : ", t)
print("Simple Interest : ", si)

Output

8) Python program to find compound


interest

# Python program to find compound interest

p = float(input("Enter the principle amount : "))


r = float(input("Enter the rate of interest : "))
t = float(input("Enter the time in the years: "))

# calculating compound interest


ci = p * (pow((1 + r / 100), t))
# printing the values
print("Principle amount : ", p)
print("Interest rate : ", r)
print("Time in years : ", t)
print("compound Interest : ", ci)

Output

9)Python program to extract and print


digits of a number in reverse order
# input the number
num = int(input("Enter a number with multiple digit:
"))
n=0

# Extracting and printing digits


# in reverse order
while num>0:
a = num%10
num = num - a
num = num/10
print(int(a),end="")
n = n + 1

Output

10)Python if, if...else Statement


Example 1: Check whether a given number is 10 or
not
a=int(input("Enter A : "))

if a==10:
print("Equal to 10")
else:
print("Not Equal to 10")

Output
Example 2: Find largest of two numbers
a=int(input("Enter A: "))
b=int(input("Enter B: "))

if a>b:
g=a
else:
g=b

print("Greater = ",g)

Output

11)Python program to input age and


check eligibility for voting

# input age
age = int(input("Enter Age : "))

# condition to check voting eligibility


if age >= 18:
status = "Eligible"
else:
status = "Not Eligible"

print("You are ", status, " for Vote.")

Output
12)Python program to calculate
discount based on the sale amount

# input sale amount


amt = int(input("Enter Sale Amount: "))

# checking conditions and calculating discount


if(amt>0):
if amt<=5000:
disc = amt*0.05
elif amt<=15000:
disc=amt*0.12
elif amt<=25000:
disc=0.2 * amt
else:
disc=0.3 * amt

print("Discount : ",disc)
print("Net Pay : ",amt-disc)
else:
print("Invalid Amount")
Output

13)Python Looping
Table of number:-
n=int(input("Enter N: "))

for i in range(1,11):
print(n,"x",i,"=",i*n)

Output

Print all the numbers between 1 to N.:-


n=int(input("Enter N: "))

for i in range(1,n+1):
print(i)
Output

Python program to find square and


cube of a number

# python program to find square and cube


# of a given number

# User defind method to find square


def square(num):
return num * num

# User defind method to find cube


def cube(num):
return num * num * num

# Main code
# input a number
number = int(input("Enter an integer number: "))

# square and cube


print("square of {0} is {1}".format(number,
square(number)))
print("Cube of {0} is {1}".format(number,
cube(number)))

Output

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy