Python programms
Python programms
word = random.choice(words)
guesses = ''
turns = 12
failed = 0
if char in guesses:
print(char, end=" ")
else:
print("_")
failed += 1
if failed == 0:
print("You Win")
print("The word is: ", word)
break
print()
guess = input("guess a character:")
guesses += guess
turns -= 1
print("Wrong")
print("You have", + turns, 'more guesses')
if turns == 0:
print("You Loose")
def simple_interest(p,t,r):
print('The principal is', p)
print('The time period is', t)
print('The rate of interest is',r)
si = (p * t * r)/100
# Driver code
simple_interest(8, 6, 8)
def findArea(r):
PI = 3.142
return PI * (r*r);
# Driver method
print("Area is %.6f" % findArea(5));
# Driver program
starting_range = 2
ending_range = 7
lst = prime(starting_range, ending_range)
if len(lst) == 0:
print("There are no prime numbers in this range")
else:
print("The prime numbers in this range are: ", lst)
Python Program to Find Area of a Circle
# Python program to find Area of a circle
def findArea(r):
PI = 3.142
return PI * (r*r);
# Driver method
print("Area is %.6f" % findArea(5));
num = 11
# Negative numbers, 0 and 1 are not primes
if num > 1:
# Iterate from 2 to n // 2
for i in range(2, (num//2)+1):
# driver code
nthFib(12)
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 = 4
print(squaresum(n))
return sum
# Driver Function
n = 5
print(sumOfSeries(n))
print(a)
Python statistics