



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A concise overview of fundamental programming concepts in python, focusing on string and list manipulation techniques. It covers essential topics such as slice notation, field width, alignment, fill characters, and floating-point precision for strings. Additionally, it details various string methods like replace, find, count, and isalnum, as well as list operations including appending, extending, inserting, removing, and sorting. The document also touches on list comprehensions and dictionary implementations, offering a comprehensive guide for beginners to grasp basic python programming skills. It serves as a quick reference for students learning python, summarizing key methods and operations with examples. Structured to aid quick recall and understanding of python's string and list functionalities, making it a valuable resource for coding exercises and assignments.
Typology: Study Guides, Projects, Research
1 / 5
This page cannot be seen from the preview
Don't miss anything!




1 /
will create a substring from my_str index start through to end - 1
my_str='[name:<16}{goals:>8}{points:^6}'
{score:0>4} produces 0018
be included in the output of floating types '{:.1f}'.format(1.725) produces 1.
by the string new; old and new arguments may be string variables or string literals phrase.replace('one', 'two') will replace any occurrence of the word one with two
replaced by the new except only replaces the first count occurrences of old phrase.replace('one', 'two', 5) will replace any occurrances of 'one' with 'two' but will begin looking at index 5
my_str.find('!') will return the index of the '!' in the string
2 /
the string but will begin looking at index start my_str.find('!', 3) will produce the index of the first! on or after index 3
in the string but will begin looking at the index start and will stop at index end - my_str.find('!', 3, 8) will produce the index of the first! but will start looking at index 3 and stop looking at index 8 - 1
occurrence in the string my_str.rfind('!') will give the index of the last! in the string
number of times 'oo' occurs in the string
the numbers 0-
lowercased
4 /
5 /
List Comprehension
Conditional List Comprehension
ensure that a will come before B
dict(Bobby='805-555-2232', Johnny='951-555-0055') dict([('Bobby', '805-555-2232'), ('Johnny', '951-555-0055')])
my_dict['Jose'] = 'B+'
my_dict: ......