CS 110 Lecture 10: Lesson 10 notes

49 views2 pages
11 Oct 2016
Course
Professor

Document Summary

Computer science lesson 10 def main(): mystr = hello main() A string is a list of characters. [ h , e , l , l , o ] new_string = 2 + 2 . This is not numerical addition, because these are strings. This will concatenate the two 2 strings together, giving you 22 new_string = 2 - 2 . This will not work, because there is no string subtraction. It will throw an error. new_string = sunday * 3. This will concatenate two more sundays, printing sunday sunday sunday mystr = hello print(mystr[0]) This will print h , because h is the 0th character string in the list. String. lower() gives a string in complete lower case. String. upper() gives a string in complete upper case. There are many others in the string library. Strings are immutable: you can"t change the string after you define it. new_string = this sunday new_string = new_string. replace( sunday , monday )

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

Related Documents

Related Questions