Python Checkpoint Chapter 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Look at the following assignment statements: value1 = 99 value2 = 45.9 value3 = 7.0 value4 = 7 value5 = 'abc' After these statements execute, what is the Python data type of the values referenced by each variable?

value1 will reference an int . value2 will reference a float . value3 will reference a float . value4 will reference an int . value5 will reference an str (string).

What is pseudocode?

An informal language that has no syntax rules and is not meant to be compiled or executed. Instead, programmers use pseudocode to create models, or "mock-ups," of programs.

Who is a programmer's customer?

Any person, group, or organization that is asking you to write a program

What will be displayed by the following program? my_value = 99 my_value = 0 print(my_value)

0

What value will be assigned to result after the following statement executes? result = 9 % 2

1

What value will be assigned to result after the following statement executes? result = 9 // 2

4

Which of the following are illegal variable names in Python, and why? x 99bottles july2009 theSalesFigureForFiscalYear r&d grade_report

99bottles is illegal because it begins with a number. r&d is illegal because the & character is not allowed.

What is a flowchart?

A diagram that graphically depicts the steps that take place in a program

What is a variable?

A name that references a value in the computer's memory

What is an algorithm?

A set of well-defined logical steps that must be taken to perform a task

What is a software requirement?

A single function that the program must perform in order to satisfy the customer

2.19 Complete the following table by writing the value of each expression in the Value column. Expression Value 6 + 3 * 5 ______ 12 / 2 − 4 ______ 9 + 14 * 2 − 6 ______ (6 + 2) * 3 ______ 14 / (11 − 4) ______ 9 + 12 * (8 − 3) ______

Here is the completed table: Expression Value 6 + 3 * 5 21 12 / 2 − 4 2 9 + 14 * 2 − 6 31 (6 + 2) * 3 24 14 / (11 − 4) 2 9 + 12 * (8 − 3) 69

Is the following assignment statement valid or invalid? If it is invalid, why? 72 = amount

It is invalid because the variable that is receiving the assignment (in this case amount ) must appear on the left side of the = operator.

Is the variable name Sales the same as sales? Why or why not?

No, it is not because variable names are case sensitive.

What do each of the following symbols mean in a flowchart? • Oval • Parallelogram • Rectangle

Ovals are terminal symbols. Parallelograms are either output or input symbols. Rectangles are processing symbols.

What will the following code display? val = 99 print('The value is', 'val')

The value is val.

You need the user of a program to enter a customer's last name. Write a statement that prompts the user to enter this data and assigns the input to a variable.

last_name = input("Enter the customer's last name: ")

Write a statement that displays the following text: Python's the best!

print("Python's the best!")

Write a statement that displays your name.

print('Jimmy Smith')

Write a statement that displays the following text: The cat said "meow."

print('The cat said "meow"')

You need the user of a program to enter the amount of sales for the week. Write a statement that prompts the user to enter this data and assigns the input to a variable.

sales = float(input('Enter the sales for the week: '))


Kaugnay na mga set ng pag-aaral

Florida 240 Practice exam questions and answers

View Set

The Nursing Process & Pharmacology-Evolve Chpt. 4

View Set

Charlie y Sophie llegan a El Salvador

View Set

Intro to Business: Business Terms 4

View Set

Guide to operating systems Exam 1

View Set