# 1/1! + 2/2! + 3/3! ... nthn=int(input('Enter a number :\n'))print(f'Your Enter number is {n}\n')sum=0fact=1foriinrange(1,n+1):fact=fact*isum=sum+(i/fact)print(f'Your Total sum of this sequence is {sum}')
# user input n=int(input('Enter the number of star you want : \n'))print(f'Your enter number is {n}\n')# loopsforiinrange(1,n+1):forjinrange(1,i+1):print('*',end='')print()
# user input n=int(input('Enter the number of star you want : \n'))print(f'Your enter number is {n}\n')# loopsforiinrange(1,n+1):forjinrange(1,i+1):print(j,end='')forkinrange(i-1,0,-1):print(k,end='')print()
# does primary number is ?lower_range=int(input('enter the Lower number :'))upper_range=int(input('enter the Lower number :'))print(f"Your Lower Range {lower_range}, Upper Range {upper_range}")foriinrange(lower_range,upper_range+1):forjinrange(2,i):ifi%j==0:breakelse:print(i)
# when using while and when using for in text# Use "while" when you want to loop based on a condition.# Example: Print numbers from 1 to 5count=1whilecount<=5:print(count)count+=1
# Use "for" when you want to iterate over a sequence (like a string).# Example: Print each character in a stringtext="Hello"forcharintext:print('\n',char)