Scope and String Methods Flashcards

Outlines key concepts in scope and string methods

1
Q

What is local scope?

A

Things defined in the current function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does local scope include?

A
  1. All parameters of the current function
  2. All variables defined (assigned) anywhere within current function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Global scope?

A

All top - level definitions in the file functions and other variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does Global Scope include?

A
  1. All things created at no indentation
  2. Anything explicitly made global with a global statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Built - in scope

A

Functions that come with Python. Such as print() and int()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When are built - in functions available?

A

They are always available unless a closer definition with the same name hides it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of the method s.upper()?

A

converts letters to uppercase letters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of return value is associated with s.upper?

A

A modified copy of s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of s.lower()?

A

converts letters to lowercase letters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What type of return value is associated with s.lower()?

A

modified copy of s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of s.starswith(sval, start, end)

A

Identifies whether a string starts with the characters indicated in the argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What type of return value is associated with s.starswith(sval, start, end)?

A

bool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of s. endswith(sval, start, end)?

A

Identifies whether a string ends with the characters indicated in the argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What type of return value is associated with
s. endswith(sval, start, end)?

A

bool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of the method s.join(iterable)?

A

Concatenates items from iterable, with copies of string s in between them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What data type is the return value of s.join(iterable)?

A

string result of the joined strings

17
Q

What is the purpose of the method of s.split(sep)?

A

get list of strings obtained by splitting s into parts at each occurrence of sep

18
Q

What type of return value does s.split(sep) return?

A

a list of strings from between occurrences of sep.

19
Q

What is the purpose of the method s.replace(old, new, count)?

A

replace all (or count) occurrences of old str with new str

20
Q

What type of return value does s.replace(old, new, count) return?

A

string with replacements performed

21
Q

What is the purpose of the method s.strip(characters) ?

A

Removes the set of characters

22
Q

What type of return value does s.strip(characters) return?

A

string with changes performed

23
Q

What is the purpose of the method split()?

A

A built - in string method to make a string as list of substrings based on a given separator.