CISC 121 EXAM QUESTIONS & ANSWERS 2024/2025
What is a Python 3 program? - ANSWERSA Python 3 program is a file that only contains text that conforms to the syntax of the Python 3 programming language
How is a Python 3 file created and edited? - ANSWERSUsing a text editor, which is distinct f...
What is a Python 3 program? - ANSWERSA Python 3 program is a file that only contains text that
conforms to the syntax of the Python 3 programming language
How is a Python 3 file created and edited? - ANSWERSUsing a text editor, which is distinct from - and
usually far less complex than - a word processing program like word.
It is most common to use a text editor that includes features friendly to Python programming. These
features might include:
-> Colourizing code to highlight certain common features of it;
-> Allowing for quick execution of a program using a "run" button;
-> Allowing the capture for analysis of any output from the program;
-> Debugging tools helpful for locating and fixing errors in programs;
Integrated development environments (IDEs) - ANSWERSAn IDE is a program that embodies some or all
the features described on the previous slide and perhaps many more.
An IDE called IDLE comes with downloads of Python 3. It's meant for beginners, and is usually not used
by experience Python programmers, but it's free and readily available.
Data vs code - ANSWERSWe tend to think of code as being the unchanging part of a program that
consists mostly of instructions that implement some algorithm, and data as the information those
instructions act on.
Data types - ANSWERSnumbers, strings and booleans
Numbers - ANSWERSPython's interpreter categorizes a number as either an int (integers, that is positive
or negative whole numbers) or a float (positive or negative numbers that may contain a fractional
portion)
,The way Python stores its floats means that they are usually just approximations of actual values. This is
because the number of bits used for storing a number is fixed, so the number of available float values is
finite, and values are stored internally in binary.
Python places no arbitrary length on the number if digits used in its integers.
Strings - ANSWERSStrings appear in Python programs as collections of zero or more characters
surrounded by either single quotes or double quotes.
A surprisingly useful entity in programming is the empty string, " ", that is, the string containing no
characters, said to have a length of 0.
Triple-quoted docstrings can be used for multi-line text, through using another escape code, \n, can also
let you build a regular string that, when displayed, shows up on more than one line in the screen.
There's a variety of text in Python 3 called an f-string that comes in handy when displaying various types
of data. You can recognize them in code by a lower or uppercase letter "f" that precedes their opening
quotation mark. f"Today is {day_name}."
Booleans - ANSWERSAn expression that evaluates to True or False
Variables - ANSWERSVariables in Python must be named as follows:
-> The name must start with a letter or an underscore
-> The rest of the name may contain letters, the numerals o through 9, or underscores, but no spaces.
-> Camel case
-> Snake case
Assignment - ANSWERSWhen we give a value to a variable in the way, we are performing what's called
an assignment. In Python, the equals sign, =, is used as the assignment operator. (count = 0)
The value of one variable can be copied to another in an assignment.
The creation of a new variable is called a declaration, and giving a variable its first value is often called
initialization. Declaration and initialization always occurs in the same step in Python 3.
Expressions - ANSWERSAn expression is anything that is a literal, or a variable or has some computable
value.
In an assignment statement, the part on the right of the assignment operator is an expression.
, Expressions are frequently formed using data operands joined by operators.
Arithmetic operators - ANSWERS+ addition
- subtraction
* multiplication
/ divison
// integer divison
% modulus
** power
String concatenation - ANSWERSThe joining of two strings using +.
The string "in" operator - ANSWERSComputes to true because the string on the left of the in operator
form all or part of the strings on the right of the in operator.
"moth" in "grandmother"
Using "not in" with strings - ANSWERSPutting the operator not in front of the in operator reverses the
meaning of in
Mixing numbers and strings in expressions - ANSWERSA common way to concatenate numbers with
strings is to convert the numeric parts of a mixed-types expression to strings. Converting between data
types is called casting, and a typical way of casting a number to a string, so that it may be concatenated
to other string, is str(age).
f-strings give us a way to more easily blend variables and other expression into single strings message =
f"{name} is {age} years old."
Comparison operators - ANSWERSComparison operators are typically used in comparisons of numbers
with numbers and strings with strings in so-called Boolean expressions. The result of such comparisons is
always either True or False.
Comparison operators play an important role in searching and sorting collection of data.
Voordelen van het kopen van samenvattingen bij Stuvia op een rij:
√ Verzekerd van kwaliteit door reviews
Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!
Snel en makkelijk kopen
Je betaalt supersnel en eenmalig met iDeal, Bancontact of creditcard voor de samenvatting. Zonder lidmaatschap.
Focus op de essentie
Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!
Veelgestelde vragen
Wat krijg ik als ik dit document koop?
Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.
Tevredenheidsgarantie: hoe werkt dat?
Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.
Van wie koop ik deze samenvatting?
Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper Bensuda. Stuvia faciliteert de betaling aan de verkoper.
Zit ik meteen vast aan een abonnement?
Nee, je koopt alleen deze samenvatting voor €10,20. Je zit daarna nergens aan vast.