Midterm study guide explanations only

# Midterm study guide explanations only - CST 100 Midterm...

• Test Prep
• 4

This preview shows pages 1–2. Sign up to view the full content.

CST 100 Midterm Study Guide Explanations to Answers 1) In IDLE, the default file extension is .py. 2) According to Chapter 1 -M1, many modern languages use both compiled and interpreted processes. They are first compiled into a lower level language, called byte code, and then interpreted by a program called a virtual machine. Python uses both processes, but because of the way programmers interact with it, it is usually considered an interpreted language. 3) Basic addition. 3+2 = 5 4) In Python, booleans can return True or False, as well as 1 or 0. In this case, check_x() is checking to see if number is 0 or 1. Since the number is 99, it skips to the else statement and prints out “number is equal to.” 5) x is 49. The first if statement checks if x is greater than or equal to 49. Since x equals 49, it will print XLIX. 6) x = 49. Since x does not equal 0, it will print exclamation. 7) You cannot assign an array element to a string. You would have to split the string and turn it into a string array, and then assign the 0th element to j. 8) x = 1. The outer for loop (i) goes from 0 to 1. The inner for loop (j) goes from 0 to 1. In the first iteration, x = x+1, which is 1+1, or 2. It keeps going through the for loops until it reaches the end of the outer and inner loops. X = 1+1+1+1+1 = 5 9) Explanation: For every i that can take the values 0 and 1 there will be a j that can take values of 0 or 1. Therefore, the print statement will be executed 2*2 = 4 times. 10) The ** denotes an exponential calculation on operators. So 3**4 means 3 to the 4th power (or 3^4). C = 3**2 evaluates to 3^2, which is 9. 11) c = 4*3, so c = 12. c += 1 -> 12+1 = 13 12) 7/3 = 2, with remainder 1. The modulus operator (%) deals with remainders, so 7 % 3 is 1 13) // means division. 7/3 = 2.333, which is rounded down to 2, since the variables are integers. 14) 7+3 = 10 15) Variable names cannot start with digits. 3bears is not a valid variable name, so it returns a syntax error.

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Fall '15
• Equals sign, ASCII, loop, relational operator

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern