programing Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

what is the command for a For loop

A

for {set variable} in {variable}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is the command for a IF statement

A

if {variable} {operator} {variable}:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are the two other commands within an IF statement

A

Else and Elif

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the command for a WHILE loop

A

While {variable} {operator} {condition}:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are the different operators

A

==, <=, >=, !=, <, >, *, **, /, //, %

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how do you function a print statement

A

put a f before the first “

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the purpose of indentation

A

to run code inside a condition, the indented code is inside of the top code and will only run if the top code runs or is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the difference between local and global variables

A

local variables are variables that only store a value in a given subprogram and otherwise can not be used outside it unless the value is returnedor is made global using the global command.

a global variable is a variable that holds a value throughout the whole program and can be used everywhere within the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the purpose of optimizing code

A

optimizing code can make it more efficient by eliminating redundant code (code that is not needed) to make less operations per instance of the program making it run faster and more efficiently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how do you format text

A

{(veriable):(operator/value)}

{temp:<5} - alligns the value of variable {temp} to the left by 5 spaces

https://www.w3schools.com/python/ref_string_format.asp#:~:text=The%20format()%20method%20formats,method%20returns%20the%20formatted%20string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly