Podcast
Questions and Answers
What is the primary goal of the unification process?
What is the primary goal of the unification process?
Which of the following materials is NOT listed to be available on the course website?
Which of the following materials is NOT listed to be available on the course website?
What percentage of the final grade is assigned to the mid-term exam?
What percentage of the final grade is assigned to the mid-term exam?
How many pop quizzes will students take during the semester?
How many pop quizzes will students take during the semester?
Signup and view all the answers
What is explicitly prohibited in assignments according to the course guidelines?
What is explicitly prohibited in assignments according to the course guidelines?
Signup and view all the answers
What will happen if you execute the statement 'y = y + 10' before creating 'y'?
What will happen if you execute the statement 'y = y + 10' before creating 'y'?
Signup and view all the answers
What does the double equal sign (==) signify in Python?
What does the double equal sign (==) signify in Python?
Signup and view all the answers
What will 'type(x)' return after executing 'x = x + 5' if 'x' is initially an integer?
What will 'type(x)' return after executing 'x = x + 5' if 'x' is initially an integer?
Signup and view all the answers
What does the function 'id()' return in Python?
What does the function 'id()' return in Python?
Signup and view all the answers
If you execute 'x = 3 * x + 20' after 'x' has previously been defined as an integer, what will be the data type of 'x' afterwards?
If you execute 'x = 3 * x + 20' after 'x' has previously been defined as an integer, what will be the data type of 'x' afterwards?
Signup and view all the answers
What will the input function always return, regardless of the user input?
What will the input function always return, regardless of the user input?
Signup and view all the answers
How can you convert a numeric string to an integer in Python?
How can you convert a numeric string to an integer in Python?
Signup and view all the answers
What is the ASCII value of the character 'a'?
What is the ASCII value of the character 'a'?
Signup and view all the answers
What will the following code output? print(ord('A'))
What will the following code output? print(ord('A'))
Signup and view all the answers
If 'my_string' = 'python', what would my_string[2] return?
If 'my_string' = 'python', what would my_string[2] return?
Signup and view all the answers
What does the chr() function do in Python?
What does the chr() function do in Python?
Signup and view all the answers
What is the proper way to define a string in Python?
What is the proper way to define a string in Python?
Signup and view all the answers
What will happen if you input a non-numeric string and try to convert it to an integer using int()?
What will happen if you input a non-numeric string and try to convert it to an integer using int()?
Signup and view all the answers
What does the method list.remove(item) accomplish?
What does the method list.remove(item) accomplish?
Signup and view all the answers
How is an empty list created in Python?
How is an empty list created in Python?
Signup and view all the answers
What will happen if you try to print(names) after executing names = names.remove('Sansa')?
What will happen if you try to print(names) after executing names = names.remove('Sansa')?
Signup and view all the answers
Which method correctly retrieves and returns the last item of a list?
Which method correctly retrieves and returns the last item of a list?
Signup and view all the answers
What will be the output of the following code: names = ['Jon', 'Sansa', 'Arya'], names.insert(50, 'Robb'), print(names)?
What will be the output of the following code: names = ['Jon', 'Sansa', 'Arya'], names.insert(50, 'Robb'), print(names)?
Signup and view all the answers
What does the .count(item) method return?
What does the .count(item) method return?
Signup and view all the answers
What does the statement my_list = list(name) do if name = 'python'?
What does the statement my_list = list(name) do if name = 'python'?
Signup and view all the answers
What will happen if you use del list[index] and the index is out of range?
What will happen if you use del list[index] and the index is out of range?
Signup and view all the answers
Which of the following methods will sort a list in ascending order?
Which of the following methods will sort a list in ascending order?
Signup and view all the answers
What will be the output of the following code: sentence = 'I love python', print(sentence.split('-'))?
What will be the output of the following code: sentence = 'I love python', print(sentence.split('-'))?
Signup and view all the answers
In decision structures, what do boolean expressions evaluate to?
In decision structures, what do boolean expressions evaluate to?
Signup and view all the answers
What is the purpose of the join() method in the context of lists?
What is the purpose of the join() method in the context of lists?
Signup and view all the answers
What will be the result of: print(list('I love python'))?
What will be the result of: print(list('I love python'))?
Signup and view all the answers
What is the correct method to reverse the order of elements in a list?
What is the correct method to reverse the order of elements in a list?
Signup and view all the answers
What does the min(myList) function return?
What does the min(myList) function return?
Signup and view all the answers
What will be the output of: sentence = 'I-love-python', print(sentence.split('o'))?
What will be the output of: sentence = 'I-love-python', print(sentence.split('o'))?
Signup and view all the answers
If names = ['Jon', 'Sansa', 'Arya'] and we execute names.insert(-3, 'Robb'), what will names contain after execution?
If names = ['Jon', 'Sansa', 'Arya'] and we execute names.insert(-3, 'Robb'), what will names contain after execution?
Signup and view all the answers
What will be the output of the following code: print('I love python'.split())?
What will be the output of the following code: print('I love python'.split())?
Signup and view all the answers
Study Notes
Course Unification
- The unification process aims to provide a consistent learning experience for all students, regardless of their section
- Course unification included revisions to academic integrity and code of conduct guidelines
- Generative AI tools are explicitly prohibited for assignments, but can be used for self-learning
- The number of quizzes, assignments, and exams are unified across all sections
Course Material
- All course materials are available on Brightspace including:
- Course syllabus
- Announcements
- Lecture slides (uploaded before class)
- Solved exercises (uploaded after class)
- Homework assignments
- Grades
Textbook
- The textbook used is "How to Think Like a Computer Scientist: Learning with Python 3" by Peter Wentworth, Jeffrey Elkner, Allen B. Downey, and Chris Meyers
- Online version: www.openbookproject.net/thinkcs/
- Interactive edition: https://runestone.academy/ns/books/published/thinkcspy/index.html
Graded Activities
- Class participation: 5%
- Includes interaction and exercises
- Random Quizzes: 10%
- Six pop quizzes are evenly distributed throughout the semester
- Assignments: 15%
- Three total assignments
- Final Project: 15%
- Group project lasting two to three weeks
- Mid-term Exam: 25%
- Held during the last lecture before break
- Final Exam: 30%
- Date is posted on Albert
Python type()
- The built-in
type()
function returns the data type of a value or variable
Python id()
- The built-in
id()
function returns the memory location of a variable
Data Types
-
type(3)
returnsint
(integer) -
type(4.5)
returnsfloat
(floating point number) -
type('abc')
returnsstr
(string) -
type('1')
returnsstr
(string) -
type(True)
returnsbool
(boolean) -
type(None)
returnsNoneType
(None)
Variable Assignments/Re-assignments
- The data type of a variable can change based on the assignment
- The data type is determined at runtime
Python Input
- The
input()
function returns a string value. - To use the input as a numerical value, use type casting:
-
int()
for integers -
float()
for floating point numbers
-
Characters
- Characters are represented by their ASCII numerical codes
ASCII Table
- Every letter, digit, and symbol has a corresponding ASCII number
ASCII-Character Conversion
-
ord(character)
converts a character to its ASCII numerical value -
chr(number)
converts an ASCII numerical value to a character
Recap on Strings
- Strings are sequences of characters
- Strings are defined using single or double quotes (' ', " ")
String Indexing
- Individual characters can be accessed by their index using square brackets
[]
- Index starts from 0
Lists
- Lists are created using square brackets
[]
- Lists are mutable, meaning they can be changed after creation
- List items are indexed from 0
- List slicing returns a new list
Removing an Item from a List
-
list.remove(item)
removes the first occurrence of the provided item -
del list[index]
removes the item at the specified index -
list.pop()
removes and returns the last item -
list.pop(index)
removes and returns the item at the specified index
List Methods and Functions
-
.sort()
: sorts items in ascending order -
.reverse()
: reverses the order of items -
.count(item)
: counts the occurrences of an item -
min(myList)
: returns the minimum value in the list -
max(myList)
: returns the maximum value in the list
Decision Structures
- Program logic can branch based on conditions
- Conditions evaluate to either
True
orFalse
Logical Operators
- Logical operators combine conditions
-
and
: both conditions must be True -
or
: at least one condition must be True -
not
: negates a condition
-
Loops
- Loops allow code to be executed repeatedly
-
for
loop: iterates through a sequence-
while
loop: executes as long as a condition is True
-
-
String Methods
-
.replace(old, new, max)
: replaces old substring with new -
.find(substring, start, end)
: finds first occurrence -
.count(substring, start, end)
: counts occurrences
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the unification process in the course aimed at creating a consistent learning experience for all students. Key aspects include academic guidelines, use of generative AI tools, and centralized course materials. Familiarize yourself with the textbook and available resources to succeed.