Skip to content
Snippets Groups Projects
Commit dc1b2df9 authored by cprutean's avatar cprutean
Browse files

Upload New File

parent fd5e5d2c
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:15c99cef tags:
# While Loop to List
%% Cell type:code id:a90d92d5 tags:
``` python
"""
Example to demonstrate a while loop to write theta and cos theta
to a list
"""
import math
def main():
n_point = 50
delta_theta = 2.0*math.pi/n_point # theta increment
theta = 0.0 # theta start
theta_data = [] # empty list
cos_data = [] # empty list
while theta < 2.0*math.pi: # while loop
cos = math.cos(theta)
theta_data.append(theta) # Add values to list
cos_data.append(cos)
theta += delta_theta # increment theta
# Do a default print (not very tidy output, replace this and
# a loop and make it nicer)
print(str(theta_data))
print(str(cos_data))
main()
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment