ENGR 102 EXAM 1 QUESTIONS AND ANSWERS GRADED A + LATEST UPDATES
5 views 0 purchase
Course
ENGR 102
Institution
ENGR 102
. ENGR 102 EXAM 1 QUESTIONS AND
ANSWERS GRADED A + LATEST
UPDATES
What is an Interpreter? - ANSWER Translates information line by line. Execution often happens
right as the program is interpreted.
Is python interpreted or compiled? - ANSWER Interpreted
How do you p...
. 102 EXAM 1 QUESTIONS AND
ENGR
ANSWERS GRADED A + LATEST
UPDATES
What is an Interpreter? - ANSWER Translates information line by line. Execution often happens
right as the program is interpreted.
Is python interpreted or compiled? - ANSWER Interpreted
How do you print in python? - ANSWER print("Howdy, World!") Note: Will automatically
print a new line at the end of the statement
How does python compute 2+3*4? - ANSWER By using order of operations:
In order it does 3*4 and then adds two so it yields 14
Does python arithmetically follow parenthesis? - ANSWER Yes. Parenthesis take precedence.
How do you take 2 to the power of 10 in python? - ANSWER 2**10
How do you divide a number WITHOUT getting a remainder in python? - ANSWER By using
the // operator.
7//3 = 2
How do you get the remainder from a division operation in python? - ANSWER Using the
modulo: % operator.
7%3=1
How do you use the math library in python? - ANSWER #first method
from math import *
cos(0)
#second method
import math
math.cos(0)
#third method
from math import cos
cos(0)
What can variable names start with in python? - ANSWER A letter (uppercase or lowercase)
Underscore (NOT recommended)
,What can a python variable name contain? - ANSWER Letters (uppercase or lowercase)
Numbers (CANNOT be the first character in the name)
Underscore Characters
What sort of words can variables NOT be? - ANSWER Reserved Keyword
Examples:
for
while
What is the value of the variable PI at the end of this program?
PI = 3
r=5
area = 3 ** r***2
r += 2
PI = 10 - ANSWER PI is 10
What is the value of the variable r at the end of this program?
PI = 3
r=5
area = 3 ** r***2
r += 2
PI = 10 - ANSWER 7
What is the value of the variable area at the end of this program?
PI = 3
r=5
area = 3 ** r***2
r += 2
PI = 10 - ANSWER 75
What type of variable types can be printed using the print(x) function? - ANSWER A constant
fixed value
A variable
An expression
What are the common variable types in python? - ANSWER Integers
Floating-Point Numbers
Booleans
Strings
What is an integer? - ANSWER Integers - Can be positive or negative.
Examples:
1
2
100
0
, -20
What is a floating point number? - ANSWER Numbers with a decimal point.
Examples:
1.01
2.0
100.0
-20.05
0.0005
What is a boolean? - ANSWER A value of True or False
What is a string? - ANSWER A way of describing text. Individual characters that are "strung"
together.
How do you indicate that something is a string in python? - ANSWER Using either "" or ''.
"This is a string"
'So is this'
How would I print the following phrase in python:
Sam's dog bit me - ANSWER print("Sam's dog bit me")
How would I print the following phrase in python:
She said that "I need to study." - ANSWER print('She said that "I need to study."')
How do we include both ' and " in a string? - ANSWER 1. Use triple quotes to begin/end string
'''He said "I'm tired." '''
"""He said "I'm tired." """
2. Use the backslash (\) as an "escape" character:
'He said "I\'m tired." '
"He said \"I'm tired.\" "
How do you print a backslash (\)? - ANSWER print('Backslash: \\1')
Output:
Backslash: \1
How do you print a tab? - ANSWER print('Tab: \t2')
Output:
Tab: _____2
How do you print a new line? - ANSWER print('Newline: \n3')
Output:
Newline:
3
how do you print a backspace? - ANSWER print('Backspace: \b4')
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller TheExamMaestro. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $13.99. You're not tied to anything after your purchase.