a=5 hello my name is phil
print(a)
opens a file named input.txt with a line of two numbers in the format:
1000;-3
where both numbers are integers, the first positive and the second negative
assigns those two values to the variables: total_count and step_size, respectively
loops from total_count to 0 by step_size, printing the loop integer for each step
Step 1: write out a text file named input.txt using the IPython file "magic"
In [0]:
%%file input.txt
20;-3
Step 2: open the file and read a line into a variable
In [0]:
f=open('input.txt','r')
firstline=f.readline()
Step 3: split the line and assign the values to variables, converting strings to ints
In [0]:
total_count,step_size=firstline.split(';')
total_count,step_size=int(total_count),int(step_size)
print("got total_count and step_size values of {}, {}".format(total_count,step_size))
Step 4: Use the range function to get a list of integers to print
In [0]:
help(range)
In [0]:
the_ints=range(total_count,0,step_size)
Step 5: loop and print
In [0]:
for the_num in the_ints:
print the_num
In [0]:
import testit
In [0]:
!ls
In [0]:
import tesit
In [0]:
dir(tesit)
In [0]:
reload(tesit)
In [0]:
!pwd
In [0]: