Test One Questions

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What would the following display? num=99 num=5 print(num)

5

Which of these statements will cause an error? A - x = 17 B - 17 = x C - x = 99999 D - x = '17'

B: 17=x

A(n)______variable keeps a running total

accumulator

A(n) _________ is a set of well defined logical steps that must be taken to perform a task

algorithm

A________ is a diagram that graphically depicts the steps that take place in a program

flowchart

Write a for loop that prints the words 'hello world' 7 times.

for i in range(7): print('hello world')

Write a loop that prints your four favorite colors from a list

for mycolor in ['red','orange','green','blue]: print('a color is:', mycolor)

Write a while loop that lets the user enter a number. The number should be multiplied by 10, and the result assigned to a variable named product the loop should iterate as long as product is less than 100

product=0 while product<100: num=int(input('enter a number')) product=num*10 print(product)

Write a python program that uses a loop to ask the user for 10 numbers and adds them together to print the result

result=0 for i in range(10): num=int(input('enter a number')) result=result+num print('result is:', result)

Explain the difference between these 2 fragments of code: x=7 print(x) And x=7 print('x')

the first one will print 7 and the second one will print x

This symbol marks the beginning of a comment in python

#

A_______ is a name that references a value in the computers memory

Variable

A______ controlled loop uses a true/false condition to control the number of times that it repeats

condition

A_______controlled loop repeats a specific number of times

count

A ________ structure executes a set of statements only under certain circumstances

decision

A string literal in python must be enclosed in_______.

either single or double quotes

Write python code that prompts the user to enter his/her height and assigns the users input to a variable named 'height'

height=input('enter your height')

Write an if statement that assigns 20 to the variable y and 40 to the variable z if the variable x is greater than 100

if x>100: y=20 z=40

A(n)______loop has no way of ending and repeats until the program is interrupted

infinite

Each repetition of a loop is known as a(n)______

iteration


Ensembles d'études connexes

Задачі для практики

View Set

Louis pasteur and Ignaz Semmelweis

View Set

LUOA U.S. History Module 1 Study Guide

View Set

Chapter 13 spinal cord, nerve, and reflexes

View Set