When writing answers to questions, please use proper grammar, capitalization,
and punctuation. Please limit the length of each line to 80 characters.
- Write a line of code that will print your name.
- How do you enter a comment in a program?
- What do the following lines of code output?
ALSO: Why do they give a different answer?
print(2 / 3)
print(2 // 3)
- Write a line of code that creates a variable called pi and sets
it to an appropriate value.
- Why does this code not work?
A = 22
print(a)
- All of the variable names below can be used. But which ONE of these is
the better variable name to use?
a
A
Area
AREA
area
area_of_rectangle
Area_Of_Rectangle
- Which of these variables names are not allowed in Python? (More than one
might be wrong. Also, this question is not asking about improper names, just
names that aren't allowed. Test them if you aren't sure.)
apple
Apple
APPLE
Apple2
1Apple
account number
account_number
account.number
accountNumber
account#
pi
PI
fred
Fred
GreatBigVariable
greatBigVariable
great_big_variable
great.big.variable
2x
x2x
total%
#left
- Why does this code not work?
print(a)
a = 45
- Explain the mistake in this code:
pi = float(3.14)
- This program runs, but the code still could be better. Explain what is
wrong with the code.
radius = float(input("Radius:"))
x = 3.14
pi = x
area = pi * radius ** 2
print(area)
- Explain the mistake in the following code:
x = 4
y = 5
a = ((x) * (y))
print(a)
- Explain the mistake in the following code:
x = 4
y = 5
a = 3(x + y)
print(a)
- Explain the mistake in the following code:
radius = input(float("Enter the radius:"))
- Do all these print the same value? Which one is better to use and why?
print(2/3+4)
print(2 / 3 + 4)
print( 2 / 3+ 4 )
- What is a constant?
- How are variable names for constants different than other variable names?
- What is a single quote and what is a double quote?
Give and label an example of both.
- Write a Python program that will use escape codes to print a double-quote
and a new line using the Window's standard. (Note: I'm asking for the Window's
standard here. Look it up out of Chapter 1.)
- Can a Python program print text to the screen using single quotes instead
of double quotes?
- Why does this code not calculate the average?
print(3 + 4 + 5 / 3)
- What is an ``operator'' in Python?
- What does the following program print out?
x = 3
x + 1
print(x)
- Correct the following code:
user_name = input("Enter your name: )"
- Correct the following code:
value = int(input(print("Enter your age")))