# Write a Python function to Find the Sum of Sine Series - Python

Categories:
Viewed: 4 - Published at: a few seconds ago

### Write a Python function to Find the Sum of Sine Series

``````import math
def sin(x,n):
sine = 0
for i in range(n):
sign = (-1)**i
pi=22/7
y=x*(pi/180)
sine = sine + ((y**(2.0*i+1))/math.factorial(2*i+1))*sign
return sine
``````

### Write a Python function to Find the Sum of Cosine Series

``````def cosine(x,n):
cosx = 1
sign = -1
for i in range(2, n, 2):
pi=22/7
y=x*(pi/180)
cosx = cosx + (sign*(y**i))/math.factorial(i)
sign = -sign
return cosx
``````

### Write a Python function to strip vowels from a string

``````def vowel_stripping(string):
'''This function takes a string as an input strips out vowels and returns stripted out string'''
return "".join([x for x in string if x not in('a','e','i','o','u')])
``````

### Write a Python function that shifts the character of strings

``````def char_shift(string, shift_count):
'''This function takes a string as an input and shifts each character by 5 and returns shifted string'''
return "".join([chr(ord(x)+shift_count) if (ord(x)+shift_count) <= 122 else chr(96 + (ord(x)+shift_count) - 122) for x in string])
``````

### Write a Python function that returns biggest character in a string

``````from functools import reduce
def biggest_char(string):
'''This function takes an input as a string and returns the biggest output character in the string'''
biggest_chr = lambda x, y: x if ord(x) > ord(y) else y
return reduce(biggest_chr, string)
``````

### Write a Python function that calculate interior angle of a equilateral polygon

``````def interior_angle(no_of_sides):
return (no_of_sides - 2) * 180 / no_of_sides
``````

### Write a Python function that calculate side length of a equilateral polygon

``````import math
return 2 * circumradius * math.sin(math.pi / no_of_sides)
``````

### Write a Python function that calculate area of a equilateral polygon

``````import math
side_length = 2 * circumradius * math.sin(math.pi / no_of_sides)
apothem = circumradius * math.cos(math.pi / no_of_sides)
return no_of_sides / 2 * side_length * apothem

# sample.py
from datetime import datetime
from time import perf_counter
import random
val = 10
counter_67 = dict()
``````

### Write a function to print given interger to binary

``````def int_to_binary(num: int):
"""
function to print number to binary
"""
if isinstance(num, int):
print(f'The binary of {num} is {bin(num).replace("0b","")}')
else:
raise ValueError('Invalid Input')
``````

### Write a function to check given string is palindrome or not (case insensitive)

``````def palindrome_str_check(value: str):
"""
function to print whether string is palindrome or not
"""
if isinstance(value, str) :
print( value.lower() == value[::-1].lower() )
else:
raise ValueError('Invalid Input')
``````

### Write a function to check whether a given date in DD/MM/YYYY format is valid or not

``````def date_validation(inputdate: str):
"""
function take input date in DD/MM/YYYY format and check its validation.
"""
import datetime
dd, mm, year = inputdate.split('/')
isValidDate = True
try :
datetime.datetime(int(year),int(mm), int(dd))
except ValueError :
isValidDate = False
if(isValidDate):
print ("Input Date is Valid")
else:
print ("Input Date is invalid")
``````

### Write a function to print the count of divisor.

``````def divisor_count(num: int):
"""
function to count the number of divisor of interger.
"""
if isinstance(num, int):
count = 0
for i in range(1, num+1):
if num%i == 0:
count = count+1
print(f'Number of divisor is {count}')
else:
raise ValueError('Invalid Input')
``````

### Write a function to print the count of divisor using list comprehension

``````def divisor_using_list(num: int):
"""
function to count the number of divisor using list comprehension.
"""
if isinstance(num, int):
count = [i for i in range(1,num+1) if not num%i]
print(f'Number of divisor is {count}')
else:
raise ValueError('Invalid Input')
``````