CS 110 Lecture 11: calculating sin function in python

81 views1 pages
30 Apr 2016
Course
Professor

Document Summary

# initialize total (sum of the series) to 0. 0. total = 0. 0. # initialize term (each term in the series) to 1. 0, and sign (sign of. # the term) to 1. term = 1. 0 sign = 1. # initialize i (loop variable) to 1. i = 1. # repeat until convergence. while total != total + term: # set term to its previous value times x divided by i. term = (term * x) / i. # if i is odd, increment total by sign * term, and toggle sign. if i % 2 != 0: total += sign * term sign *= -1. Reads a float x (representing an angle in.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents