SlideShare a Scribd company logo
Computer Science 151
An introduction to the art of computing
Midterm Review
Rudy Martinez
CS151 Spring 2019
Midterm
When: 3/6 This Wednesday
Exam is 50 minutes.
Closed book, closed computer, no phones, no notes.
Exam is 11 questions 1 extra credit question
During the Exam everyone will need at least one seat empty next to them on
either side.
CS151 Spring 2019
Topics - Booleans:
● Know how the logic conditions work in Conditional statements:
If a > b then:
print(‘Hello’)
● Know And, Or statements
a = 5 b = 7 c = -1
If a > b AND a > c:
print(‘False’)
If a < b OR a > c:
print(‘True’)
CS151 Spring 2019
Topics - Strings
● Know what a string is
● Know how to get the individual characters:
myString = ‘Hello’
myString[4] → ‘o’
● Know how to get the length of a string.
● Know how to use a for loop to iterate over a string.
● Know how to concatenate two strings
● Know how strings are printed with print()
CS151 Spring 2019
Topics - Trace a Program
Know how a program flows:
myString = ‘Hello’
for i in range(0, len(myString), 1):
print(myString[i])
● Know what I is as the loop runs.
● Know how many times the loop will run
● Know what is being printed.
CS151 Spring 2019
Topics - Loops
● For loops
○ Know how to trace them
○ Know how to write them
● While loops
○ Know how to trace them
○ Know how to write them
for i in range(start, stop, increment)
# Do Stuff
while(boolean condition is true)
# Do Stuff
Increment variable that will lead to boolean
eventually being false.
CS151 Spring 2019
Topics - Scope of Variables
● Go back over lecture on Function it has everything you need to know about
scope of variables.
● Know what a global variable is and when it changes.
● Know variables in functions and when they can change.
CS151 Spring 2019
Global Scope vs Local Scope
a = 1
# Uses global because there is no local 'a'
def f():
print('Inside f() : ', str(a))
# Variable 'a' is redefined as a local
def g():
a = 2
print('Inside g() : ',str(a))
# Uses global keyword to modify global 'a'
def h():
global a
a = 3
print('Inside h() : ', str(a))
# Global scope
print('global : ',str(a))
f()
print('global : ',str(a))
g()
print('global : ',str(a))
h()
print('global : ',str(a))
global : 1
Inside f() : 1
global : 1
Inside g() : 2
global : 1
Inside h() : 3
global : 3
CS151 Spring 2019
Topics - Dictionaries
● Know how to create a dictionary
○ Mydictionary = {} # remember curly braces
● Know how to access a value using a key
○ Remember key:value pairs, every key has a value
○ Mydictionary{key} returns value
● Know how to iterate over them in a for loop
○ For loops!
○ For loops!
○ For loops!
CS151 Spring 2019
Stress Management
● Taking exams can be stressful to minimize this:
○ Get plenty of sleep, this help more than cramming for the test.
○ Eat a breakfast/lunch at least an hour before you take the test.
● Cramming doesn’t work, it really doesn’t.
● Positive attitude helps you with the right state of mind for the test.
● Show up to the test early and get ready.

More Related Content

Similar to CS 151 Midterm review

Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revision
afsheenfaiq2
 
Artifact 2 clemson
Artifact 2 clemsonArtifact 2 clemson
Artifact 2 clemson
clemsonj11
 
Threading Is Not A Model
Threading Is Not A ModelThreading Is Not A Model
Threading Is Not A Model
guest2a5acfb
 

Similar to CS 151 Midterm review (20)

CS151 FIle Input and Output
CS151 FIle Input and OutputCS151 FIle Input and Output
CS151 FIle Input and Output
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revision
 
Python week 2 2019 2020 for g10 by eng.osama ghandour
Python week 2 2019 2020 for g10 by eng.osama ghandourPython week 2 2019 2020 for g10 by eng.osama ghandour
Python week 2 2019 2020 for g10 by eng.osama ghandour
 
Python week 4 2019 2020 for g10 by eng.osama ghandour
Python week 4 2019 2020 for g10 by eng.osama ghandourPython week 4 2019 2020 for g10 by eng.osama ghandour
Python week 4 2019 2020 for g10 by eng.osama ghandour
 
INDIAN INSTITUTE OF TECHNOLOGY OF KANPURESC 111M Lec03.pptx
INDIAN INSTITUTE OF TECHNOLOGY OF KANPURESC 111M Lec03.pptxINDIAN INSTITUTE OF TECHNOLOGY OF KANPURESC 111M Lec03.pptx
INDIAN INSTITUTE OF TECHNOLOGY OF KANPURESC 111M Lec03.pptx
 
CS 151 CSV output
CS 151 CSV outputCS 151 CSV output
CS 151 CSV output
 
Stanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programmingStanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programming
 
Learn C
Learn CLearn C
Learn C
 
Module 1 programs
Module 1 programsModule 1 programs
Module 1 programs
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
 
One Problem, Two Structures, Six Solvers and Ten Years of Personnel Schedulin...
One Problem, Two Structures, Six Solvers and Ten Years of Personnel Schedulin...One Problem, Two Structures, Six Solvers and Ten Years of Personnel Schedulin...
One Problem, Two Structures, Six Solvers and Ten Years of Personnel Schedulin...
 
03-fortran.ppt
03-fortran.ppt03-fortran.ppt
03-fortran.ppt
 
