Answer:
def fizzbuzz (num):
for item in range(num):
if item % 2 == 0 and item % 3 == 0:
print("fizzbuzz")
elif item % 3 == 0:
print("buzz")
elif item % 2 == 0:
print("fizz")
else:
print (item)
fizzbuzz(20)
Explanation:
Using Python programming Language
Use a for loop to iterate from 0 up to the number using the range function
Within the for loop use the modulo (%) operator to determine divisibility by 2 and 3 and print the required output
see attached program output screen.
Answer:
Moscow
Explanation:
Moscow is the capital of Russia and was made the capital in 1918.
Answer:
Declare variable b in both lines
i.e. int b
Explanation:
In the given code, the parameters of both functions were not properly declared.
When listing the parameters, the data type must be clearly stated for all parameters (individually)
In the declaration of both functions, only variable a is declared as integer while b is undeclared.
So, the correction is to declare b as integer
Take this one step at a time. Your teacher has given you the code for step 1. Now write step 2. Then 3, and so on.
For step 2: if you're using Python v2.x you'd use a line like
guess = int( raw_input( "Take another guess: " ) )
For Python v3.x it would be:
guess = int( input( "Take another guess: " ) )
Break it down into small pieces, it's not a complicated assignment.