The program 'linear_a'.
x = int(input("Give me a number. "))
y = int(3*x+1)
print(y," What's happened to your number?")
input ("Press Enter to finish.")
Maths:
Input a number. What is the program doing to it?
Can you try numbers systematically to find out?
Computing:
Can you edit the program so that it applies a different rule? Give it to a friend to work out. Don't make it too easy or too hard!
'linear_b' gives the results of inputting 0 - 10.
print ("x","y")
for x in range (11):
y = int(3*x+1)
print(x,y)
input ("Press Enter to finish.")
Computing:
Can you edit the program so that it applies a different rule?
Maths:
Investigate the result for x=0 for different equations.
Now investigate the increment between values for y for different equations.
How would y = int(3*x+1) be written in a maths book?
This program will generate a table of results for y=ax+b. Can you work out the randomly generated values of a and b? a is between 1 and 10 inclusive and b is between -10 and 10.
import random
a= (random.randint(1, 10))
b= (random.randint(-10, 10))
for x in range(0, 11):
print(x," ", a*x+b)