C 859: Introduction to Programming in Python Questions and Correct Answers | Latest Update
6 views 0 purchase
Course
C 859
Institution
C 859
Slice Notation
-:- my_str[start:end]
will create a substring from my_str index start through to end - 1
Slice Notation with Stride
-:- my_str[start:end:stride]
Field Width
-:- minimum number of characters that must be inserted into a string
my_str='{name:16}{goals:8}'
Alignment Characte...
✓ -:- used to pad a replacement field when the string being inserted is smaller than the
field width
{score:0>4} produces 0018
Floating-point Precision
✓ -:- format specification which indicates how many digits to the right of the decimal
should be included in the output of floating types
'{:.1f}'.format(1.725) produces 1.7
Replace (old and new parameters)
✓ -:- returns a copy of the string with all occurrences of the substring old replaced 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
Replace (old, new and count parameters)
✓ -:- returns a copy of the string with all occurences of the substring old 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
Find (with x variable)
2|P a g e | G r a d eA + | 2 0 2 0 2 5
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller TestTrackers. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $10.49. You're not tied to anything after your purchase.