Podcast
Questions and Answers
What command gives a quick list of defined symbols in Python?
What command gives a quick list of defined symbols in Python?
What aspect of a piece of code affects its meaning in Python?
What aspect of a piece of code affects its meaning in Python?
How are logical connectors spelled out in Python?
How are logical connectors spelled out in Python?
What is the value of an empty string in Python boolean operations?
What is the value of an empty string in Python boolean operations?
Signup and view all the answers
What prefix is used to create a raw string literal in Python?
What prefix is used to create a raw string literal in Python?
Signup and view all the answers
What is the length of the string r'x\nx'?
What is the length of the string r'x\nx'?
Signup and view all the answers
What is the return value of list.append() in Python?
What is the return value of list.append() in Python?
Signup and view all the answers
What does REPL stand for in Python?
What does REPL stand for in Python?
Signup and view all the answers
What is the term for testing individual units of source code?
What is the term for testing individual units of source code?
Signup and view all the answers
What is the smallest testable part of an application?
What is the smallest testable part of an application?
Signup and view all the answers
Study Notes
Python Functions
-
round(45.8)
returns the rounded value of 45.8 -
round(6352.898,2,5)
is not a valid syntax for theround
function -
round()
without arguments is not a valid function call -
round(7463.123,2,1)
is not a valid syntax for theround
function
Python Data Types
- The
id
function returns an integer value that is unique for each object - In Python, you do not specify types, it is directly interpreted by the compiler
- The
//
operator is used for integer division in Python 3.0 - The
int(..)
function is used to type cast a value to an integer
Python Operations
- The
*
operator is used for string repetition, not mathematical multiplication - The
+
operator is used for string concatenation, not mathematical addition - The
/
operator is used for float division, not integer division
Python Syntax
- Indentation is required for Python codes to be executed correctly
- You cannot perform mathematical operations on strings
- The
def
keyword is used to define a function
Python Data Structures
- A list stores values of any data type, including strings and integers
- A dictionary stores values in terms of keys and values
- An array is not a built-in data structure in Python
Python String Operations
- The
print
function can be used to display strings with newline characters (\n
) - Strings can be concatenated using the
+
operator - Strings can be repeated using the
*
operator
Python Class and Objects
- An object represents an entity in the real world with its identity and behavior
- A class defines an object
- A constructor is used to create an object with assigned values to its members
Python Miscellaneous
- The
trunc
function returns an integer value - The
help
function can be used to get details of a function or module - The
dir
function gives a quick list of defined symbols in Python - Logical connectors are spelled out with letters
- Whitespace indentation affects the meaning of Python code
- Empty string is counted as
False
in Python boolean operations - A "raw" string literal is prefixed by an
r
and passes all characters through without special treatment of backslashes -
REPL
stands for Read-Evaluate-Print-Loop - Unit testing is a method by which individual units of source code are tested to determine if they are fit for use
- A unit is the smallest testable part of an application
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Multiple choice questions about Python functions including round and id functions.