CoCalc Shared FilesPhysics Modeling for Game Programmers / PHYS360-Scratch.htmlOpen in CoCalc with one click!
Author: Todd Zimmerman
Views : 7
Description: Jupyter html version of Physics Modeling for Game Programmers/PHYS360-Scratch.ipynb
PHYS360-Scratch
In [5]:
from __future__ import division

max=10
count=[]
i=0
running = True


while running:
    count.append(i)
    i+=1
    print i
    if i>max:
        running=False
print count
1
2
3
4
5
6
7
8
9
10
11
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
In [10]:
sum=0
for j in count:
    sum+=j
    print j,sum
print("The sum of all numbers between 0 and 10 is",  sum)
0 0
1 1
2 3
3 6
4 10
5 15
6 21
7 28
8 36
9 45
10 55
('The sum of all numbers between 1 and 10 is', 55)
In [21]:
a = 5
b = 3
if a % 2 == 0 & b % 2 == 0:
    print(a ** b)
if a % 2 != 0 & b % 2 != 0: 
    print(b ** a)
if (a % 2 == 0 and b % 2 != 0) or (a % 2 != 0 and b % 2 == 0):
    print(a%2==0 and b%2!=0,b%2==0 and a%2!=0)
    print( a * b)
In [ ]: