Coding_Practice_Problems_CSE
Coding_Practice_Problems_CSE
1. Reverse a String
-------------------
Python Solution:
def reverse_string(s):
return s[::-1]
---------------------
Python Solution:
def is_prime(n):
if n <= 1:
return False
if n % i == 0:
return False
return True
3. Fibonacci Series
-------------------
Python Solution:
def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
----------------------------
Python Solution:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
-----------------------------------
Python Solution:
total = n * (n + 1) // 2
6. Palindrome Check
-------------------
Python Solution:
def is_palindrome(s):
return s == s[::-1]
7. Pattern Printing
-------------------
Python Solution:
def print_pattern(n):
print('*' * i)