[go: up one dir, main page]

0% found this document useful (0 votes)
11 views14 pages

# To Interchange The Value of Two Variables Input

Coding Docx

Uploaded by

mdamaan639
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)
11 views14 pages

# To Interchange The Value of Two Variables Input

Coding Docx

Uploaded by

mdamaan639
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/ 14

# To Interchange the value of two

variables

Input :

a=float(input(“Enter 1st Number : ”))


b=float(input(“Enter 2nd Number : ”))

a=a+b
b=a-b
a=a-b

print(“1st Interchanged Value :”,a)


print(“2nd Interchanged Value :”,b)
# To Reverse Three Digit Number

Input :

n = int(input(“Enter a Three Digit Number : ”))


if 100<=n<1000:
reverse = 0
for i in range(0,3):
rem = n%10
reverse = (reverse*10)+rem
n = int(n/10)
print(“Reverse :”,reverse)
# To find the Biggest Number Among
Three Numbers

Input :

num1 = float(input(“Enter First number : ”))


num2 = float(input(“Enter Second number :
”))
num3 = float(input(“Enter Third number : ”))

max_number = max(num1, num2, num3)


print(“The Biggest number :”, max_number)
# To Display Student’s Grade

Input :
n=input(“Enter Student’s Name : ”)

print(“\nEnter Marks(Out Of 100)\n”)

m=float(input(“Marks In Maths : ”))

s=float(input(“Marks In Science : ”))

sst=float(input(“Marks In S.St : ”))

p=float(input(“Marks In Punjabi : ”))

e=float(input(“Marks In English : ”))

if (m and s and sst and p and e<=100):

Total=m+s+sst+p+e

print(“\nTotal Marks :”,Total)

percent=(total/500)*100

print(“\nPercentage :”,percent)

else:

print(“Invalid Marks”)

if 90 <=percent<= 100:

grade = ‘A’

elif 80 <=percent< 90:

grade = ‘B’

elif 70 <=percent< 80:

grade = ‘C’

elif 60 <=percent< 70:

grade = ‘D’

else:

grade = ‘F’

print(“\nStudent’s Grade:”, grade)


# To Print n Natural Number

Input :

n=int(input(“Enter Value of n : ”))


print(“\nFirst”,n,”Natural Numbers : ”)
for i in range(1,n+1):
print(i)
# To Display the Table

Input :

n=float(input(“Enter a Number to Print Table :


”))

i=1
while i<=10:
print(n,“×”,i, “=”, n*i)
i=i+1
# To Print Sum of n Natural Numbers

Input :

n=int(input(“Enter Maximum Limit : ”))

Sum=0
i=1
while i<=n:
Sum=Sum+i
i=i+1
print(“Sum of n Natural Numbers :”,Sum)
# To check Number is Prime or Not

Input :

n = int(input(“Enter a Number : ”))


flag = 0
for i in range(2,n):
if n%i == 0:
flag = 1
break
if flag == 1:
print(“Number is Not Prime”)
else:
print(“Number is Prime”)
# To print Fibonaccie Series

Input :

n = int(input(“How Many Elements : ”))


pre = 0
curr = 1
print(pre)
print(curr)

for i in range(1,n+1):
next = pre+curr
print(next)
pre = curr
curr = next
# To print Pattern

Input :

n = int(input(“How Many Rows : ”))

for i in range(1,n+1):
for j in range(1,i+1):
print(j,end=“ ”)
print(“\r”)
# To print Triangle

Input :

n = int(input(“How Many Rows : ”))

for i in range(1,n+1):
for k in range(n+1,i,-1):
print(“ ”,end= “ ”)
for j in range(1,i+1):
print(“* ”,end=“ ”)
print(“\r”)
# To Calculate Mean

Input :

import array as arr


a = arr.array (‘i’,[10,20,30,40,50])
sum = 0

for i in range(0,5):
sum = sum+a[i]

mean = sum/5
print(“Mean :”,mean)
# To find Location of a Number

Input :

import array as arr


a = arr.array(‘i’,[10,20,30,40,50])
loc = -1
n = int(input(“Enter the Number to be
search : “))
for i in range(0,5):
if n==a[i]:
loc = i
break
if loc == -1:
print(“Element Not Found”)
else:
print(“Element Found at Location :”,loc)
# To display the Contents of a Data
Dictionary

Input :

You might also like