- #1
- 2,168
- 193
Homework Statement
Take as input from the user an integer N. We don't want the user to enter very large integers, so exit with an error message if N>20. You may assume that N is an integer (and not a real number) and also that it is positive. Make two vectors v1 and v2 using v1.append() and v2.append() to fill in these vectors in the following way:
- nth element of v1 should be cos(pi*n/16)
- nth element of v2 should be sin(pi*n/21)
Homework Equations
The Attempt at a Solution
Here is my code
Python:
#!/usr/bin/python
N=int(input('Enter integer: '))
if N>20:
print ('error')
exit ()
elif N<20:
v1=[]
for n in range (1,N+1):
import math
x=math.cos(math.pi*n / 16)
v1.append(x)
print (v1)
But I just only want the last one. How can I choose it ?
Thanks
Last edited by a moderator: