Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write a function that prints to the screen the odd numbers from 1 to 99. 2) W

ID: 3529822 • Letter: 1

Question

1) Write a function that prints to the screen the odd numbers from 1 to 99.

2) Write a function called isPrime that takes a positive integer and returns True if the number is prime, and False otherwise. (A prime number has only two divisors, the number 1, and itself.)

3) Write a function that repeatedly rolls a virtual six-sided die and prints to the screen the outcomes or face values. The function stops printing when it gets the face value 6 twelve times in total.

4) Write a function called printTriangle that takes a string parameter and prints a triangle on the screen with the letters of that string. For instance, printTriangle(

Explanation / Answer

Hi,


-------------------------------------------------


# Prints odd numbers from 1 to 99


oneto100 = range(1, 100)

print "List of odd numbers."


for count in oneto100:

if count % 2 == 1:

print count


-------------------------------------------------


# Reads a number and prints a message if it is prime number


def isPrime(a):

b = a - 1

for x in range(2, b):

if a % x == 0:

print("{} equals {} x {}".format(a, x, a // x))

return False

else:

print(a, "is a prime number")

return True



# Asks for a number.

number = input("Tell me a number: ")


isPrime(number)


Thanks,

Satish