You are on page 1of 2

https://github.

com/zhiwehu/Python-programming
exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises.txt

1. ###make it so that any word written is such that the first letter of the word is substituted with a
corresponding number of the position of that letter in the alphabet###

y=input("Write your word:")

if y[0]=="a" or y[0]== "A":

print ("1" + y [1:])

elif y[0]=="b" or y[0]=="B":

print ("2" + y [1:])

elif y[0]=="c" or y[0]=="C":

print ("3" + y [1:])

elif y[0]== "d" or y[0]=="D":

print ("4" + y [1:])

#etc.

2. ###Write a program which will find all such numbers which are divisible by 7 but are not a multiple
of 5, between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-
separated sequence on a single line.###

for x in range (2000,3201):

if x%7==0 and x%5!=0:

print(x, end=",")

### outsourced on https://stackoverflow.com/questions/3249524/print-in-one-line-dynamically


3. Write a program that calculates a factorial of a given number:

num= int(input("Input your number"))

beb=num

y=0

for x in range (1, num+1):

while (beb>1):

beb=beb-1

num=beb* num

if beb==1:

print(num*beb)

You might also like