CS 1301 Lecture 8: Day 8 Notes (8 June)

62 views8 pages

Document Summary

#####day 8- more string functions, string constants, escape sequences, tuples. ##print(mystring. replace("m","d")) #creates a new string with all the ms replaced. ##mystring = mystring. replace("s","p"). strip() #strips white space, not spaces in middle. ######string constants that have string in front of the dot. ##import string #allows the use of string. constants. ######write a loop that loops through a sentence counting how many uppercase. ##sentence= "i love going to tech in summer semester" ###uses a backslash before a charater to change the meaning of the character. #\n means end of line character; counts as one character. #\" and " means you actually want to see the quote. ##newtup3 = ("cat",3,"rabbit",1) #do not need parenthesis, they are for grouping. ##newtup1 = newtup1 + (2,) +(2,3) #adds to newtup1. ####write a function that takes a tuple as its parameter and return the sum. ## for example: (1,2,4) and (1,2,5) would return 2. ####write a function that takes two tuples as parameters and returns how many items.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers