You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 25147be
Browse filesBrowse the repository at this point in the historyBrowse files
Anastomose
committed
Adding list lab, string functions, and class notes.
new file: ../../../Students/ebuer/list_lab.py
new file: ../../../Students/ebuer/session_03/s3_notefile.txt
new file: ../../../Students/ebuer/session_03/string_funcs.py
ord () is the ordinal of a string value. This allows us to quickly alphabetize strings. Cap letters are indexed in front of lower case.
3
+
4
+
string.index() locates the first instance of a specified string passed to the operator.
5
+
6
+
string.count() acts as you'd expect it to with the count looking for the argument passed.
7
+
8
+
raw_input() takes a string that is presented to the user -- this function always returns a string, if you want an integer or float you must cast the value
9
+
10
+
float()
11
+
int()
12
+
etc
13
+
14
+
input() trys to make an intelligent guess as to what type the input is. This is a bad habit to get into using since it will accept bad inputs and attempt to run them, allowing for reverse injection attacks.
15
+
16
+
enumerate() will return the index for each value in a list
17
+
18
+
FLOW CONTROL
19
+
break -- terminates loop
20
+
21
+
continue -- skips everything below the continue line and returns to the top of the loop
22
+
23
+
else on a "FOR" loop -- else is executed if the loop does not break, e.g. it runs to completion.
24
+
25
+
string.split(argument) -- splits string on argument passed
26
+
string.join(argument) -- join list values into a string with argument separators
27
+
28
+
strings are immutible, so all string operations return a new string.
29
+
30
+
.isnumeric()
31
+
.isalnum()
32
+
.isalpha()
33
+
etc
34
+
35
+
36
+
ord() translates a character to ordinal value
37
+
char() translates values into characters
38
+
39
+
string.format() -- most current formatting tool, pretty powerful
0 commit comments