1/95
storage location in a computer program - value - store in memory location
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
what are primitive data types
data,, floats, whole number values
reference data type?
complex structures, aries, strings
define a variable
named storage location whose value can change while program is running, can be over ridden
define constants and examples
cannot be changed, numeric constants ()/ string constants(‘‘)
use UPPER_CASE

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
why cannot you use class as a variable name
it is already reserved word
why can you not use letter/us.ot
you cannot use the symbols
whats camel case
firrstword lowercase second word starts with a capital
what is papscal
both capitals for both parts of the name
what is Sniciss
with underscores
what is kebabcase
using a dash - make sure its not a minus
whats a neumonic
memory aid to know what your value is storing in memory
what are the operators

what are the types of data types
integers/ floats
what is the difference between int/float
+ve,-ve,0
exp, frcat, .
what does concatenate mean
put two strings together

how do you identify a data type
type ()
greetings = ‘hello’ + ‘danny’
print (type(greetings)))
output <class ‘str’>
define type conversion/ typecasting
changing one type of data into another string
int(), float (), str(), complex()
how do you show a type cast in code
print(float(111) + 11)
122.0
how do you type cast variabl data types
i = 59
f = float(i)
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
HOW DO YOU SHOW A SLICE

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

hwo do you convert between strings and integers

how do you get user input
name= input(‘what is your name’)
print( ‘welcome’, name, ‘!’)
how to ask for iinitials if names are already given
initials = name1[0] + ‘.’ + name2[0]
print (‘your initials are’, initials)
elevtor problem

what are the modern applications of programming language
developed under heavy time constraints
teams
run time
written by a lot of people
define code
seriese of sorted instruction
about python
guido van rosso
high skilled language
portable since high skilled
free and open source
compiler porcess
source code → complier → oject code → execture → output
interpreter
source code → interpreter → output
what is a vim command mode
Vim can be used with your command line program to edit programs written in any programming language
what is the difference between equality operators and rational operators
equal or not equal / more than less than
what must you put after each if statement
the colon denotes that the immediate statement is inside
Example program of an if statement

how do you write a prime number program

what is a boolean statement
true or false, 1/0, yes/no
show an if elif else statement (nested)

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
show a nested if statement
one if statment inside of another

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
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.
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
what are for loops
they are used to iterate part of a program several times
define iteration
the process of instructing the python program to repeat the code constrct again, instructions are performed one after another
what doe sthe i represent in the for i in range for loop
placeholder ame which represents the current value in the sequence
how do you use a for loop to right y = 3x² + 3

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>](https://knowt-user-attachments.s3.amazonaws.com/5c3e3786-95d1-409b-a7cf-dfe84dc47086.png)
when is a for loop used vs when is a while loop used
for: fixed iterations
while:iterations are not fixed
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)
how do you write a program that will use a nested for loop to find the prime numbers between 2 and 30

what is a break statement used for
to terminate a loop, if in nested it will terminate the innermost loop
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
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
what are comparison operators
they look at or access variables but do not change the value
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
what does a greet function look like
def greet(name):
print('Hello', name)
userName = input('Enter your name: ')
greet(userName)
how are functions stored
stored in code segment of memory,
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
what are the built in functions
provided as part of the python program such as print input type float in
what are user defined functions
functions we define ourselves, new ‘reserved words’
why use functions?
store and re-use
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
revise the built in functions

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.
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
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
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
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
testing a function
if we run the program containing only the function defentiion then nothing will happen
what does the term black box mean
used in program with given specification but unknown implementation or outcome
what is type casting
process of converting from one data type to another
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
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)
what are recursive functions
function that calls itself
define depth of recursion
maximum call stack level reached during recursion (deeper = more memory)
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.
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
what is function overloading
having multiple functions with teh same name but different paramter types that behave differently
why is python special when it comes to function overload
does not allow multiple functions wiht the same name, allows checking types at runtime
what i an argument
when you pass a value in a function
local vs global
defined withiin function - global can be used anywhere
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
efine a string
sequence of characters within python and programming general.
- arrays of bytes represting unicode characters
define concatinate
the plus sign + - process of joining two or more strings together in a program
what are the 4 ways of joining strings together
+, join(), % string formatting operator, format()
what is an operator overload
meaning of string changes based on data types
how do you use join()

how do you use the % operator for concatinating strings

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

how do you access a string
square brackets to access string elements- use index specified in square brackets
what does appending strings mean
adding one string to anotherby using += operator d
define immutable strings
strings whose values cannot be chamged after they are assigned to string object- cannot be uopdated & cannot be re assigned
string formatting operators image and desc
