0% found this document useful (0 votes)
14 views12 pages

Kashish String

The document contains a series of Python programming assignments that cover various topics such as calculating total and average marks, generating a three-digit number, computing simple interest, reversing a number, checking triangle validity, and identifying prime numbers. It also includes tasks for calculating factorials, checking Armstrong numbers, and swapping two numbers without a temporary variable. Each assignment is presented as a separate code block with user input prompts and output statements.

Uploaded by

KASHISH MADAN
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)
14 views12 pages

Kashish String

The document contains a series of Python programming assignments that cover various topics such as calculating total and average marks, generating a three-digit number, computing simple interest, reversing a number, checking triangle validity, and identifying prime numbers. It also includes tasks for calculating factorials, checking Armstrong numbers, and swapping two numbers without a temporary variable. Each assignment is presented as a separate code block with user input prompts and output statements.

Uploaded by

KASHISH MADAN
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/ 12

ASSIGNMENTS

#QUESTION NUMBER 2
count=0

eng=float(input("enter marks of english"))

count+=1

maths=float(input("enter marks of mathematics"))

count+=1

comp=float(input("enter marks of computer science"))

count+=1

phy=float(input("enter marks of physics"))

count+=1

chem=float(input("enter marks of chemistry"))

count+=1

total=eng+maths+comp+phy+chem

print("total is:",total)

avg=total/count

print("average marks is:",avg)


#QUESTION 3
n = input("Enter a single digit number :")
num = n + str(int(n)+1) + str(int(n)+2)
print("The three digit number is :", num)
#QUESTION NUMBER 5
P=float(input("enter principal amount"))
R=float(input("enter rate of interest"))
T=float(input("enter time period "))
SI=P*R*T/100
print("simple interest is:",SI)
#QUESTION NUMBER 6
n=int(input("Enter number: "))
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
print("Reverse of the number:",rev)
#QUESTION NUMBER 8
a=int(input("enter length of side 1:"))
b=int(input("enter length of side 2:"))
c=int(input("enter length of side 1:"))
if a+b<c or b+c<a or a+c<b:
print("not a triangle")
else:
print("its a triangle")
#QUESTION NUMBER 9
a = input("enter a number:")
if a[-1]=="4":
print("ends with 4")
elif a[-1]=="8":
print("ends with 8")
else:
print("ends with neither")
#QUESTION NUMBER 11
for Number in range (1, 101):
count = 0
for i in range(2,(Number//2 + 1)):
if(Number % i == 0):
count = count + 1
break

if (count == 0 and Number!= 1):


print(" %d" %Number, end = ' ')
#QUESTION NUMBER 12
fact=1
num=int(input("factorial to be find"))
if num<0:
print("sorry,factorial does not exist")
elif num==0:
print("the factirial of 0 is 1")
else:
for i in range(1,num+1):
fact=fact*i
print("the factorial of",num,"is",fact)
#QUESTION NUMBER 13
num = int(input("enter a number"))
a = len(str(num))
sum = 0
k=num
while k > 0:
digit = k % 10
sum += digit ** a
k//= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
#QUESTION NUMBER 1
t=input("enter a string")
count = 0
for char in t :
if char not in t :
count = 1
break
else :
pass
if count :
print("No")
else :
print("Yes")
#QUESTION NUMBER 10
x=int(input("enter a number 1:"))
y=int(input("enter a number 2:"))
print(x,y)
x=x+y
y=x-y
x=x-y
print(x,y)
#4,7 and 14 doubt

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