## Plotting Fibonacci

0 likes • Nov 19, 2022
Python

## More Python Posts

`# function which return reverse of a stringdef isPalindrome(s):    return s == s[::-1] # Driver codes = "malayalam"ans = isPalindrome(s) if ans:    print("Yes")else:    print("No")`
```prime_lists=[] # a list to store the prime numbers
def prime(n): # define prime numbers    if n <= 1:        return False    # divide n by 2... up to n-1    for i in range(2, n):        if n % i == 0:  # the remainder should'nt be a 0            return False    else:        prime_lists.append(n)        return True

for n in range(30,1000):  # calling function and passing starting point =30 coz we need primes >30    prime(n)
check=0 # a var to limit the output  to 10 onlyfor n in prime_lists:    for x in prime_lists:        val=  n *x        if (val > 1000 ):            check=check +1        if (check <10) :            print("the num is:", val , "=",n , "* ", x )        break```
```class Rectangle:    pass
class Square(Rectangle):    pass
rectangle = Rectangle()square = Square()
print(isinstance(rectangle, Rectangle))  # Trueprint(isinstance(square, Rectangle))     # Trueprint(isinstance(square, Square))        # Trueprint(isinstance(rectangle, Square))     # False```
```filename = "data.txt"data = "Hello, World!"
with open(filename, "a") as file:    file.write(data)```
`def print_pyramid_pattern(n):         # outer loop to handle number of rows    # n in this case    for i in range(0, n):             # inner loop to handle number of columns        # values changing acc. to outer loop        for j in range(0, i+1):                     # printing stars            print("* ",end="")              # ending line after each row        print("\r") print_pyramid_pattern(10)`
`# @return a list of strings, [s1, s2]def letterCombinations(self, digits):    if '' == digits: return []    kvmaps = {        '2': 'abc',        '3': 'def',        '4': 'ghi',        '5': 'jkl',        '6': 'mno',        '7': 'pqrs',        '8': 'tuv',        '9': 'wxyz'    }    return reduce(lambda acc, digit: [x + y for x in acc for y in kvmaps[digit]], digits, [''])`