define variable

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

1/95

flashcard set

Earn XP

Description and Tags

storage location in a computer program - value - store in memory location

Last updated 9:36 AM on 2/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

96 Terms

1
New cards

what are primitive data types

data,, floats, whole number values

2
New cards

reference data type?

complex structures, aries, strings

3
New cards

define a variable

named storage location whose value can change while program is running, can be over ridden

4
New cards

define constants and examples

cannot be changed, numeric constants ()/ string constants(‘‘)

use UPPER_CASE

<p>cannot be changed, numeric constants ()/ string constants(‘‘)</p><p>use UPPER_CASE</p><p></p>
5
New cards

what are reversed words

should not be used - already have their own fixed meanings and should not be used as variable names, function names or identifiers

6
New cards

why cannot you use class as a variable name

it is already reserved word

7
New cards

why can you not use letter/us.ot

you cannot use the symbols

8
New cards

whats camel case

firrstword lowercase second word starts with a capital

9
New cards

what is papscal

both capitals for both parts of the name

10
New cards

what is Sniciss

with underscores

11
New cards

what is kebabcase

using a dash - make sure its not a minus

12
New cards

whats a neumonic

memory aid to know what your value is storing in memory

13
New cards

what are the operators

knowt flashcard image
14
New cards

what are the types of data types

integers/ floats

15
New cards

what is the difference between int/float

+ve,-ve,0

exp, frcat, .

16
New cards

what does concatenate mean

put two strings together

<p>put two strings together</p>
17
New cards

how do you identify a data type

type ()

greetings = ‘hello’ + ‘danny’

print (type(greetings)))

output <class ‘str’>

18
New cards

define type conversion/ typecasting

changing one type of data into another string

int(), float (), str(), complex()

19
New cards

how do you show a type cast in code

print(float(111) + 11)

122.0

20
New cards

how do you type cast variabl data types

i = 59

f = float(i)

21
New cards

define slice

A slice gives from a string one character in the position of the index. E.g. S[i] means the ‘i’ is the position index of the string character

22
New cards

HOW DO YOU SHOW A SLICE

knowt flashcard image
23
New cards

how doo you give the last letter of a string when ou slice

knowt flashcard image
24
New cards

hwo do you convert between strings and integers

knowt flashcard image
25
New cards

how do you get user input

name= input(‘what is your name’)
print( ‘welcome’, name, ‘!’)

26
New cards

how to ask for iinitials if names are already given

initials = name1[0] + ‘.’ + name2[0]

print (‘your initials are’, initials)

27
New cards

elevtor problem

knowt flashcard image
28
New cards

what are the modern applications of programming language

  • developed under heavy time constraints

  • teams

  • run time

  • written by a lot of people

29
New cards

define code

seriese of sorted instruction

30
New cards

about python

  • guido van rosso

  • high skilled language

  • portable since high skilled

    • free and open source

31
New cards

compiler porcess

source code → complier → oject code → execture → output

32
New cards

interpreter

source code → interpreter → output

33
New cards

what is a vim command mode

Vim can be used with your command line program to edit programs written in any programming language

34
New cards

what is the difference between equality operators and rational operators

equal or not equal / more than less than

35
New cards

what must you put after each if statement

the colon denotes that the immediate statement is inside

36
New cards

Example program of an if statement

knowt flashcard image
37
New cards

how do you write a prime number program

knowt flashcard image
38
New cards

what is a boolean statement

true or false, 1/0, yes/no

39
New cards

show an if elif else statement (nested)

knowt flashcard image
40
New cards

what is a nested statement

statement that we write upon snother conditional statement, we define a statement and within the block of the statement we define another statement

41
New cards

show a nested if statement

one if statment inside of another

<p>one if statment inside of another</p>
42
New cards

when do you use a nested if statment or an elif statment

elif is when the variables do not depend on each other
nested if is better when the second variable is depending if the first variable passes

43
New cards

what happens if an if statement is nested in an else:

The statement “Congratulations you score a B” is only printed if and only if the outer if condition results in false and the inner if condition results in true. In other words, the first if condition must have to “fail” before the second print statement will print the outcome.

44
New cards

what happens if one nested if else statement is inside another if else statement

it gives you the ability to specify consition and to continue the execution expanding upon the result obtained by checking those conditions set withing the code block

45
New cards

what are for loops

they are used to iterate part of a program several times

46
New cards

define iteration

the process of instructing the python program to repeat the code constrct again, instructions are performed one after another

47
New cards

what doe sthe i represent in the for i in range for loop

placeholder ame which represents the current value in the sequence

48
New cards

how do you use a for loop to right y = 3x² + 3

knowt flashcard image
49
New cards

write for loop for all even numbers

listOfNumbers = [1,2,3,4,5,6,7,8,9,10]

number = 2

for i in listOfNumbers:

evenNumber = number * i # multiply 2 by i

print(evenNumber)

<p>listOfNumbers = [1,2,3,4,5,6,7,8,9,10]</p><p>number = 2</p><p>for i in listOfNumbers:</p><p>    evenNumber = number * i  # multiply 2 by i</p><p>    print(evenNumber)</p><p></p>
50
New cards

when is a for loop used vs when is a while loop used

for: fixed iterations
while:iterations are not fixed

51
New cards

what are sentinel controlled loop

