Def squaresum(n) : # Iterate i from 1


Download 150.34 Kb.
Sana26.01.2023
Hajmi150.34 Kb.
#1128759
Bog'liq
python R J


  1. def squaresum(n) :

# Iterate i from 1
# and n finding
# square of i and
# add to sum.
sm = 0
for i in range(1, n+1) :
sm = sm + (i * i)
return sm
# Driven Program
n = 5
print(squaresum(n))








  1. # Python code to demonstrate the working of

# max()
# printing the maximum of 4,12,43.3,19,100
print("Maximum of 4,12,43.3,19 and 100 is : ",end="")
print (max( 4,12,43.3,19,100 ) )




# Python code to demonstrate the working of
# min()
# printing the minimum of 4,12,43.3,19,100
print("Minimum of 4,12,43.3,19 and 100 is : ",end="")
print (min( 4,12,43.3,19,100 ) )





  1. x = input("Type a number: ")

y = input("Type another number: ")

sum = int(x) + int(y)



print("The sum is: ", sum)

a = int(input("Enter a first number\n"))
b = int(input("Enter a second number\n"))
c = a-b
print("The result is",c)

Download 150.34 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling