MULTIPLE CHOICE. Chapter Seven
|
|
- Kelley Lang
- 6 years ago
- Views:
Transcription
1 Chapter Seven MULTIPLE CHOICE 1. Which of these is associated with a specific file and provides a way for the program to work with that file? a. Filename b. Extension c. File object d. File variable 2. What do you call the process of retrieving data from a file? a. Retrieving data b. Reading data c. Input data d. Get data 3. What happens when a piece of data is written to a file? a. Data is copied from a variable in RAM to a file. b. Data is copied from a variable in the program to a file. c. Data is copied from the program to a file. d. Data is copied from a file object to a file. 4. Which step creates a connection between a file and a program? a. Open the file. b. Read the file. c. Process the file. d. Close the file. 5. How many types of files are there? a. One b. Two c. Three d. Four 6. A(n) access file is also known as a direct access file. a. sequential b. random c. numbered d. text 7. What type of file access jumps directly to any piece of data in a file without reading the data that came before it? a. Sequential b. Random c. Number d. Text 8. Which mode specifier will open a file but will not let you change the file or write to it?
2 a. w b. r c. a d. 'e' 9. Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist? a. w b. r c. a d. e 10. Assume that the customer file references a file object, and the file was opened using the w mode specifier. How would you write the string Mary Smith to the file? a. customer_file.write( Mary Smith ) b. customer.write( w, Mary Smith ) c. customer.input( Mary Smith ) d. customer.write( Mary Smith ) 11. When a file has been opened using the r mode specifier, which method will return the file s contents as a string? a. write b. input c. get d. read 12. Which method could be used to strip specific characters from the end of a string? a. estrip b. rstrip c. strip d. remove 13. Which method could be used to convert a numeric value to a string? a. str b. value c. num d. chr 14. Which method will return an empty string when it has attempted to read beyond the end of a file? a. Read b. Getline c. input d. readline 15. What statement can be used to handle some of the run-time errors in a program? a. exception statement b. try statement c. try/except statement
3 d. exception handler statement TRUE/FALSE 1. True/False: If a file with the specified name already exists when the file is opened, and the file is opened in 'w' mode, then an alert will appear on the screen. 2. True/False: When a piece of data is read from a file, it is copied from the file into the program. 3. True/False: Closing a file disconnects the communication between the file and the program. 4. True/False: Python allows the programmer to work with text and number files. 5. True/False: In Python, there is nothing that can be done if the program tries to access a file to read that does not exist. 6. True/False: The ZeroDivisionError exception is raised when the program attempts to perform a division by zero. 7. True/False: An exception handler is a piece of code that is written using the try/except statement. 8. True/False: If the last line in a file is not terminated with a \n, the readline method will return the line without a \n. 9. True/False: Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written. 10. True/False: It is possible to create a while loop that determines when the end of a file has been reached. FILL IN THE BLANK 1. When a program needs to save data for later use, it writes the data in a(n). 2. Programmers usually refer to the process of data in a file as writing data to the file. 3. The term file is used to describe a file to which data is written. 4. The term file is used to describe a file from which the program gets data. 5. A(n) file contains data that has been encoded as text, using a scheme such as ASCII. 6. A(n) file contains data that has not been converted to text. 7. A(n) access file retrieves data from the beginning of the file to the end of the file.
4 8. A filename is a short sequence of characters that appear at the end of a filename preceded by a period. 9. A(n) gives information regarding the line number(s) that caused an exception. 10. A(n) includes one or more statements that can potentially raise an exception.
5 Chapter Eight MULTIPLE CHOICE 1. What are the data items in the list called? a. data b. elements c. items d. values 2. Which list will be referenced by the variable number after the execution of the following code? number = range(0, 9, 2) a. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] b. [1, 3, 5, 7, 9] c. [2, 4, 6, 8] d. [0, 2, 4, 6, 8] 3. What would you use if an element is to be removed from a specific index? a. del statement b. remove method c. index method d. slice method 4. What is the first negative index in a list? a. 0 b. -1 c. -0 d. Size of the string or list minus one 5. What method can be used to place an item in the list at a specific index? a. append b. index c. insert d. Add 6. What would be the value of the variable list after the execution of the following code? list = [1, 2] list = list * 3 a. [1, 2] * 3 b. [3, 6] c. [1, 2, 1, 2, 1, 2] d. [[1, 2], [1, 2], [1, 2]] 7. What would be the value of the variable list after the execution of the following code? list = [1, 2, 3, 4] list[3] = 10 a. [1, 2, 3, 10] b. [1, 2, 10, 4] c. [1, 10, 10, 10]
6 d. invalid code 8. What method or operator can be used to concatenate lists? a. * b. + c. % d. concat 9. What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3] list2 = list1 list1 = [4, 5, 6] a. [1, 2, 3] b. [4, 5, 6] c. [1, 2, 3, 4, 5, 6] d. invalid code 10. What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3] list2 = [] for element in list1 list2.append(element) list1 = [4, 5, 6] a. [1, 2, 3] b. [4, 5, 6] c. [1, 2, 3, 4, 5, 6] d. invalid code 11. When working with multiple sets of data, one would typically use a(n). a. list b. tuple c. nested list d. Sequence 12. The primary difference between a tuple and list is that. a. when creating a tuple you don t use commas to separate elements b. a tuple can only include string elements c. a tuple cannot include lists as elements d. once a tuple is created, it cannot be changed 13. What is the advantage of using tuples over lists? a. Tuples are not limited in size. b. Tuples can include any data type as an element. c. Processing a tuple is faster than processing a list. d. There is no advantage. 14. What method can be used to convert a list to a tuple? a. append b. tuple c. insert d. list
7 15. What method can be used to convert a tuple to a list? a. append b. tuple c. insert d. list TRUE/FALSE 1. True/False: Invalid indexes do not cause slicing expressions to raise an exception. 2. True/False: Lists are dynamic data structures such that items may be added to them or removed from them. 3. True/False: Arrays, which most other programming languages allow, have much more capabilities than list structures. 4. True/False: A list cannot be passed as an argument to a function. 5. True/False: The remove method removes all occurrences of the item from a list. 6. True/False: The sort method rearranges the elements of a list so they appear in ascending or descending order. 7. True/False: The first step in calculating the average of the values in a list is to get the total of the values. 8. True/False: Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth. 9. True/False: The index 1 identifies the last element in a list. 10. True/False: In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead. FILL IN THE BLANK 1. A(n) is an object that holds multiple items of data. 2. Each element in a tuple has a(n) that specifies its position in the tuple. 3. The built-in function returns the length of a sequence. 4. Tuples are sequences, which means that once a tuple is created, it cannot be changed. 5. A(n) is a span of items that are taken from a sequence.
8 6. Lists are, which means their elements can be changed. 7. The method is commonly used to add items to a list. 8. The exception is raised when a search item is not in the list being searched. 9. The method reverses the order of the items in the list. 10. The function returns the item that has the lowest value in the sequence. Chapter Nine MULTIPLE CHOICE 1. What are the valid indexes for the string New York? a. 0 through 7 b. 0 through 8 c. -1 through -8 d. -1 through 6 2. What will be assigned to s_string after the execution of the following code? special = 1357 Country Ln. s_string = special[ :4] a. 7 b c d. Invalid code 3. What will be assigned to s_string after the execution of the following code? special = 1357 Country Ln. s_string = special[4: ] a b. Country Ln. c. Country Ln. d. Invalid code 4. What will be assigned to the string variable even after the execution of the following code? special = even = special[0:10:2] a b c d. Invalid code 5. What will be assigned to s_string after the execution of the following code? special = 1357 Country Ln. s_string = special[-3: ] a. 531 b. Ln.
9 c. Ln. d If the start index is the end index, the slicing expression will return an empty string. a. equal to b. less than c. greater than d. not equal to 7. Which of the following string methods can be used to determine if a string contains only \n characters? a. ischar() b. isalpha() c. istab() d. isspace() 8. What is the return value of the string method lstrip()? a. The string with all whitespace removed b. The string with all leading spaces removed c. The string with all leading tabs removed d. The string with all leading whitespaces removed 9. What will be assigned to the string variable pattern after the execution of the following code? i = 3 pattern = z * (5*i) a. zzzzzzzzzzzzzzz b. zzzzz c. Error: * operator used incorrectly d. The right side of the * must be an integer. 10. Which list will be referenced by the variable list_strip after the execution of the following code? list_string = 03/07/2008 list_strip = list_string.split( / ) a. [ 3, 7, 2008 ] b. [ 03, 07, 2008 ] c. [ 3, /, 7, /, 2008 ] d. [ 03, /, 07, /, 2008 ] 11. What is the first negative index in a string? a. 0 b. -1 c. -0 d. Size of the string minus one 12. Which method would you use to determine whether a substring is present in a string? a. endswith(substring) b. find(substring) c. replace(string, substring)
10 d. startswith(substring) 13. Which method would you use to determine whether a substring is the suffix of a string? a. endswith(substring) b. find(substring) c. replace(string, substring) d. startswith(substring) 14. What is the value of the variable string after the execution of the following code? string = 'abcd' string.upper() a. 'abcd' b. 'Abcd' c. 'ABCD' d. Invalid code 15. What is the value of the variable string after the execution of the following code? string = 'Hello' string += ' world' a. 'Hello' b. ' world' c. 'Hello world' d. Invalid code TRUE/FALSE 1. True/False: Invalid indexes do not cause slicing expressions to raise an exception. 2. True/False: Indexing works with both strings and lists. 3. True/False: Indexing of a string starts at 1, so the index of the first character is 1, the index of the second character is 2, and so forth. 4. True/False: The index 1 identifies the last character in a string. 5. True/False: In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead. 6. True/False: An expression of the form string[i] = 'i' is a valid expression. 7. True/False: If the + operator is used on strings, it produces a string that is the combination of the two strings used as its operands. 8. True/False: When accessing each character in a string, such as for copying purposes, you would typically use a while loop. 9. True/False: If a whole paragraph is included in a single string, the split() method can be used to obtain a list of the sentences included in the paragraph.
11 10. True/False: The strip() method returns a copy of the string with all leading whitespace characters removed, but does not remove trailing whitespace characters. FILL IN THE BLANK 1. Each character in a string has a(n) which specifies its position in the string. 2. A(n) exception will occur if you try to use an index that is out of range for a particular string. 3. Strings are, which means that once a string is created, it cannot be changed. 4. A(n) is a span of characters that are taken from within a string. 5. The operator can be used to determine whether one string is contained in another string. 6. The method returns true if the string contains only numeric digits. 7. When the operand on the left side of the * symbol is a string and the operand on the right side is an integer, it becomes the operator. 8. The method returns the list of the words in the string. 9. The method returns a copy of the string with all alphabetic letters converted to lower case. 10. The third number in string slicing brackets represents the value.
Exam 3. 1 True or False. CSCE 110. Introduction to Programming Exam 3
CSCE 110. Introduction to Programming Exam 3 Exam 3 Professor:Joseph Hurley Exam Version B 1 True or False Fill in the bubble for "A" if the answer is True. Fill in the bubble for "B" if the answer is
More informationWorking with Sequences: Section 8.1 and 8.2. Bonita Sharif
Chapter 8 Working with Sequences: Strings and Lists Section 8.1 and 8.2 Bonita Sharif 1 Sequences A sequence is an object that consists of multiple data items These items are stored consecutively Examples
More informationStrings. Upsorn Praphamontripong. Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break
Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break Strings Upsorn Praphamontripong CS 1111 Introduction to Programming Spring 2018 Strings Sequence of characters
More informationString Processing CS 1111 Introduction to Programming Fall 2018
String Processing CS 1111 Introduction to Programming Fall 2018 [The Coder s Apprentice, 10] 1 Collections Ordered, Dup allow List Range String Tuple Unordered, No Dup Dict collection[index] Access an
More informationChapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationChapter 8: More About Strings. COSC 1436, Summer 2018 Dr. Zhang 7/10/2018
Chapter 8: More About Strings COSC 1436, Summer 2018 Dr. Zhang 7/10/2018 Creating Strings The str Class s1 = str() # Create an empty string s2 = str("welcome") # Create a string Welcome Python provides
More informationAnnouncements COMP 141. Writing to a File. Reading From a File 10/18/2017. Reading/Writing from/to Files
Announcements COMP 141 Reading/Writing from/to Files Reminders Program 5 due Thurs., October 19 th by 11:55pm Solutions to selected problems from Friday s lab are in my Box.com directory (LoopLab.py) Programming
More informationAnnouncements COMP 141. Accessing Characters Review. Using len function 10/30/2017. Strings II. Reminders: Program 6 - due 11/2
Announcements COMP 141 Reminders: Program 6 - due 11/2 Strings II 1 2 # Prints 1 letter of city on each line city = Boston index = 0 while index < len(city): print(city[index]) index += 1 Using len function
More informationIntroduction to String Manipulation
Introduction to Computer Programming Introduction to String Manipulation CSCI-UA.0002 What is a String? A String is a data type in the Python programming language A String can be described as a "sequence
More informationChapter 6: Files and Exceptions. COSC 1436, Spring 2017 Hong Sun 3/6/2017
Chapter 6: Files and Exceptions COSC 1436, Spring 2017 Hong Sun 3/6/2017 Function Review: A major purpose of functions is to group code that gets executed multiple times. Without a function defined, you
More informationSPRING COMP 141 MIDTERM 2 PRACTICE PROBLEMS
1. Which method could be used to convert a numeric value to a string? a. str b. value c. num d. chr 2. Which of the following statements are true? (circle all that are true) a. When you open a file for
More informationPython I. Some material adapted from Upenn cmpe391 slides and other sources
Python I Some material adapted from Upenn cmpe391 slides and other sources Overview Names & Assignment Data types Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics
More informationStrings are actually 'objects' Strings
Strings are actually 'objects' Strings What is an object?! An object is a concept that we can encapsulate data along with the functions that might need to access or manipulate that data. What is an object?!
More informationChapter 6: Files and Exceptions. COSC 1436, Summer 2016 Dr. Ling Zhang 06/23/2016
Chapter 6: Files and Exceptions COSC 1436, Summer 2016 Dr. Ling Zhang 06/23/2016 Introduction to File Input and Output Concept: When a program needs to save data for later use, it writes the data in a
More informationPython allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:
1 STRINGS Objectives: How text data is internally represented as a string Accessing individual characters by a positive or negative index String slices Operations on strings: concatenation, comparison,
More informationPython Tutorial. Day 1
Python Tutorial Day 1 1 Why Python high level language interpreted and interactive real data structures (structures, objects) object oriented all the way down rich library support 2 The First Program #!/usr/bin/env
More informationSequence types. str and bytes are sequence types Sequence types have several operations defined for them. Sequence Types. Python
Python Sequence Types Sequence types str and bytes are sequence types Sequence types have several operations defined for them Indexing Python Sequence Types Each element in a sequence can be extracted
More informationChapter 6: List. 6.1 Definition. What we will learn: What you need to know before: Data types Assignments
Chapter 6: List What we will learn: List definition Syntax for creating lists Selecting elements of a list Selecting subsequence of a list What you need to know before: Data types Assignments List Sub-list
More informationScript language: Python Data structures
Script language: Python Data structures Cédric Saule Technische Fakultät Universität Bielefeld 3. Februar 2015 Immutable vs. Mutable Previously known types: int and string. Both are Immutable but what
More informationIntroductory Linux Course. Python I. Martin Dahlö UPPMAX. Author: Nina Fischer. Dept. for Cell and Molecular Biology, Uppsala University
Introductory Linux Course Martin Dahlö UPPMAX Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University August, 2018 Outline Python basics get started with Python Data types Control
More informationCOLLEGE OF ENGINEERING, NASHIK-4
Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4 DEPARTMENT OF COMPUTER ENGINEERING Important PYTHON Questions 1. What is Python? Python is a high-level, interpreted, interactive and object-oriented
More information1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.
Gaddis: Starting Out with Python, 2e - Test Bank Chapter Two MULTIPLE CHOICE 1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationUNIVERSITÀ DI PADOVA. < 2014 March >
UNIVERSITÀ DI PADOVA < 2014 March > Easy-to-learn: Python has relatively few keywords, simple structure, and a clearly defined syntax. Easy-to-read: Python code is much more clearly defined and visible
More informationUnit 3 Fill Series, Functions, Sorting
Unit 3 Fill Series, Functions, Sorting Fill enter repetitive values or formulas in an indicated direction Using the Fill command is much faster than using copy and paste you can do entire operation in
More information6. Data Types and Dynamic Typing (Cont.)
6. Data Types and Dynamic Typing (Cont.) 6.5 Strings Strings can be delimited by a pair of single quotes ('...'), double quotes ("..."), triple single quotes ('''...'''), or triple double quotes ("""...""").
More informationUnit 3 Functions Review, Fill Series, Sorting, Merge & Center
Unit 3 Functions Review, Fill Series, Sorting, Merge & Center Function built-in formula that performs simple or complex calculations automatically names a function instead of using operators (+, -, *,
More informationIntroduction to Python for Plone developers
Plone Conference, October 15, 2003 Introduction to Python for Plone developers Jim Roepcke Tyrell Software Corporation What we will learn Python language basics Where you can use Python in Plone Examples
More informationAdvanced Python. Executive Summary, Session 1
Advanced Python Executive Summary, Session 1 OBJECT: a unit of data of a particular type with characteristic functionality (i.e., methods and/or use with operators). Everything in Python is an object.
More informationStrings, Lists, and Sequences
Strings, Lists, and Sequences It turns out that strings are really a special kind of sequence, so these operations also apply to sequences! >>> [1,2] + [3,4] [1, 2, 3, 4] >>> [1,2]*3 [1, 2, 1, 2, 1, 2]
More informationFundamentals of Python: First Programs. Chapter 4: Strings and Text Files
Fundamentals of Python: First Programs Chapter 4: Strings and Text Files Objectives After completing this chapter, you will be able to Access individual characters in a string Retrieve a substring from
More informationWorking with Strings. Husni. "The Practice of Computing Using Python", Punch & Enbody, Copyright 2013 Pearson Education, Inc.
Working with Strings Husni "The Practice of Computing Using Python", Punch & Enbody, Copyright 2013 Pearson Education, Inc. Sequence of characters We've talked about strings being a sequence of characters.
More informationLists in Python CS 8: Introduction to Computer Science, Winter 2018 Lecture #10
Lists in Python CS 8: Introduction to Computer Science, Winter 2018 Lecture #10 Ziad Matni Dept. of Computer Science, UCSB Administrative Homework #5 is due today Homework #6 is out and DUE on MONDAY (3/5)
More informationTips and Tricks to loading data using the Data Import Specification
Tip or Technique Tips and Tricks to loading data using the Data Import Specification Product(s): IBM Cognos Controller 8.3 or higher Area of Interest: Financial Management Tips and Tricks to loading data
More informationIntroduction to: Computers & Programming: Strings and Other Sequences
Introduction to: Computers & Programming: Strings and Other Sequences in Python Part I Adam Meyers New York University Outline What is a Data Structure? What is a Sequence? Sequences in Python All About
More informationSequence of Characters. Non-printing Characters. And Then There Is """ """ Subset of UTF-8. String Representation 6/5/2018.
Chapter 4 Working with Strings Sequence of Characters we've talked about strings being a sequence of characters. a string is indicated between ' ' or " " the exact sequence of characters is maintained
More informationIntroduction to: Computers & Programming: Strings and Other Sequences
Introduction to: Computers & Programming: Strings and Other Sequences in Python Part I Adam Meyers New York University Outline What is a Data Structure? What is a Sequence? Sequences in Python All About
More informationBabu Madhav Institute of Information Technology, UTU 2015
Five years Integrated M.Sc.(IT)(Semester 5) Question Bank 060010502:Programming in Python Unit-1:Introduction To Python Q-1 Answer the following Questions in short. 1. Which operator is used for slicing?
More informationThe Big Python Guide
The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String
More informationUNIVERSITY OF TORONTO SCARBOROUGH. December 2017 EXAMINATIONS. CSCA20H3 Duration 3 hours. Examination Aids: Instructor: Bretscher
PLEASE HAND IN UNIVERSITY OF TORONTO SCARBOROUGH December 2017 EXAMINATIONS CSCA20H3 Duration 3 hours PLEASE HAND IN Examination Aids: None Student Number: Last (Family) Name(s): First (Given) Name(s):
More informationGIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes
GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and
More informationLISTS WITH PYTHON. José M. Garrido Department of Computer Science. May College of Computing and Software Engineering Kennesaw State University
LISTS WITH PYTHON José M. Garrido Department of Computer Science May 2015 College of Computing and Software Engineering Kennesaw State University c 2015, J. M. Garrido Lists with Python 2 Lists with Python
More informationStandard prelude. Appendix A. A.1 Classes
Appendix A Standard prelude In this appendix we present some of the most commonly used definitions from the standard prelude. For clarity, a number of the definitions have been simplified or modified from
More informationSequences: Strings, Lists, and Files
Sequences: Strings, Lists, and Files Read: Chapter 5, Sections 11.1-11.3 from Chapter 11 in the textbook Strings: So far we have examined in depth two numerical types of data: integers (int) and floating
More informationTopic 7: Lists, Dictionaries and Strings
Topic 7: Lists, Dictionaries and Strings The human animal differs from the lesser primates in his passion for lists of Ten Best H. Allen Smith 1 Textbook Strongly Recommended Exercises The Python Workbook:
More informationThere are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:
Numeric Types There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals: 1-123 +456 2. Long integers, of unlimited
More informationLanguage Reference Manual
TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall
More information1 Strings (Review) CS151: Problem Solving and Programming
1 Strings (Review) Strings are a collection of characters. quotes. this is a string "this is also a string" In python, strings can be delineated by either single or double If you use one type of quote
More informationIntroductory Linux Course. Python I. Pavlin Mitev UPPMAX. Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University
Introductory Linux Course Python I Pavlin Mitev UPPMAX Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University August, 2017 Outline Python introduction Python basics get started with
More informationPython Strings. Stéphane Vialette. LIGM, Université Paris-Est Marne-la-Vallée. September 25, 2012
Python Strings Stéphane Vialette LIGM, Université Paris-Est Marne-la-Vallée September 25, 2012 Stéphane Vialette (LIGM UPEMLV) Python Strings September 25, 2012 1 / 22 Outline 1 Introduction 2 Using strings
More informationStudent Number: Comments are not required except where indicated, although they may help us mark your answers.
CSC 108H5 F 2018 Midterm Test Duration 90 minutes Aids allowed: none Student Number: utorid: Last Name: First Name: Do not turn this page until you have received the signal to start. (Please fill out the
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More information2. Explain the difference between read(), readline(), and readlines(). Give an example of when you might use each.
CMSC 0 Fall 0 Name Final Review Worksheet This worksheet is NOT guaranteed to cover every topic you might see on the exam. It is provided to you as a courtesy, as additional practice problems to help you
More informationECS15, Lecture 13. Midterm solutions posted. Topic 4: Programming in Python, cont. Staying up to speed with Python RESOURCES. More Python Resources
Midterm solutions posted ECS15, Lecture 13 Topic 4: Programming in Python, cont. Don t forget, you have one week since the material returned to request a re-grade for whatever reason. We will re-evaluate
More informationCS2304: Python for Java Programmers. CS2304: Sequences and Collections
CS2304: Sequences and Collections Sequences In Python A sequence type in python supports: The in membership operator. The len() function. Slicing like we saw with strings, s[1:3]. And is iterable (for
More information18.1. CS 102 Unit 18. Python. Mark Redekopp
18.1 CS 102 Unit 18 Python Mark Redekopp 18.2 Credits Many of the examples below are taken from the online Python tutorial at: http://docs.python.org/tutorial/introduction.html 18.3 Python in Context Two
More informationCIS192: Python Programming Data Types & Comprehensions Harry Smith University of Pennsylvania September 6, 2017 Harry Smith (University of Pennsylvani
CIS192: Python Programming Data Types & Comprehensions Harry Smith University of Pennsylvania September 6, 2017 Harry Smith (University of Pennsylvania) CIS 192 Fall Lecture 2 September 6, 2017 1 / 34
More informationChapter 10: Creating and Modifying Text Lists Modules
Chapter 10: Creating and Modifying Text Lists Modules Text Text is manipulated as strings A string is a sequence of characters, stored in memory as an array H e l l o 0 1 2 3 4 Strings Strings are defined
More informationSprite an animation manipulation language Language Reference Manual
Sprite an animation manipulation language Language Reference Manual Team Leader Dave Smith Team Members Dan Benamy John Morales Monica Ranadive Table of Contents A. Introduction...3 B. Lexical Conventions...3
More informationSMURF Language Reference Manual Serial MUsic Represented as Functions
SMURF Language Reference Manual Serial MUsic Represented as Functions Richard Townsend, Lianne Lairmore, Lindsay Neubauer, Van Bui, Kuangya Zhai {rt2515, lel2143, lan2135, vb2363, kz2219}@columbia.edu
More informationCSC148 Fall 2017 Ramp Up Session Reference
Short Python function/method descriptions: builtins : input([prompt]) -> str Read a string from standard input. The trailing newline is stripped. The prompt string, if given, is printed without a trailing
More informationPROGRAMMING, DATA STRUCTURES AND ALGORITHMS IN PYTHON
NPTEL MOOC PROGRAMMING, DATA STRUCTURES AND ALGORITHMS IN PYTHON Week 5, Lecture 3 Madhavan Mukund, Chennai Mathematical Institute http://www.cmi.ac.in/~madhavan Dealing with files Standard input and output
More informationInformation Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay
Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Lecture - 11 Coding Strategies and Introduction to Huffman Coding The Fundamental
More informationPython Intro GIS Week 1. Jake K. Carr
GIS 5222 Week 1 Why Python It s simple and easy to learn It s free - open source! It s cross platform IT S expandable!! Why Python: Example Consider having to convert 1,000 shapefiles into feature classes
More informationCS 115 Lecture 13. Strings. Neil Moore. Department of Computer Science University of Kentucky Lexington, Kentucky
CS 115 Lecture 13 Strings Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 29 October 2015 Strings We ve been using strings for a while. What can
More informationCMPT 125: Lecture 3 Data and Expressions
CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,
More informationChapter 5 BET TER ARRAYS AND STRINGS HANDLING
Chapter 5 BET TER ARRAYS AND STRINGS HANDLING Chapter Objective Manage arrays with the foreach loop Create and use associative arrays Extract useful information from some of PHP s built-in arrays Build
More informationCSc 120. Introduc/on to Computer Programing II. 01- b: Python review. Adapted from slides by Dr. Saumya Debray
CSc 120 Introduc/on to Computer Programing II Adapted from slides by Dr. Saumya Debray 01- b: Python review Lists of Lists x = [ [1,2,3], [4], [5, 6]] x [[1, 2, 3], [4], [5, 6]] y = [ ['aa', 'bb', 'cc'],
More informationData Structures. Lists, Tuples, Sets, Dictionaries
Data Structures Lists, Tuples, Sets, Dictionaries Collections Programs work with simple values: integers, floats, booleans, strings Often, however, we need to work with collections of values (customers,
More informationComposite)Types. Types)Of)Variables. Addresses)And)References)(2) Addresses)And)References. Small)Example)Programs)Using)Strings
Composite)Types Types)Of)Variables Python variables Example composite A$string$(sequence$of$ characters)$can$be$ decomposed$into$individual$ words. You$will$learn$how$to$create$new$variables$that$are$collections$of$
More informationInteractive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D
1/58 Interactive use $ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.
More informationUnit 2. Srinidhi H Asst Professor
Unit 2 Srinidhi H Asst Professor 1 Iterations 2 Python for Loop Statements for iterating_var in sequence: statements(s) 3 Python for While Statements while «expression»: «block» 4 The Collatz 3n + 1 sequence
More informationSome material adapted from Upenn cmpe391 slides and other sources
Some material adapted from Upenn cmpe391 slides and other sources History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics
More information- c list The list specifies character positions.
CUT(1) BSD General Commands Manual CUT(1)... 1 PASTE(1) BSD General Commands Manual PASTE(1)... 3 UNIQ(1) BSD General Commands Manual UNIQ(1)... 5 HEAD(1) BSD General Commands Manual HEAD(1)... 7 TAIL(1)
More informationQuestion 1. Part (a) Part (b) December 2013 Final Examination Marking Scheme CSC 108 H1F. [13 marks] [4 marks] Consider this program:
Question 1. Part (a) [4 marks] Consider this program: [13 marks] def square(x): (number) -> number Write what this program prints, one line per box. There are more boxes than you need; leave unused ones
More informationHistory Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability
History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability Some material adapted from Upenn cmpe391 slides and other sources Invented in the Netherlands,
More informationInteractive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D
1/60 Interactive use $ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.
More informationPython Companion to Data Science
Extracted from: Python Companion to Data Science Collect Organize Explore Predict Value This PDF file contains pages extracted from Python Companion to Data Science, published by the Pragmatic Bookshelf.
More informationGenome 373: Intro to Python II. Doug Fowler
Genome 373: Intro to Python II Doug Fowler Review string objects represent a sequence of characters characters in strings can be gotten by index, e.g. mystr[3] substrings can be extracted by slicing, e.g.
More informationThey grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list.
Arrays Perl arrays store lists of scalar values, which may be of different types. They grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list. A list literal
More informationCSc 120 Introduction to Computer Programing II Adapted from slides by Dr. Saumya Debray
CSc 120 Introduction to Computer Programing II Adapted from slides by Dr. Saumya Debray 01-c: Python review 2 python review: lists strings 3 Strings lists names = "John, Paul, Megan, Bill, Mary" names
More informationVariables, Constants, and Data Types
Variables, Constants, and Data Types Strings and Escape Characters Primitive Data Types Variables, Initialization, and Assignment Constants Reading for this lecture: Dawson, Chapter 2 http://introcs.cs.princeton.edu/python/12types
More informationAPPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 TRUE-FALSE FILL-IN-THE-BLANKS
APPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 2. F The AS/400 family of computers, as with all IBM midrange and mainframe computers, uses the EBCDIC coding system. 3. F Arrival sequence files do not
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science SUMMER 2012 EXAMINATIONS CSC 108 H1Y Instructors: Janicki Duration NA PLEASE HAND IN Examination Aids: None Student Number: Family Name(s):
More informationRhythm Reference Manual
Rhythm Reference Manual John Sizemore Cristopher Stauffer Lauren Stephanian Yuankai Huo jcs2213 cms2231 lms2221 yh2532 Department of Computer Science Columbia University in the City of New York New York,
More informationPreviously. Iteration. Date and time structures. Modularisation.
2017 2018 Previously Iteration. Date and time structures. Modularisation. Today File handling. Reading and writing files. In order for a program to work with a file, the program must create a file object
More informationProgramming Fundamentals and Python
Chapter 2 Programming Fundamentals and Python This chapter provides a non-technical overview of Python and will cover the basic programming knowledge needed for the rest of the chapters in Part 1. It contains
More informationISE 101 Introduction to Information Systems. Lecture 3 Objectives: While loops Strings
ISE 101 Introduction to Information Systems Lecture 3 Objectives: While loops Strings While Loops Write a Python script that computes the sum of squares from 1 to 5. sum = 0; sum = sum + 1**2; sum = sum
More informationTopic 2. Big C++ by Cay Horstmann Copyright 2018 by John Wiley & Sons. All rights reserved
Topic 2 1. Reading and writing text files 2. Reading text input 3. Writing text output 4. Parsing and formatting strings 5. Command line arguments 6. Random access and binary files Reading Words and Characters
More informationUsing Lists (Arrays) Notes
Using Lists (Arrays) Notes - 27.11.16 Array/List = a data structure that allows for multiplied items or elements to be stored using just one variable name. Each element in a list is accessed using an index
More informationCIS192 Python Programming
CIS192 Python Programming Data Types Joseph Cappadona University of Pennsylvania September 03, 2015 Joseph Cappadona (University of Pennsylvania) CIS 192 September 03, 2015 1 / 32 Outline 1 Data Types
More informationString Objects: The string class library
String Objects: The string class library Lecture 23 COP 3014 Spring 2017 March 7, 2017 C-strings vs. string objects In C++ (and C), there is no built-in string type Basic strings (C-strings) are implemented
More informationText. Text Actions. String Contains
Text The Text Actions are intended to refine the texts acquired during other actions, for example, from web-elements, remove unnecessary blank spaces, check, if the text matches the defined content; and
More informationPRELIMINARY APPLE BASIC USERS MANUAL OCTOBER Apple Computer Company. 770 Welch Rd., Palo Alto, CA (415)
PRELIMINARY APPLE BASIC USERS MANUAL OCTOBER 1976 Apple Computer Company. 770 Welch Rd., Palo Alto, CA 94304 (415) 326-4248 This is a PRELIMINARY manual. It will, most likley, contain errors, incorrect
More informationIntroduction to Python
Introduction to Python Reading assignment: Perkovic text, Ch. 1 and 2.1-2.5 Python Python is an interactive language. Java or C++: compile, run Also, a main function or method Python: type expressions
More informationComputing with Strings. Learning Outcomes. Python s String Type 9/23/2012
Computing with Strings CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17 1 Learning Outcomes To understand the string data type and how strings are represented
More informationFile Operations. Working with files in Python. Files are persistent data storage. File Extensions. CS111 Computer Programming
File Operations Files are persistent data storage titanicdata.txt in PS06 Persistent vs. volatile memory. The bit as the unit of information. Persistent = data that is not dependent on a program (exists
More informationProgramming in Python
3. Sequences: Strings, Tuples, Lists 15.10.2009 Comments and hello.py hello.py # Our code examples are starting to get larger. # I will display "real" programs like this, not as a # dialog with the Python
More informationCOMP1730/COMP6730 Programming for Scientists. Strings
COMP1730/COMP6730 Programming for Scientists Strings Lecture outline * Sequence Data Types * Character encoding & strings * Indexing & slicing * Iteration over sequences Sequences * A sequence contains
More information06/11/2014. Subjects. CS Applied Robotics Lab Gerardo Carmona :: makeroboticsprojects.com June / ) Beginning with Python
CS95003 - Applied Robotics Lab Gerardo Carmona :: makeroboticsprojects.com June / 2014 Subjects 1) Beginning with Python 2) Variables 3) Strings 4) Basic arithmetic operators 5) Flow control 6) Comparison
More information