Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Variables
Assigning a variable reserves space in the computer's memory for information of a
particular data type (e.g., integer, or float or string).
1.
Cut and paste the following programs into IDLE and carefully examine the output. If
you run across any runtime errors, fix them and rerun your program.
Cut and paste the output of your programs into this document!
a)
a = 123.4
b23 = 'Spam'
first_name = "Bill"
b = 432
c = a + b
print ("a + b is", c)
print ("first_name is", first_name)
print ("Sorted Parts, After Midnight or", b23)
b)
a = 1
print(a)
a = a + 1
print(a)
a = a * 2
print(a)
c)
a = 7
b = a
print(a, b)
d)
a = 7
b = "Michelle is "
c = "years old"
print(b + a + c)
2.
State each variable’s data type. You can check in IDLE using the type command.
a. U = "Python"
b. W = 1.625
c. X = 3/2
d. Y = 5**2
e. Z = "285"
3.
State the final value of A after each sequence of commands. Use the print
command if you like to print out the value of A when the program is executed.
a) A = 25
B = 12
C = A – B
b) A = 25
B = 20
A = B
c)
A = 25
B = 12
A = A + B
4.
Variable names may consist of letters, numbers and underscores. They cannot begin
with a number, nor can they contain spaces. Also, they cannot be any of the
following Python keywords, since they are integral to the interpreter’s operation.
True
False
None
continue
def
del
from
global
not
or
yield
and
as
assert
break
class
elif
else
except
finally
for
if
import
in
is
lambda
nonlocal
pass
raise
return
try
while
with
Here are some examples of inappropriate variable names.
2nd_place = 2
number of people = 10
class = 7
YOU TRY!!!!
Which of the following are acceptable variable names in Python? If a name is
not acceptable, explain why.
a. P
b. bestFriend
c. 12jurors
d. Bx3R28
e. True
true
g. test score
h. soup_of_the_day
i. #ofPlayers
f.