






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







1/22/2009 1
Lotfi Ben Othmane Department of Computer Science Western Michigan University
1/22/2009 2
1/22/2009 3
Print a value as it is in Python
String value
Print a string value
1/22/2009 4
Can not change the sequence using slicing
1/22/2009 7
Character โโโ couldnโt be part of the string
Backslash character is used to display character โโโ in a string
Character โ\nโ is considered line return Character โ\nโ is escaped using โ\โ
Character โrโ is used to require the print of the string as it is
1/22/2009 8
1/22/2009 9
Character %: specifies the beginning of the conversion Conversion flags: optional flags that could be used in the conversion Character โ-โ : left alignment Character โ+โ : A sign should proceed the converted values Character โโ : A space should proceed positive numbers Character 0 : should be zero padded Minimum field width A. (dot) followed by the precision Conversion type (see course book page 57 for the list of conversion types)
1/22/2009 10
Simple formatting
Formatting float using precision
Formatting string using precision Formatting float using padding
Formatting float using left alignment
1/22/2009 13
1/22/2009 14
Return the position of the substring โcs2100โ
Return -1 because โCs2100โ does not exist in the string Return the first position of the substring โiโ
Return the first position of the substring โiโ such that the start position is 8 and the end position is the length of the string
1/22/2009 15
Create a tuple
Join a tuple elements
Create a list
Create a list elements
Error when joining integers using a character
1/22/2009 16
Convert the string to lower case
Find method returns -1! Why?
Lower method is used in a membership test statement
1/22/2009 19
Delete while spaces on the left and right of the string
The first membership test returned negative result and the second test returned positive results! Why?
1/22/2009 20
Import method maketrans from string library and construct a table string such that characters โcโ and โsโ are replaced respectively by โkโ and โzโ
Translate a string using the table constructed above (make appropriate replacement of charactersโ
1/22/2009 21