construct that we write into the while loop condition to instruct our program to stop looping once the sentinel value is entered as an input

while (number ≠ -1)

52
New cards

how do you write a program that will use a nested for loop to find the prime numbers between 2 and 30

knowt flashcard image
53
New cards

what is a break statement used for

to terminate a loop, if in nested it will terminate the innermost loop

54
New cards

what is a continue statement

used to skip the rest of the code inside a loop for the current iteration one, loop does not terminate but continue with next iteration, it moves onto the next available iteration to execute

55
New cards

what is the difference between a pass statement and a null statement

null statement the interpreter ignores a comment entirely, the pass statement is not ignored- the pass statement is a no operation NOP

56
New cards

what are comparison operators

they look at or access variables but do not change the value

57
New cards

what is a function

  • re-usable code, which is stored in a segment of memory which will be retrieved, sequential instructional code.

  • made up of block statements that perform a specific

  • start with DEF keyword

    • argument/parameter should be pass inside the parentheses and begins with :

  • sequence of insturctions with a name

58
New cards

what does a greet function look like

  • def greet(name):

  • print('Hello', name)

  • userName = input('Enter your name: ')

  • greet(userName)

59
New cards

how are functions stored

stored in code segment of memory,

60
New cards

what are the functions/ features of functions

  • holds reusable code

  • created to avoid repetition

  • recursive nature

  • when called compiler remebers the line for which the function is called

  • defned by using def keyword

    • useful way of dividing program codes into managable chunks

61
New cards

what are the built in functions

provided as part of the python program such as print input type float in

62
New cards

what are user defined functions

functions we define ourselves, new ‘reserved words’

63
New cards

why use functions?

store and re-use

64
New cards

what does return expression mean

  • sends a value/ output back form the function

    def add(a, b):

  • return a + b

  • result = add(5, 3)

  • print(result) # Output: 8

65
New cards

revise the built in functions

knowt flashcard image
66
New cards

what are parameters and arguments

  • arguments are specific values with data type (int float string_ we pass into the function to perform a specific operation, we can pass several arguments into the function seperated with a comma
    paramater: term can be used interchangably
    The variable defined within the parentheses when we define our function is referred to as a parameter list. While the value we passed into the function when it is called is referred to as an argument.

67
New cards

what is an argument

value we pass into the function as an input

we can instruct the function to perform different kinds of operation when we call it at different times

68
New cards

what are arbitrary arguments

used as a place holder to hold so many values passed in as arguments in a function paramater list, you may not know how many arguments to use, therefore use * to denote arbitrary method before the parameter list

69
New cards

what is function overloading

  • in object oriented programming where two or more functions have the same name but are differentiated by a parameter list

    • add(5) → adds one number

    • add(5, 10) → adds two numbers

    • add(5.5, 2.1) → adds floats

70
New cards

return statements

used to finish the execution of a function call and return the result of the value in an expression

  • the statements following thereturn statements are skipped

  • if there is no expression in the return declaration the unique value none is return

    • you cannot use a retrn statement outside of a function decleration

71
New cards

testing a function

if we run the program containing only the function defentiion then nothing will happen

72
New cards

what does the term black box mean

used in program with given specification but unknown implementation or outcome

73
New cards

what is type casting

process of converting from one data type to another

74
New cards

define scope

scope of a variable is the part of the program in which you can access it, e.g. scope of a functions parameter variable is the entire function

75
New cards

local scope vaiables

variables defined within the confinment of a functio or within a confinment of a for loop/ if statement (block/local to construct)

76
New cards

what are recursive functions

function that calls itself

77
New cards

define depth of recursion

maximum call stack level reached during recursion (deeper = more memory)

78
New cards

what is a slice/substring

A substring (often called a slice in Python) is a piece of a string that you take from a bigger string.

79
New cards

what are functions with parameters

  • recieves values from outside, uses those values inside of the function, often returns a result


    def add(a, b):

  • return a + b

80
New cards

what is function overloading

having multiple functions with teh same name but different paramter types that behave differently

81
New cards

why is python special when it comes to function overload

does not allow multiple functions wiht the same name, allows checking types at runtime

82
New cards

what i an argument

when you pass a value in a function

83
New cards

local vs global

defined withiin function - global can be used anywhere

84
New cards

what is a lambda function

A lambda function is a small, anonymous function written in one line

no name, written in one line can contain only one expression automatically returns the resultd

85
New cards

efine a string

sequence of characters within python and programming general.
- arrays of bytes represting unicode characters

86
New cards

define concatinate

the plus sign + - process of joining two or more strings together in a program

87
New cards

what are the 4 ways of joining strings together

+, join(), % string formatting operator, format()

88
New cards

what is an operator overload

meaning of string changes based on data types

89
New cards

how do you use join()

knowt flashcard image
90
New cards

how do you use the % operator for concatinating strings

knowt flashcard image
91
New cards

how do you use the format () function to concatinate strings

<p></p>
92
New cards

how do you access a string

square brackets to access string elements- use index specified in square brackets

93
New cards

what does appending strings mean

adding one string to anotherby using += operator d

94
New cards

define immutable strings

strings whose values cannot be chamged after they are assigned to string object- cannot be uopdated & cannot be re assigned

95
New cards

string formatting operators image and desc

knowt flashcard image
96
New cards