• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 7 páginas
Resumen

Summary computer science alevel ocr notes questions answers and project!

Document preview thumbnail
Vista previa 2 fuera de 7 páginas

This is perfect as it has revision notes, summary notes, detailed notes and even questions and answer. Also a BONUS of example programming projects such as programming a calculator. Worth it!!!!

Vista previa del contenido

#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)

Información del documento

Nivel de Estudio
Tema
Subido en
15 de febrero de 2023
Número de páginas
7
Escrito en
2022/2023
Tipo
Resumen
$8.95

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
2
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes