Python Program to Find the Sum of Cosine Series.
Input:
First Line: Value of x in degrees
Second Line: Number of terms
Output:
Print the Sum of Cosine Series
Input:
Value of X in degrees: 65
Number of terms: 10
Output:
Sum of Cosine Series: 0.42
import math 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 x=int(input("value of X in degrees: ")) n=int(input("Number of terms: ")) print("\nSum of the Cosine Series: ",round(cosine(x,n),2))
INPUT_1:
Value of X in degrees: 65
Number of terms: 10
OUTPUT:
Sum of the Cosine Series: 0.42
INPUT_2:
Value of X in degrees: 45
Number of terms: 10
OUTPUT:
Sum of the Cosine Series: 0.71
INPUT_3:
Value of X in degrees: 30
Number of terms: 20
OUTPUT:
Sum of the Cosine Series: 0.87
INPUT_4:
Value of X in degrees: 60
Number of terms: 20
OUTPUT:
Sum of the Cosine Series: 0.5
ILLUSTRATION
![](http://www.fcukthecode.com/wp-content/uploads/2022/02/Screenshot-from-2022-02-10-16-47-29.png)
Morae Q!
- Program to get dictionary items, use update module and items module.
- Regular expression allowing certain set of characters.
- Compute the Sum of Cosine Series.
- Find the Sum of Sine Series.
- Remove the Vowels from the string.
- Find All Non-Overlapping strings/characters using regular expressions .
- Check whether the given string is Panagram or not.
- Replacing strings using Regular Expression Regex.
- Check whether the given number is Strong number or not.
- Find the numbers divisible by a input numbers within the given range.
- Change the behaviour of the Regular Expression using flags.
- Find the exponentiation of a number.
- Find all prime numbers in a range using Sieve of Eratosthenes.
- Convert decimal equivalent into binary, hexadecimal and octal.
- Compute the area of a farmers field in feet.
- Compute time from number of days/hours to seconds.
- Precompiled patterns using Regular Expressions .
- Compute the price of the cake on the nth day.
- Compute the number of possible non-increasing arrays.
- Find the type of spinach using the calorie value.