CS 1101 Week 5

Descripción

AS - Level (CS 1101 Python) Computer Science Test sobre CS 1101 Week 5 , creado por Troy Bowlin el 18/05/2016.
Troy Bowlin
Test por Troy Bowlin, actualizado hace más de 1 año
Troy Bowlin
Creado por Troy Bowlin hace más de 8 años
130
1

Resumen del Recurso

Pregunta 1

Pregunta
What does the function subroutine do? def subroutine(n): while n>0: print(n,) n-=1
Respuesta
  • Counts down from 10 to 0 and displays each number
  • Counts from n down to 1 and displays each number
  • Calculates the sum of n numbers greater than 0
  • Calculates the mean of n

Pregunta 2

Pregunta
What output will the following python command produce: >>>percentage = float (60*100)/50 >>>print(percentage)
Respuesta
  • percentage
  • 109
  • 109.0909090909091
  • 109.0

Pregunta 3

Pregunta
What outputs will the following python commands produce: n=10000 count=0 while n: count=count+1 n=n//10 print(count)
Respuesta
  • 5
  • 0
  • 10000
  • 1000

Pregunta 4

Pregunta
What output will the following python commands produce: x=5 if x%2==0: print(x) else: print(x,x%2)
Respuesta
  • 5
  • 5 1
  • 2
  • 5 0

Pregunta 5

Pregunta
What is the output of the following statements? pi=float(3.14159) print(pi)
Respuesta
  • 3
  • 3.0
  • 3.14159
  • 0

Pregunta 6

Pregunta
Expressions evaluate to either True or False:. What will the output of the following code be when the expression "Ni!" is evaluated? if "Ni!" print("We are the knights who say, "Ni!") else print("Stop it! No more of this!")
Respuesta
  • Stop it!
  • We are the knights who say, "Ni!"
  • Stop it! No more of this!
  • No output will be produced

Pregunta 7

Pregunta
What output will the following python commands produce: x=1 y=2 if x==y: print(x,"and",y,"are equal") else if x<y: print(x,"is less than", y) else print(x,"is greater than",y)
Respuesta
  • 1 and 2 are equal
  • 1 is less than 2
  • 1 is greater than 2
  • 2 is greater than 2

Pregunta 8

Pregunta
The following code is an example of what principle? bruce=5 print(bruce,) bruce=7 print(bruce)
Respuesta
  • Multiple Assignment
  • An iteration or loop structure
  • A logical operator
  • A conditional operator

Pregunta 9

Pregunta
The % or modulus operator returns the remainder present when two integers do not divide evenly into one another
Respuesta
  • True
  • False

Pregunta 10

Pregunta
An algorithm is a step by step process for solving a problem
Respuesta
  • True
  • False

Pregunta 11

Pregunta
Functions allow the programmer to encapsulate and generalize sections of code.
Respuesta
  • True
  • False

Pregunta 12

Pregunta
One way to generalize a function is to replace a variable with a value.
Respuesta
  • True
  • False

Pregunta 13

Pregunta
A variable name defined in a function cannot appear in the calling program because it will cause a conflict error.
Respuesta
  • True
  • False
Mostrar resumen completo Ocultar resumen completo

Similar

Computing Hardware - CPU and Memory
ollietablet123
SFDC App Builder 2
Parker Webb-Mitchell
Data Types
Jacob Sedore
Intake7 BIM L1
Stanley Chia
Software Processes
Nurul Aiman Abdu
Design Patterns
Erica Solum
CCNA Answers – CCNA Exam
Abdul Demir
Abstraction
Shannon Anderson-Rush
Spyware
Sam2
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Data Analytics
anelvr