programing Flashcards
what is the command for a For loop
for {set variable} in {variable}
what is the command for a IF statement
if {variable} {operator} {variable}:
what are the two other commands within an IF statement
Else and Elif
what is the command for a WHILE loop
While {variable} {operator} {condition}:
what are the different operators
==, <=, >=, !=, <, >, *, **, /, //, %
how do you function a print statement
put a f before the first “
what is the purpose of indentation
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.
what is the difference between local and global variables
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.
what is the purpose of optimizing code
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 do you format text
{(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.