Description
State whether true or false:

The best way to write a program is to immediately type in some code and then debug it until it works.

An algorithm can be written without using a programming language.

Programs no longer require modification after they are written and debugged.

Python identifiers must start with a letter or underscore.

Keywords make good variable names.

Expressions are built from literals, variables, and operators.

In Python, x = x + 1 is a legal statement.

Python does not allow the input of multiple values with a single statement.

A counted loop is designed to iterate a specific number of times.

In a flowchart, diamonds are used to show statement sequences, and rectangles are used for decision points.

Information that is stored and manipulated by computers is called data.

Since floatingpoint numbers are extremely accurate, they should generally be used instead of integers.

Operations like addition and subtraction are defined in the math library.

The number of possible arrangements of n items is equal to n!

The sqrt function computes the squirt of a number.

The float data type is identical to the mathematical concept of a real number.

Computers represent numbers using base2 (binary) representations.

A hardware float can represent a larger range of values than a hardware integer.

Type conversion functions such as float are a safe alternative to eval() for getting a number as user input.
Multiple Choice

Which of the following is not a step in the software development process?

specification

testing/Debugging

fee setting

maintenance


What is the correct Python formula for converting Celsius to Fahrenheit?

F = (9/5)*C + 32

F = 5/9*C 32

F=B^{2}4AC

F = (21232)/100


The process of describing exactly what a computer program will do to solve a problem is called


design

implementation

programming


Which of the following is not a legal Python identifier?

Spam

spAm

2spam



spam 4U


Which of the following are not used in expressions?

Variables

Statements

Operators

literals


Fragments of code that produce or calculate new data values are called

identifiers

expressions



productive clauses

assignment statements


Which of the following is not a builtin Python data type?

int

float

rational

string


Which of the following is not a builtin operation?

+



%

abs ()

sqrt ()


In order to use functions in the math library, a program must include

a comment

a loop

an operator

an import statement


The value of 4! is

9

24

41

120


The most appropriate data type for storing the value of pi is

Int

Float

Irrational



string


In a mixedtype expression involving ints and floats, Python will convert


floats to ints

ints to strings

both floats and ints to strings

ints to floats

Discussion:
1 Show the result of evaluating each expression. Be sure that the value is in the proper form to indicate its type (int or float). If the expression is illegal, explain why.
2 Translate each of the following mathematical expressions into an equivalent Python expression. You may assume that the math library has been imported (via import math).
Programming Exercises:

Write a program that converts temperatures from Fahrenheit to Celsius.

Write a program that converts distances measured in kilometers to miles. One kilometer is approximately 0.62 miles.

Write a program to perform a unit conversion of your own choosing. Make sure that the program prints an introduction that explains what it does.

Write a program to find the roots of the equation ax^{2}+bx+c=0. You read the input parameters a, b, and c from the user emphasizing that the program finds only real roots.

Let a, b, c be the lengths of the sides of a triangle. The area is given by:
= √ ( − )( − )( − ), ℎ ℎ ℎ . Write a program to read the triangle sides and compute its area.