Lecture 8 – Practice Exam

Slides:



Advertisements
Similar presentations
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Advertisements

1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
LOOP (Part 2) for while do-while 1. TK1913-C Programming2 TK1913-C Programming 2 Loop : for Loop : for Condition is tested first Loop is controlled by.
Last Week Doctests Lists List methods Nested Lists Aliasing.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Last Week if statement print statement input builtin function strings and methods for loop.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
More about Strings. String Formatting  So far we have used comma separators to print messages  This is fine until our messages become quite complex:
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
CPSC 217 T03 Week VI Part #2: Midterm Review Session Hubert (Sathaporn) Hu.
1 CS 177 Week 6 Recitation Slides Review for Midterm Exam.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Lecture 14 – lists, for in loops to iterate through the elements of a list COMPSCI 1 1 Principles of Programming.
Python Flow of Control CS 4320, SPRING Iteration The ‘for’ loop is good for stepping through lists The code below will print each element in the.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC530 Data Structures - LOOP 7/9/20161.
CMSC201 Computer Science I for Majors Lecture 07 – While Loops
CMPT 120 Topic: Python’s building blocks -> More Statements
Whatcha doin'? Aims: To start using Python. To understand loops.
Loops Upsorn Praphamontripong CS 1110 Introduction to Programming
CS 115 Lecture Flags.
It’s called “wifi”! Source: Somewhere on the Internet!
Python: Control Structures
Printing Lines of Asterisks
Lecture 4 - Loops UniMAP EKT120 Sem 1 08/09.
Repetition-Counter control Loop
While Loops in Python.
Little work is accurate
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
CSC115 Introduction to Computer Programming
The while Looping Structure
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Exception Handling.
CS 115 Lecture Flags.
CS212 Data Structures 2018 Second Semester.
Count Controlled Loops (Nested)
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Do While (condition is true) … Loop
The while Looping Structure
Looping Topic 4.
CMSC201 Computer Science I for Majors Lecture 09 – While Loops
Visual Basic – Decision Statements
Algorithm and Ambiguity
Module 4 Loops and Repetition 2/1/2019 CSE 1321 Module 4.
Python programming exercise
Let’s all Repeat Together
CS 1111 Introduction to Programming Spring 2019
Python Basics with Jupyter Notebook
QUIZ 5 – RESULT.
CS 101 First Exam Review.
Selections and Loops By Sarah, Melody, Teresa.
CISC101 Reminders Assignment 3 due today.
CMPT 120 Lecture 12 – Unit 2 – Cryptography and Encryption –
CSCE 206 Lab Structured Programming in C
While Loops in Python.
Lecture 7 – Unit 1 – Chatbots Python – For loops + Robustness
CMPT 120 Lecture 4 – Unit 1 – Chatbots
CMPT 120 Lecture 6 – Unit 1 – Chatbots
Starter Look at the hand-out.
CMPT 120 Lecture 24 – Unit 4 – Computer Vision
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Lecture 23 – Practice Exercises 5
Introduction to Python
Presentation transcript:

Lecture 8 – Practice Exam CMPT 120 Lecture 8 – Practice Exam

How does this Practice Exam works? This is a practice exam -> it's not for marks Suggestion Try to do it without looking at your notes and on your own CS Peer Tutors They are here to help us If you have tried to answer a question on your own, but need help, you can ask them questions

Why having a Practice Exam? More practice for us! Yay! It is a chance for you to ascertain what you understand of the material so far It is a chance for you to become familiar with: Type of questions asked in CMPT 120 exams Format of questions – the way the questions are phrased (terminology used) Expected answer format

Theory and Understanding

num = int(input("Enter an integer: ")) if (num < 10): Consider the following Python code fragment and answer Question 1 and Question 2 below: num = int(input("Enter an integer: ")) if (num < 10): print("num is just 1 digit long.") else: if (num < 100): print("num is just 2 digit long.") print("num has more than 2 digits.") For which input int values will the code fragment above print "num is just 2 digit long."?  Any int value between -9 and 9 Any int value from -10 to -99 Any int value from 10 to 99 None of the above For which input int values will this code fragment produce a semantic error?

Question 3 What does the following code fragment print? print("!.?blah".strip("!.h")) Question 4 What does the following code fragment print? for item in ["0", "1", "2"]: print(item)

Question 5 What does the following code fragment print? pico = "pico" paco = "paco" poco = "poco" if pico+paco in ["pico", "paco", "pocopoco"]: print("It’s there!") else: print("Not it isn’t!")

Question 6 Consider the following code fragment: isHappy = False response = input("How are you today?").lower() if response in ["good", "great", "awesome"]: isHappy = True print(isHappy) What would the output be if the user input was I feel good?

Coding

Here is a sample output (or sample run): Question 7 Problem Statement: Write a New Years Bot that counts down from 10 to 1. Requirements: It should use a for loop and each number should be on a new line. At the end of the countdown, it should output Happy new year! Here is a sample output (or sample run):

Question 8 Here are 5 sample runs: Problem Statement: Write a Star Wars Bot that decides if you can be on the Dark side, or the Light side. To be a Dark Lord you need to like capes or the colour red. Otherwise the bot will recommend you to the Light side. Requirements: Your bot should be robust to upper/lowercase answers of yes and no.

Solution Will be posted on our course web site after this lecture Go over the solution to this Practice Exam 1 and make sure you understand everything If not, ask questions next week! Do not wait until the end of the semester to ask questions! Clarify what you do not understand now!