CP104 Lecture Notes - Lecture 6: For Loop

96 views2 pages
School
Course
Professor
EX.65=A
Function character chr
- random.choice(‘ABCDEFGH’)
- For loop
- dir(str)- functions for strings
- Or help(string)
- s.capitalize()---> capitalizes first letter and rest lowercase
- my_string= ‘this is python. It is awesome!’
- my_count= my-string.count (‘is’, 0(start), -1(finish))
- Cannot change a string
- Lower and upper methods
- [-1] last character in string
- Chaining method calls:
- S.swapcase().endswith(‘ENCE’)
- .rstrip()---> REMOVES SPACES FROM RIGHT
- .lstrip()---> from left
- No function to reverse string have to do manually
- str.capitalize()
- ONLY MULTIPLY STRING BY NUMBER
- Lower case letters and uppercase letters are in different locations (eg A=65, a=97)
- Rstrip takes out white space
- Strp functions used for files cleaning files
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in
hayjayshay and 38575 others unlocked
CP104 Full Course Notes
2
CP104 Full Course Notes
Verified Note
2 documents

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers