Ch 32 for loop exercise
for i in range(10):
print("hello world")
# the range function is help to define the range which number u want to print
for i in range(10,30): #
print(f"hello world {i}")
(10,30). In this line u command to (start:stop) lekin ismai 0bhi count hoga toh ye sirf 29number tak dekhaga
#The sum input exercisen
int(input("enter something"))
total=0
for i in range(1,n+1):
total+=i
print(total)
#simple to learn and easy to use !!
Exercise. 2
total=0
num=input("enter a number")
for i in range(0,len(num)):
total+=(int(num[i]))
print(total)
The code will add this type of formate ====#
1+2+3+4+5+6+7+8
Exercise 3
name=input("enter your name")
temp=""
for i in range(len(name)):
if name[i] not in temp:
print(f"{name[i]}:{name.count(name[i])}")
temp+=name[i]
#Count the caracter in string and show to user
Comments
Post a Comment