Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
184_notes:python_syntax [2018/06/04 14:58] – dmcpadden | 184_notes:python_syntax [2020/08/24 19:31] (current) – dmcpadden | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | / | ||
+ | |||
===== Common Commands and Tips for Python ===== | ===== Common Commands and Tips for Python ===== | ||
In this class, we are often going to use VPython to create computational models, which will serve as a powerful tool to help us create visualizations and apply the ideas in this course to more real-world contexts. Below are some of the common Python commands that we will use in this course and some coding tips compiled by previous EMP-Cubed students. (Note: we do not expect you to have any coding experience prior to this course, and we will not expect you to write a program from scratch. We will primarily be asking you to interpret chunks of code with your group members and adjust/ | In this class, we are often going to use VPython to create computational models, which will serve as a powerful tool to help us create visualizations and apply the ideas in this course to more real-world contexts. Below are some of the common Python commands that we will use in this course and some coding tips compiled by previous EMP-Cubed students. (Note: we do not expect you to have any coding experience prior to this course, and we will not expect you to write a program from scratch. We will primarily be asking you to interpret chunks of code with your group members and adjust/ | ||
Line 37: | Line 39: | ||
position2=vec(2, | position2=vec(2, | ||
separation=position2-position1 | separation=position2-position1 | ||
- | testing=separation-4 #This will give and error | + | testing=separation-4 #This will give an error |
</ | </ | ||
* **Vector magnitude** - the " | * **Vector magnitude** - the " | ||
Line 53: | Line 55: | ||
A=vec(1, | A=vec(1, | ||
B=vec(4, | B=vec(4, | ||
- | AB=dot(A,B) | + | AB=dot(A, |
+ | print(AB) | ||
</ | </ | ||
* **Cross Product** - the cross product is another way to [[184_notes: | * **Cross Product** - the cross product is another way to [[184_notes: | ||
Line 59: | Line 62: | ||
C=vec(5, | C=vec(5, | ||
D=vec(3, | D=vec(3, | ||
- | CD=cross(C, | + | CD=cross(C, |
+ | print(CD) | ||
</ | </ |