Code Optimization.ppt
Code Optimization.pptCode Optimization.ppt
Code Optimization.ppt
 
CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.ppt
 
Artifact 2 clemson
Artifact 2 clemsonArtifact 2 clemson
Artifact 2 clemson
 
Threading Is Not A Model
Threading Is Not A ModelThreading Is Not A Model
Threading Is Not A Model
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
 
CMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of FunctionsCMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of Functions
 
Lecture4
Lecture4Lecture4
Lecture4
 
GE3151_PSPP_UNIT_3_Notes
GE3151_PSPP_UNIT_3_NotesGE3151_PSPP_UNIT_3_Notes
GE3151_PSPP_UNIT_3_Notes
 

More from Rudy Martinez (13)

CS 151Exploration of python
CS 151Exploration of pythonCS 151Exploration of python
CS 151Exploration of python
 
CS 151 Graphing lecture
CS 151 Graphing lectureCS 151 Graphing lecture
CS 151 Graphing lecture
 
CS 151 Classes lecture 2
CS 151 Classes lecture 2CS 151 Classes lecture 2
CS 151 Classes lecture 2
 
CS 151 Classes lecture
CS 151 Classes lectureCS 151 Classes lecture
CS 151 Classes lecture
 
CS151 Deep copy
CS151 Deep copyCS151 Deep copy
CS151 Deep copy
 
CS 151 Standard deviation lecture
CS 151 Standard deviation lectureCS 151 Standard deviation lecture
CS 151 Standard deviation lecture
 
Cs 151 dictionary writer
Cs 151 dictionary writerCs 151 dictionary writer
Cs 151 dictionary writer
 
CS 151 homework2a
CS 151 homework2aCS 151 homework2a
CS 151 homework2a
 
CS 151 dictionary objects
CS 151 dictionary objectsCS 151 dictionary objects
CS 151 dictionary objects
 
CS 151 Date time lecture
CS 151 Date time lectureCS 151 Date time lecture
CS 151 Date time lecture
 
Lecture01
Lecture01Lecture01
Lecture01
 
Lecture03
Lecture03Lecture03
Lecture03
 
Lecture01
Lecture01Lecture01
Lecture01
 

Recently uploaded

Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 

Recently uploaded (20)

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 

CS 151 Midterm review

  • 1. Computer Science 151 An introduction to the art of computing Midterm Review Rudy Martinez
  • 2. CS151 Spring 2019 Midterm When: 3/6 This Wednesday Exam is 50 minutes. Closed book, closed computer, no phones, no notes. Exam is 11 questions 1 extra credit question During the Exam everyone will need at least one seat empty next to them on either side.
  • 3. CS151 Spring 2019 Topics - Booleans: ● Know how the logic conditions work in Conditional statements: If a > b then: print(‘Hello’) ● Know And, Or statements a = 5 b = 7 c = -1 If a > b AND a > c: print(‘False’) If a < b OR a > c: print(‘True’)
  • 4. CS151 Spring 2019 Topics - Strings ● Know what a string is ● Know how to get the individual characters: myString = ‘Hello’ myString[4] → ‘o’ ● Know how to get the length of a string. ● Know how to use a for loop to iterate over a string. ● Know how to concatenate two strings ● Know how strings are printed with print()
  • 5. CS151 Spring 2019 Topics - Trace a Program Know how a program flows: myString = ‘Hello’ for i in range(0, len(myString), 1): print(myString[i]) ● Know what I is as the loop runs. ● Know how many times the loop will run ● Know what is being printed.
  • 6. CS151 Spring 2019 Topics - Loops ● For loops ○ Know how to trace them ○ Know how to write them ● While loops ○ Know how to trace them ○ Know how to write them for i in range(start, stop, increment) # Do Stuff while(boolean condition is true) # Do Stuff Increment variable that will lead to boolean eventually being false.
  • 7. CS151 Spring 2019 Topics - Scope of Variables ● Go back over lecture on Function it has everything you need to know about scope of variables. ● Know what a global variable is and when it changes. ● Know variables in functions and when they can change.
  • 8. CS151 Spring 2019 Global Scope vs Local Scope a = 1 # Uses global because there is no local 'a' def f(): print('Inside f() : ', str(a)) # Variable 'a' is redefined as a local def g(): a = 2 print('Inside g() : ',str(a)) # Uses global keyword to modify global 'a' def h(): global a a = 3 print('Inside h() : ', str(a)) # Global scope print('global : ',str(a)) f() print('global : ',str(a)) g() print('global : ',str(a)) h() print('global : ',str(a)) global : 1 Inside f() : 1 global : 1 Inside g() : 2 global : 1 Inside h() : 3 global : 3
  • 9. CS151 Spring 2019 Topics - Dictionaries ● Know how to create a dictionary ○ Mydictionary = {} # remember curly braces ● Know how to access a value using a key ○ Remember key:value pairs, every key has a value ○ Mydictionary{key} returns value ● Know how to iterate over them in a for loop ○ For loops! ○ For loops! ○ For loops!
  • 10. CS151 Spring 2019 Stress Management ● Taking exams can be stressful to minimize this: ○ Get plenty of sleep, this help more than cramming for the test. ○ Eat a breakfast/lunch at least an hour before you take the test. ● Cramming doesn’t work, it really doesn’t. ● Positive attitude helps you with the right state of mind for the test. ● Show up to the test early and get ready.