cmp 111

¡Supera tus tareas y exámenes ahora con Quizwiz!

What symbol is not a valid string operation? (+,*,-,>,/)

/

input: sum = 0 num = 10 if num > 0 sum = sum+10 elif num > 5 sum = num +15

10

what is the output of: hours = 1 mins = 6 secs = 39 print("{:02}:{02}:{02}").format(hours, mins, secs)

11:06:39

score=12.345 print("{:.2f}".format(score)) output?

12.35

when was python language written?

1990s

count = 1 num = 25 while count < 25 : num = num - 1 count = count + 1 print(count, num)

25 1

What is the output of the following code: list = [1, 2, 4, 8, 16] sum = 0 for num in list: sum = sum + num print(sum)

31

counter = 0 while counter <= 30: counter += 3 print(counter)

33

This code uses a for loop to print "Hi" _____ times. for i in range (1,10,2) : print ("Hi")

5

Boolean operator

An operator that combines Boolean conditions; ex. and, or, not

Which is an example of a control structure?

Condition

overloaded operator

It performs different functions based on the type of operands that it is applied to.

>>> sentence = 'Programming' + ' is fun!' >>> print(sentence) >>> print(sentence[0]) >>> print(sentence[5]) >>> print(sentence[0:10]) >>> print(sentence[5:10]) >>> print(sentence[:5]) >>> print(sentence[5:])

Programming is fun! P a Programmin ammin Progr amming is fun!

Boolean variable

To store a condition that can be True or False; bool data type represents the boolean type; TRUE or FALSE

concatenation operator

When + has two string operands

explicit line joining

Writing a logical line spanning many physical lines

complier

a program that translates instruction written in high-level languages into machine code

statement

a python instruction that causes the comp to perform some action after it is executed or processed by the computer

loop

a statement that is used to: execute one or more statements repeatedly until a goal is reached. Sometimes these one-or-more statements will not be executed at all—if that's the way to reach the goal. executes repeatedly while some condition remains true

What does this print? for i in range (2) : print ("a",end="") for j in range (2) : print ("b",end="")

abbabb

event-controlled loop

an event changes the loop control expression from true to false. Indefinite repetition Used when number of repetitions not known Sentinel value indicates "end of data" Explicit (controlled by the loop) or implicit (controlled by some external condition) updating process

to develop a program to solve a problem you must..

analyze the problem

= ==

assigning asking if equal

software

comprises the instructions that govern the computer systems functioning

example of a control structure

condition

intepreter

converts and executes one statement at a time

A(n) ____ is a numeric variable used for counting something, such as the number of employees paid in a week.

counter

A loop that continues to execute endlessly is called a(n) ____ loop.

infinite

The repetition structure is referred to more simply as a(n) ____.

loop

In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s)

looping

run time error

occurs when theres an illegal operation

sequental

print the value of product

Initialization or population of a variable

putting a value into the variable when it is created.

Values that are used to end loops are referred to as ____ values.

sentinel

values

string, integer, float

identifier

the name of the variable (garage name) - allows us to name data and other objects in the program - cannot be any special names known as reserved words or keywords like float or string etc. name of a memory location - should help you remember its purpose

range

to iterate over a sequence of numbers range([start],stop,[step])

pass statement for loops

used in Python to indicate an empty block of statements.

break statement for loops

used to break out of a loop statement i.e. stop the execution of a looping statement, even if the loop condition has not become False or the sequence of items has been completely iterated over.

if statement

used to implement a decision. When a condition is fulfilled,one set of statements is executed. Otherwise,another set of statements is executed; if statements when nested must be indented

variable

used to store information - the contents of the variable (garage)

continue statement for loops

used to tell Python to skip the rest of the statements in the current loop block and to continue to the next iteration of the loop.

Nested

when one control statement is located within another

counter-controlled loop

when we know the number of times an action is to be repeated. Definite repetition: know how many times loop will execute Control variable used to count repetitions

semantic error

when you want to output something but it is not giving the intended results, but it is still outputting something. ex. average= #1 + #2 / 2 when u actually mean average=(#1+#2)/2

loop statements

while - event control for - counter control

What does the following code print? score = 12345 print=("{:->8,}".format(score))

--12,345

if 6 > 8: print(" ** ") print(" **** ") elif 9 == 4: print(" *** ") else: print(" * ")

*


Conjuntos de estudio relacionados

Adaptations to Life on Land, the Evolution of Land, Non-Vascular, and Vascular Plants, and Classifying Vascular Plants

View Set

Chapter 40- Care of patients with Hematologic Problems

View Set

Health assessment practice questions

View Set

Fundamentals of Nursing compiled practice quiz questions

View Set

Writer's Workshop: Writing a Research-Based Informative Essay about Language quizes

View Set

Language Arts Semester Exam Study Guide

View Set

Chapter 9 (Agents and Principals)

View Set

Combo with "Child Abuse and Neglect (CAAN)" Module 1 and 2

View Set

[G11 STEM] Oral Communication L3: Verbal and Non-verbal Communication

View Set

Chapter 4: Printers and Multi-function Devices

View Set