Prime Numbers Announcement
# What are prime numbers?
# http://www.programiz.com/python-programming/examples/prime-number
def isPrime(num):
if isinstance(num, float) or isinstance(num, int):
if isinstance(num,bool) or int(num) != num:
print("Illegal input")
elif num > 1:
# check for factors
num = int(num)
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")
# if input number is less than
# or equal to 1, it is not prime
else:
print(num,"is not a prime number")
else:
print("Illegal input")
isPrime([3,4])
isPrime(True)
isPrime(3.0)
isPrime(-4.3)
isPrime("a")
isPrime(5.6)
isPrime(407)
isPrime(17)
Multiplication Table Announcement
def multi_table(a,b):
if a > b:
small = b
large = a
else:
small = a
large = b
print("{:<6 br="" end="" format=""> for head in range(small,large+1,1):
print("{:<6 br="" end="" format="" head=""> print("")
for row in range(small,large+1,1):
print("{:<6 br="" end="" format="" row=""> for col in range(small,large+1,1):
print("{:<6 br="" col="" end="" format="" row=""> print("")
multi_table(11,17)
print("------------------")
multi_table(17,11)6>6>6>6>
Exam 3
Exam 3 will be held on Nov 7 and 9. On Monday (11/7), you will see one question and on Wednesday (11/9) you will see another question. Exam 3 covers everything up to and including Chapter 7. It is open book and open notes, but it is closed on any living thing.
No comments:
Post a Comment