#ITERATION CODING
#INSTRUCTIONS
# 1) COMPLETE QUESTIONS THAT ARE IN A RED BOX
# 2) DO NOT CHANGE THE MAIN METHOD NAMES!!!!!
# 3) READ COMMENTS FOR HELP
# 4) DELETE "RETURN" KEYWORD IN SOME PLACES
# 5) MAKE SURE THERE ARE NO SYNTAX ERRORS WHEN YOU UPLOAD!!!!
######################################################
# Question 1: Write a function that prints takes a string from a user and print this as many
times the user has specified
######################################################
def question1():
stringInput = input ("Enter a string of your choice : ")
numberOfTimes = int(input("How many times would you like to print this ? "))
return stringInput, numberOfTimes
def question1Main():
x,y = question1()
for i in range (y):
print(x)
#question1Main()
#####################################################
# Question 2: Write a function that takes in a number from the user e.g. 5 and prints the
following pattern If the user enters 5 the following patern would be:
# 1
# 12
# 123
# 1234
# 12345
######################################################
def question2(numberOfTimes):
for i in range(1,numberOfTimes+1):
for j in range(1,i+1):
print(j,end = " " )
print(" ")
def question2Input():
, x = int(input("Enter a number : "))
return x
def question2Main():
numberOfTimes = question2Input()
question2(numberOfTimes)
#question2Main()
######################################################
# Question 3: Write a function that calculates the sum of all numbers from 1 to a given
number
######################################################
def question3(x):
sum = 0
i=0
while i<=x :
sum = sum+i
i+= 1
return sum
def question3Input():
number = int(input("Enter a number >1 : "))
return number
def question3Main():
x = question3Input()
sumNumber = question3(x)
print(sumNumber)
#question3Main()
######################################################
# Question 5: Write a program to print multiplication table of a given number
######################################################
def question5(number):
print("Multiplication table for : ", number)
for i in range(1,11) :
print(number,"x",i,"=", number*i)
#INSTRUCTIONS
# 1) COMPLETE QUESTIONS THAT ARE IN A RED BOX
# 2) DO NOT CHANGE THE MAIN METHOD NAMES!!!!!
# 3) READ COMMENTS FOR HELP
# 4) DELETE "RETURN" KEYWORD IN SOME PLACES
# 5) MAKE SURE THERE ARE NO SYNTAX ERRORS WHEN YOU UPLOAD!!!!
######################################################
# Question 1: Write a function that prints takes a string from a user and print this as many
times the user has specified
######################################################
def question1():
stringInput = input ("Enter a string of your choice : ")
numberOfTimes = int(input("How many times would you like to print this ? "))
return stringInput, numberOfTimes
def question1Main():
x,y = question1()
for i in range (y):
print(x)
#question1Main()
#####################################################
# Question 2: Write a function that takes in a number from the user e.g. 5 and prints the
following pattern If the user enters 5 the following patern would be:
# 1
# 12
# 123
# 1234
# 12345
######################################################
def question2(numberOfTimes):
for i in range(1,numberOfTimes+1):
for j in range(1,i+1):
print(j,end = " " )
print(" ")
def question2Input():
, x = int(input("Enter a number : "))
return x
def question2Main():
numberOfTimes = question2Input()
question2(numberOfTimes)
#question2Main()
######################################################
# Question 3: Write a function that calculates the sum of all numbers from 1 to a given
number
######################################################
def question3(x):
sum = 0
i=0
while i<=x :
sum = sum+i
i+= 1
return sum
def question3Input():
number = int(input("Enter a number >1 : "))
return number
def question3Main():
x = question3Input()
sumNumber = question3(x)
print(sumNumber)
#question3Main()
######################################################
# Question 5: Write a program to print multiplication table of a given number
######################################################
def question5(number):
print("Multiplication table for : ", number)
for i in range(1,11) :
print(number,"x",i,"=", number*i)