Tuesday, 7 April 2026

Using generator producing Fibonacci numbers


   
 def fun():
    a,b=
0,1 ---> Define Variables
while b<10: Using While Loop
yield b -- Using Generator Yiled Hear
a,b=b,a+b -- Logic Of Fab


i2=fun() -- Creating object
for i in i2: ---> Using loop
print(i,end=" ")



Output:
1 1 2 3 5 8

No comments:

Post a Comment

Python Most Used Coding ..SCR's Part _I

 #Define the Function For palindrome #.palindrome Means Original String =Reverse String  def is_palindrome(string):     reversed_string = st...