Python basics in the IDLE shell.
Try these examples in the IDLE shell, in order, one at a time:
>>> n = 47
>>> n < 50
>>> n > 100
>>> n > 50
>>> n < 100
>>> n < 100 and n > 50
>>> n > 50 or n < 100
>>> not (n > 50)
>>> ord('Q')
>>> ord('R')
>>> 'Q' < 'R'
>>> for x in range(37, 42):
print(x)
>>> x = 37
>>> while x < 42:
print(x)
x = x + 1
>>> from random import randrange
>>> randrange(3)
>>> randrange(3)
>>> randrange(3)
>>> from time import sleep
>>> sleep(3)
>>> sleep(0.25)
>>> j = 0
>>> while j < 100:
print(j)
sleep(0.5)
j = randrange(50, 150)
>>> j
Download and unzip the pre-lab
archive. Use IDLE to open lab3_examples.py
in the
pre-lab3
folder. Read over the file in detail. Bring
questions to ask at the start of lab.
Run the module in IDLE and then experiment with using each of the functions in the IDLE shell, as in:
>>> is_upper_char('P')
>>> uppers_only('Computers Only Offer Loops!')
>>> count_factors(30)
>>> steps_to_zero(19)
>>> smallest_factor(98769876345281112)
>>> int_to_string(4301)
>>> random_boxes(8)