avatar
Advika Bhavsar
0

Codes

3

Answers

Code compilers

Top answers

0
python fibonacci while loop
February-07-2022
Input:
    
    
    n = int(input("Enter the value of n: "))
first = 0
second = 1
next_number = 0
count = 1

while(count <= n):
     print(next_number, end = " ")
     count += 1
     first = second
     second = next_number
     next_number = first + second
     t_number = first + second


Output:
    
Enter the value of n:  8
0 1 1 2 3 5 8 13
0
Fibonacci sequences
February-07-2022
Input:

def Fib(n):
   if n <= 1:
       return n
   else:
       return (Fib(n - 1) + Fib(n - 2))  # function calling itself(recursion)


n = int(input("Enter the Value of n: "))  # take input from the user
print("Fibonacci series :")
for i in range(n):
   print(Fib(i),end = " ")


Output:

Enter the value of n:  8
0 1 1 2 3 5 8 13
0
find string in string python
February-02-2022
myStr = "py py py py"
print(myStr.find("js"))
print(myStr.index("js"))