Podcast
Questions and Answers
What is the primary goal of the unification process?
What is the primary goal of the unification process?
- To provide a consistent learning experience for every student. (correct)
- To enhance the use of generative AI in assignments.
- To increase the number of quizzes each semester.
- To standardize the textbook across all courses.
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?
- Graded activities breakdown (correct)
- Lecture slides
- Class syllabus
- Solved exercises
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?
- 15%
- 10%
- 25% (correct)
- 30%
How many pop quizzes will students take during the semester?
How many pop quizzes will students take during the semester?
What is explicitly prohibited in assignments according to the course guidelines?
What is explicitly prohibited in assignments according to the course guidelines?
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'?
What does the double equal sign (==) signify in Python?
What does the double equal sign (==) signify in Python?
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?
What does the function 'id()' return in Python?
What does the function 'id()' return in Python?
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?
What will the input function always return, regardless of the user input?
What will the input function always return, regardless of the user input?
How can you convert a numeric string to an integer in Python?
How can you convert a numeric string to an integer in Python?
What is the ASCII value of the character 'a'?
What is the ASCII value of the character 'a'?
What will the following code output? print(ord('A'))
What will the following code output? print(ord('A'))
If 'my_string' = 'python', what would my_string[2] return?
If 'my_string' = 'python', what would my_string[2] return?
What does the chr() function do in Python?
What does the chr() function do in Python?
What is the proper way to define a string in Python?
What is the proper way to define a string in Python?
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()?
What does the method list.remove(item) accomplish?
What does the method list.remove(item) accomplish?
How is an empty list created in Python?
How is an empty list created in Python?
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')?
Which method correctly retrieves and returns the last item of a list?
Which method correctly retrieves and returns the last item of a list?
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)?
What does the .count(item) method return?
What does the .count(item) method return?
What does the statement my_list = list(name) do if name = 'python'?
What does the statement my_list = list(name) do if name = 'python'?
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?
Which of the following methods will sort a list in ascending order?
Which of the following methods will sort a list in ascending order?
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('-'))?
In decision structures, what do boolean expressions evaluate to?
In decision structures, what do boolean expressions evaluate to?
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?
What will be the result of: print(list('I love python'))?
What will be the result of: print(list('I love python'))?
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?
What does the min(myList) function return?
What does the min(myList) function return?
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'))?
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?
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())?
Flashcards are hidden until you start studying
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 integersfloat()
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 valuechr(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 itemdel list[index]
removes the item at the specified indexlist.pop()
removes and returns the last itemlist.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 itemmin(myList)
: returns the minimum value in the listmax(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 Trueor
: at least one condition must be Truenot
: negates a condition
Loops
- Loops allow code to be executed repeatedly
for
loop: iterates through a sequencewhile
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.