Digital Coding T4

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

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:32 AM on 11/20/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

34 Terms

1
New cards

#function

Creates a note that doesn't show in the code when it is run

Example #this is an example of what a hash does

2
New cards
Integer

Int - Converts a variable into a WHOLE number

*NOTE: Integers will always round down

3
New cards
\n
new line (enter)
4
New cards
\t
tab
5
New cards
F string
creating a print with variables in it
6
New cards
Integer Example

variable1 = int(input("What is your age: "))

variable2 = int(2.5)

*NOTE: Integers will always round down

7
New cards
\n example

print("Hello \nWorld")

Output Hello World

8
New cards
\t example

print("Hello \tWorld")

Output Hello World

9
New cards
F string Example

name = "Olivia"

age = 16

print(f"My name is {name} and I am {age}.")

Output

My name is Olivia and I am 16.

10
New cards
Input

Allows the user to input data into the coding

*NOTE: Inputs will always be a string at first unless otherwise stated by the code

11
New cards
Input Example

name = input("Enter your name: ")

print(name)

Output

(whatever the person put in)

12
New cards
Variable
A word that holds a value or information
13
New cards
Variable Example

age = 15

print(age)

Output

15

14
New cards
Float
Float - A number with a decimal point
15
New cards
Float Example

height = float(input("Enter your height (m): "))

print(f"{height:.2f}")

*NOTE: The {height:.2f} means that the float that was input is rounded to two decimal places (always rounded DOWN)

16
New cards
Swapping Variables
a = 1
b = 2
a, b = b, a
print(a)
print(b)

17
New cards
Boolean
A single value of either TRUE or FALSE
18
New cards
Boolean Example

d = True

print(d)

f = False

print(f)

Output

True

False

19
New cards

==

sees if the condition is met (is it true)

20
New cards

!=

sees if the condition is not met (it is false)

21
New cards
Three Control Structures

sequence, selection, iteration

22
New cards
Sequence
a series of instructions
23
New cards
Sequence Example
Instructions for a cake
24
New cards
Selection
If... then... else
25
New cards

Selection Example

If it is raining, then stay inside, else put on a hat

26
New cards
iteration

looping/repetition

While... Do... Repeat... Until... For 1 to ... do....

27
New cards
Iteration Example

Brushing Hair (until tangle free)

while answer == "yes":

..........

else: print("We don't accept that at the moment and you will not be getting your food/drink.")

28
New cards

Range in for loop

()

29
New cards

Sequence of Numbers brackets in for loop

[]

*NOTE: range [1, 10] will only print numbers 1 to 9

30
New cards

Dictionary brackets in for loop

{}

31
New cards

To the power of

**

32
New cards

divide and round down (as an int)

//

33
New cards

remainder amount

%

34
New cards

division (auto converts to float)

/