Starting from:

$25

METCSS521-Assignment 1 Solved

Complete the following problems from the textbook: 1, 2, 3, 4, 5, 6, 7, 8, 11, 12 (pages 78 - 79)

 

1.     What is a program?

 

2.     Python is an interpreted language. What does “interpreted” mean in this context?

 

3.     What is a Python comment? How do you indicate a comment? What purpose do they serve?

 

4.     What is a namespace in Python?

 

5.     Whitespace:

a.     What is whitespace in Python?

b.     When does whitespace matter?

c.      When does whitespace not matter?

 

6.     Explain the difference between a statement and an expression. Give an example of both, and explain what is meant by a statement having a side effect.

 

7.     Mixed operations:

a.     What type results when you divide an integer by a float? A float by an integer?

b.     Explain why that resulting type makes sense (as opposed to some other type).

 

8.     Consider integer values of a, b, and c, and the expression (a + b) * c. In mathematics, we can substitute square brackets, [], or curly braces, {}, for parentheses, (). Is that same substitution valid in Python? Try it.

 

11.  Assignment:

my_int = 5
my_int = my_int + 3
print(my_int)

a.     If you execute the three lines of code, what will be printed? Explain your answer using the rules of assignment.

b.     Rewrite my_int = my_int + 3 using the += symbol

 

12.  Assignment:

     my_var1 = 7.0
     my_var2 = 5
     print(my_var1 % my_var2)

If you execute these three lines of code, what will be printed?

More products