CHAPTER 3 Intro to Programming Flashcards
In coding, IDLE, the color-coded text represents_____ and all the text that comes after “»” represents the______.
code output of the interactive shell
Courier New is a type of fix-width (non-proportional) font often used to display programming text why ?
because each character has the same width, so indentation and other display characteristics of code alignment are easier to observe.
Explain what a comment is?
A comment is a line (or part of a line) of code written in English (or another language) preceded by a special symbol that tells the programming language you are using to ignore that line (or part of a line) of code.
In Python, what symbol is used to create comment
pound symbol
What does a comment explain?
It explain what a line of code does
Programmers use comments to
clarify why they did something to make the line of code easier to understand for whoever
What can you write in a ‘COMMENT’?
You can write whatever you want in a comment
How long should the “comment” be
as long as it is only ONE LINE
When should you use comments
Use comments sparingly; do not comment on every line
Explain the use of a comment like this:
d = math.sqrt(l2 + w2) # length of the diagonal
Even if you understood exactly how this code works , you
still might not know how to calculate the length of a diagonal of a rectangle, which is why this
comment is useful.
Python programs are divided into
lines of code.
Print is indented by how many spaces?
4 spaces
Without proper _____, your program will not work.
spacing
Different kinds of data in Python are grouped into different
categories, or data types .
In python, each data value, like 2 or “Hello, World!” , is called an _____
object
For now, think of An object as a
data value in Python with three properties: an identity, a data type and a value (IDV)
The value of an object is the ______ it represents—
Data it represents; the number 2, for example, has a value of 2.
The identity of an object is where it is
stored in memory, which never changes (and which we will be ignoring for now).
The data type of an object is the ________of data the object belongs to
is the category of data the object belongs to, and determines the properties the object has.
What the determines the properties the object has?
The data type
When we refer to an object with a str data type, we call it a string; what is a string?
A string is a sequence of one or more characters surrounded by quotes.
You can use single quotes or double quotes, but the quotes at the beginning and end of a given string musT
match
“Hello World” is an example of what kind of data?
string
Strings are used to represent _______, and they have unique ______
text; properties
Whole numbers have the data type int , short for _____
integer.
Numbers like 2 , 3 , 4 and 10 all have the data type int. Another way of saying this is they are all
integer
Like strings, integers have their own
properties.
Whole numbers are integers, fractional numbers (numbers with a decimal point) have a different data type called
float
Like all data types, floats have their own
properties and behave in a certain way.
Objects with a bool data type have a value of either TRUE OR FALSE are called what?
have a value of either True or False and are called
booleans:
Objects with a data type NoneType always have the value
None
Objects with a
NoneType data type are used to represent the
absence of a value:
What is a constant?
A value that never changes\
for example : the value 2 does not change
A variable , on the other hand, refers to a value; but that value cha____cant/can change
can
A variable consists of ______
a name made up of one or more characters
Often programmers want to increment or decrement variables, Python has a special syntax—a shortcut—for incrementing and decrementing variables. To
increment a variable
you assign the variable to itself, and on the other side of the equals sign you add the variable to the number you want to increment by
Provide an example on how you can increment the variable–> x =12 but you want to increase to 14
x=12
x=x+2
x
»>14