Intro To Computer Programming

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/38

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

39 Terms

1
New cards

+

Strings can be added together with this operator

2
New cards

ord()

Converts character to ASCII value

3
New cards

char()

Converts ASCII value to character

4
New cards

len()

Returns the length of a word as an integer

5
New cards

word[ ]

Used to find the character at a particular index

6
New cards

word[-1]

Will begin reading from the final character of the string

7
New cards

word.isalpha()

Returns a boolean value of whether ALL characters are alphabetical

8
New cards

word.isupper()

Returns a boolean value of whether ALL characters are uppercase

9
New cards

word[ ].isupper

Checks if a single character at a particular index is uppercase (boolean)

10
New cards

word.upper()

Converts a word to all upper case characters

11
New cards

word.swapcase()

Switches the case of all characters in a string

12
New cards

list_name = [ ]

Creates a new list

13
New cards

list[ ]

Format for list indexing

14
New cards

list.append(“item”)

Adds a string “item” to a list

15
New cards

list.remove(“item”)

Removes a string “item” from a list

16
New cards

list.index(“item”)

Find the index of string “item” in a list

17
New cards

min(list)

Find the minimum value in a list

18
New cards

max(list)

Find the maximum value in a list

19
New cards

list.split(“,”)

Turns a list into a string separated by a comma

20
New cards

try:

Place risky code — that may throw an error — under this block header

21
New cards

except:

Write code under this block header that will run if there is an exception (runtime error etc.) in a previous block

22
New cards

def name():

Creates a function called name

23
New cards

Local variable

A variable in a function that is only used in that function (e.g. a variable ‘x’ can be use din multiple functions because of this)

24
New cards

def name(a, b, c,):

Define a function called “name“ with functions a, b, and c

25
New cards

dict = { }

Create an empty dictionary named “dict’

26
New cards

:

Keys and values are separated by this

27
New cards

,

Key-value pairs are separated buy this

28
New cards

dict[key]

In a dictionary named ‘dict’ find the value of ‘key’

29
New cards

dict[new_key] = new_value

In a dictionary called ‘dict’ add a key called ‘new_key’ and a value called ‘new_value’

30
New cards

dict.keys()

Find all keys in a dictionary called ‘dict’

31
New cards

dict.values()

Find all values in a dictionary called ‘dict’

32
New cards

dict.items()

Find all key-value pairs in a dictionary called ‘dict’

33
New cards

for key in dict.keys()

Iterate over all keys in a dictionary called ‘dict’

34
New cards

for key, value in dict.items()

Iterate over all key-value pairs in a dictionary called ‘dict’

35
New cards

class class_name

Create a class called ‘class_name)

36
New cards

def __init_(self):

Write the constructive method used in classes (use one less underscore in the second “dunder” because of Knowt formatting)

37
New cards

def __init_(self, name, age):

Create a constructor method that passes arguments ‘name’ and ‘age’

38
New cards

dog1 = dogs(“Albert”)

Create a new instance of a class called ‘dogs’ and assign it to a variable ‘dog1’. The new dogs name is ‘Albert’.

39
New cards

dog1.name

Using the class ‘dogs’, find the name of ‘dog1’ (dog1 is already assigned as a variable)