p4da-Slides-ch08

.pptx

School

University of Toronto *

*We aren’t endorsed by this school

Course

1340

Subject

Computer Science

Date

Oct 30, 2023

Type

pptx

Pages

22

Uploaded by hsoidsf

Report
Strings in Detail Chapter 8 Python for Data & Analytics A Business-Oriented Approach 1 © 2023 Rose River Software, LLC
Chapter 8: Strings in Detail Topics String basics recap Substrings (slicing) Searching parts of strings Methods that return string variations Checking strings 2
Chapter 8: Strings in Detail Topics String basics recap Substrings (slicing) Searching parts of strings Methods that return string variations Checking strings 3
Chapter 8: Strings in Detail String basics recap A string constant (string literal), in above: 'Hi' A string variable in above is name A string contains a sequence of characters Square brackets can be used to access a character if s = 'Hello' then s[0] is 'H' Strings are immutable , you can't use s[0] = 'h' But you can reset a string variable, e.g., s = 'hello' The empty string is a string with no characters s = '' # two adjacent apostrophes The input() function always returns a string 4 name = input('Please enter your name: ') print('Hi', name)
Chapter 8: Strings in Detail String basics recap + can be used to join (concatenate) strings += can be used to append one string to another int() and float() can convert strings containing numbers to numbers str() can be used to convert numbers (and other types) to strings Useful for concatenating numbers with strings format() can be used to convert a number to a formatted string 5
Chapter 8: Strings in Detail String basics recap Strings can be compared for equality (same sequence of characters) with == Compare for inequality with != Other string comparisons: < > <= >= Strings have an order based on the ASCII table values 6 range characters 0-31 special characters: e.g., tab, backspace 32 space 33-47 symbols1: ! “ # $ % & ' ( ) * + , - . / 48-57 digits: 0, 1, …, 9 58-64 symbols2: : ; < = > ? @ 65-90 uppercase letters: A, B, …, Z 91-96 symbols3: [ \ ] ^ _ ` 97-122 lowercase letters: a, b, …, z 123-126 symbols4: { | } ~ 127 DEL
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: 1. A dam is in the shape of an isosceles trapezoid. The dam is 120 feet wide at the top and 60 feet…
Q: In a combination of excitatory or inhibitory synaptic connections the following is true it is poorly…
Q: Describe the similarities and differences between mitosis and meiosis.  Discuss at least two…
Q: The rate of a continuous money flow starts at $1300 and increases exponentially at 6% per year for…
Q: 4. 6. 12 kg v = ? m/s Before 3m/s 8 kg v = 3 m/s kg вони Om/s 10 kg 12 kg v = 1 m/s After 8 kg v = 6…
Q: Light of wavelength 322 nm is incident on an uncharged metal sphere of diameter 12.2 cm. If the work…
Q: 5. A C number of loop square coil of wire, with side length B/5 cm and total resistance CQ2, is…
Q: A marriage counselor has traditionally seen that the proportion p of all married couples for whom…
Q: Detail how a faulty system might compromise a computer's data storage and retrieval.
Q: a. P(Positive | Pregnant) = b. What is the probability that the woman is pregnant given that the…
Q: What does database integrity consist of? Enumerate all Oracle database integrity-preserving…
Q: A piece of copper metal (mass = 35.0 g) at 120 °C is placed in a Styrofoam coffee cup containing…
Q: Question 4 Convert 81.9x10-6 Matm to psi. Give your answer in scientific notation (e. g. 1.23E4…
Q: and lear X + ilrn/takeAssignment/takeCovalentActivity.do?locator assignment-... * [Review Topics]…
Q: K Let X = (a, b, c, 11, 12, 13), Y = {b, d, f, 11, 13, 15), and Z= {b, d, 12, 13, 15). List the…
Q: 19. A titration analysis of a 345 mL aqueous HBr solution was performed and the endpoint was reached…
Q: The following initial rate data are for the reaction of ICI with hydrogen: 21C1+ H₂ → I2+ 2HCl…
Q: What are various ways to implement a repetitive computation? Explain each steps
Q: Consider our example instruction set from class (and homework 3). Suppose the contents of memory…
Q: All can be said of dendrites, EXCEPT: they must grow in size to be able to "learn" undergo…
Q: Why are ethics and trust important in business?
Q: (2²+1)/1+x) 1)+xy - x = 0 dx