programme

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/28

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:10 PM on 7/11/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

29 Terms

1
New cards

get length of string

print(len())

2
New cards

string mutable or not

immutable

unless:

  • using +=

  • id() function

    The id() function returns the object's memory address

3
New cards

lexicographical order

ord()

use ASCII table

4
New cards

isalnum(), isalpha(), isdigit()

  1. Return True if string is alphanumeric.

  2. Return True if string contains only letters.

  3. Return True if string contains only digits.

5
New cards

isidentifier()

Checks whether a string would be a valid name for a variable

Returns true or false

6
New cards

islower(), isupper(), isspace()

  1. Return True if string is in lowercase or changes word to lower

  2. Return True if string is in uppercase or changes word to upper

  3. Return True if string contains only white space.

7
New cards

endswith(s1), startswith(s1)

  1. Return True if string ends with sub-string s1.

  2. Return True if string starts with sub-string s1.

8
New cards

count(s1),find(s1),rfind(s1)

  1. Return number of s1’s

  2. Return lowest index from where string s1

  3. Return highest index from where string s1

9
New cards

print(s.capitalize()) ,print(s.title()) ,print(s.replace("trix", "d")) 

  1. cap the first letter

  2. cap the first letter of both words

  3. replace the given var

10
New cards

list

A list contains multiple items of any type. It is mutable and its contents can be manipulated. lists are dynamic items can be added or removed

list uses [brackets]

11
New cards

add items to list

  • append() to add an item at end of the list

  • insert() to insert a item at the specified index

12
New cards

delete item

  • pop() to remove item (by position) from the list

  • remove() to remove item (by content) from the list

  • clear() to remove all items from the list

13
New cards

max(list), min(list), sum(list),del(list)

  1. Returns the max value within the list

  2. Return the minimum value within the list

  3. Return the sum of all the items in the list

  4. Deletes the list

14
New cards

index(item), count(item),insert(index, item)

  1. Return the index of the first element whose value is equal to the item

  2. counts number of values

  3. Insert the item into the list at the specified index

15
New cards

sort(), reverse()

  1. Sort the items in the list in ascending order.

  2. Reverse the order of the items in the list

16
New cards

pop(), remove(item), clear()

  1. remove item at the specified index

  2. Remove the first item from the list

  3. Remove all the contents in the list

17
New cards

copy list content

by

  • slicing

  • operator 1  to duplicate the full content

  • copy()  to make a copy of the content

  • A list() constructor is a built-in function which can be used to convert an iterable

18
New cards

tuple

A tuple contains multiple items of any type.it is immutable and Tuples are more efficient in terms of performance and memory usage since they are immutable

uses (bracket)

19
New cards

tuple methods

Tuples only support index() and count() methods.

20
New cards

how to tuple to list

tuple( listName )

reverse

list( tupleName )

21
New cards

dictionary

A dictionary stores a collection of data. Each item in a dictionary has two parts: a key and a value. Dictionaries are mutable and their contents are immutable.

uses {bracket}

22
New cards

when to uss [bracket] in dictionary

The square bracket [] and the key is used to retrieve value from a dictionary. It is also used to :

  • update value in the dictionary

  • add a new value to the dictionary

23
New cards

sorted()

use sorted() to create a sorted list of key

for key in sorted( dic.keys() ) :         #returns keys sorted in a list

   print( key , ":" , dic[ key ] )


Output:
Abe : Boss

Bob : Cook

Nat : Staff

Pete : Chef

24
New cards

list in dict

print( f"Jerome's Math mark : { examResult['Jerome'][1] } " )

25
New cards

dict in dict

print( f"Jerome's Math mark : { examResult['Jerome']['Math'] } " )

26
New cards

list in list

print( f"Jerome's Math mark : { examResult[2][2] } " )

27
New cards

while loop vs for loop

while It is a condition-controlled loop. The loop will keep executing until the condition becomes false.

for It is a count-controlled loop

28
New cards

break statement

The break statement ends the current loop and jumps to the statement immediately following the loop.

29
New cards

continue statement 

The continue statement ends the current iteration and jumps to the top of the loop and starts the next iteration.