background img
banner
Dec 23, 2021
346 Views
1 0

Python Programmings For Practice Part 2 ( 2022 )

Written by
banner

Python program to find the geometric mean of n numbers

c = 0
p = 1.0
count = int(input("Enter the number of values: "))
while(c<count):
    x = float(input("Enter a real number: "))
    c = c+1
    p = p * x
gm = pow(p,1.0/count)
print("The geometric mean is: ",gm)

Python program to find the sum of the digits of an integer using while loop

sum = 0
number = int(input("Enter an integer: "))
while(number!=0):
    digit = number%10
    sum = sum+digit
    number = number//10
print("Sum of digits is: ", sum)  

Python program to display all the multiples of 3 within the range 10 to 50

for i in range(10,50):
    if (i%3==0):
        print(i)

Python program to display all integers within the range 100-200 whose sum of digits is an even number

for i in range(100,200):
    num = i
    sum = 0
    while(num!=0):
        digit = num%10
        sum = sum + digit
        num = num//10
    if(sum%2==0):
        print(i)
Article Tags:
Article Categories:
Programming Language · Python
banner

Comments to Python Programmings For Practice Part 2 ( 2022 )

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback
1 year ago

[…] Python Programmings For Practice Part 2 ( 2022 ) […]

1
0
Would love your thoughts, please comment.x
()
x