On some Python ah shi

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/25

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:01 PM on 9/18/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

26 Terms

1
New cards

What do variables have to start with?

either a letter or an underscore - can’t start with a number and ARE case sensitive

2
New cards

To make comments (make a code inactive), then…

Add a hash, which is cmd + /

3
New cards

What does % do?

gives remainder of first no. divided by second number

4
New cards

equal to and not equal to

“==” is equal to, “!=” is not equal to

5
New cards

“ifand” function

same as excel, just use “and” with spaces. Same with “or”

6
New cards

“not” used to..

flip a condition you’re checking

7
New cards

Not function example

Print(not(10 < 5 or 13 < 25)) ==> ans is FALSE

8
New cards

If you want to connect two things (like a no. to “sales”), use…

5 = “whatever”

9
New cards

How is a list defined? (what brackets?)

Square brackets [ ]

10
New cards

how would I print the length of my list? (after creating a list, for example [0, 1, 2, 3, 4, 5])

print(len(mylist)

11
New cards

Finding a specific character in your list (remember that indexes and lists start from zero)

print(mylist[2]) - would return 2 if starts from 0

12
New cards

strings vs sequences

strings are also sequences, but can’t be changed once created

13
New cards

How do I return just part of my sequence?

Slice - print(mylist[1 : 4 : 1]) … means print from characters 1 to 4 at a step of 1 character

14
New cards

Trick to reverse sequence

print(mylist[ : : -1])

15
New cards

Tuple

Used to hold data that won’t change (immutable)

16
New cards

How are sets defined? (what brackets)

Curvy brackets! { }

17
New cards

Rules for sets

Can only contain unique values, and repeated numbers won’t print more than once

18
New cards

What does “in” test for?

Tests for membership (whether something is in the list or not)

19
New cards

“in” example

print(1 in mylist) ==> returns TRUE/FALSE

20
New cards

What is the purpose of using mydict

if you do “mydict = {“one” : 1, “two” : 2, 3 : “three”, 4 : “four”}” then you connect pieces of data to “key” values

21
New cards

how to print using mydict

print(mydict[“one”]) returns 1

22
New cards

which values come first and second, values or keys?

Keys first, values second

23
New cards

Can “if” be used in a print statement?

Yes! ==> if x < y : print(“x is less than y”)

24
New cards

How can I created a statement that will return an answer for “if x<y, then say this, but otherwise, say this!”

“x less than y” if (x<y) else “x > or = y”

25
New cards

How do I indent?

Press tab (or insert 4 spaces)

26
New cards

What’s the point of indentation?

indentation is how the computer knows which lines of code belong together