Python Flashcards

1
Q

Programs

A

Lists of instructions the computer preforms in sequential order

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

Source Code

A

Program written in a high-level programming language

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

Python

A

High-level programming language
Easy
Emphasizes code readability

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

Python Interpreter

A

Read instructions from top to bottom, left to rights
Performs instruction validation
run in command line: py or python3

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

IDE

A

Integrated Development Environment
Most useful in Python: PyCharm

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

IDLE

A

Python’s Integrated Development Learning Environment

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

String

A

multiple characters (animals)

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

Integer

A

Number without decimal (2)

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

Float

A

Decimal number (2.5)

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

Boolean

A

True or False

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

Hashtag #

A

Renders an entire line as a comment

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

””” three quotes

A

Used in the beginning and end of multi-line comments

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

print()

A

Prints what is in the ()

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

Keywords

A

Python’s reserved words and instructions like print, def

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

Indentation

A

Mechanism that associates a block of code with a condition, loop, or class

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

input function

A

Used to ask a user for input
Always a string data type
name = input(“Please enter your name: “)

17
Q

Data Types

A

String, Integer, Boolean, Float

18
Q

string formatting

A

% ex: item 1 = “Hi, my name is %s and I’m %d years old”
.format ex: item2 = “Hi, my name is {} and I’m {} years old”
f ex: item3 = f”Hi, my my name is {} and I’m {} years old”

19
Q

Logical Operations

A

Used with Boolean expressions
Truth table: Table that defines the results of a binary operation
AND: Both conditions must be true (to be a true statement or it is false)

20
Q

Conditional Operations

A

OR: Only one operation must be true (always true unless both conditions are false)
NOT: Reverse the result of the operation
XOR: Exclusive OR True if the results of the operation aren’t similar (must have a true and false)

21
Q

Type Casting

A

Converting one data type to another date type
int(), float(), str()

22
Q

List

A

Dynamic data type that can hold different types of data simultaneously.
Starts at 0 [cat, dog, bear] 0=cat

23
Q

Dictionary

A

Have a key:value format (ex: personDict = {“name”:”Chad”} )
Dictionaries are identified by curly brackets

24
Q

Nested Data Structures

A

Can hold other data structures
nestedDS = [“hello”, {“name”:”John”, “age”:24}, [“one”, “two”]]
This example is a list with a nested dictionary and another list

25
Q

Tuple

A

Cannot be edited
Write values separated by commas (cat, dog)

26
Q

String Concationation

A

Join strings together with +

27
Q

String Sub-String

A

Also known as slicing
Slice specific characters from a string
string[start:end] or string[start:end:step]

28
Q

Loops

A

A group of code used when you need something to repeat several times
break command exits the loop
continue command skips the iteration
pass command is used as an empty execution

29
Q

for loop

A

Used to repeatedly execute a group of statements as long as the condition is satisfied. Used when you know how many times it needs to repeat

30
Q

while loop

A

Performs a block of code while a condition is true-if it is false, it will not be executed
Used if you do not know how many times it needs to repeat

31
Q

open()

A

To open a file. Needs text name, and function (r-read, w-write, a-append)
myfile = open(“file.txt”, “w”)

32
Q

close()

A

Need to be used after open in order to save and close your work
myfile.close()

33
Q

function

A

Blocks of code with reusable logic
You can call upon it without having to write the same code again

34
Q

scope

A

What defines the visibility of a variable
4 types: local, enclosed, global, and built-in

35
Q

return

A

Send the function’s result back to the caller. Get information out of a function

36
Q

try & except

A

try creates a code block to execute code that may create an error
execute handles the error in the try code

37
Q

Recursion

A

Functions that call themselves
Need to make sure it has an exit condition

38
Q

class

A

an object and defines an objects properties
class Car:
def __init__(self, color) :
self.color = color
__init__ allows the attributes of a class to be initialized for an object
Class attributes and methods are assessed by using self

39
Q

netcat

A

Tool used to test the connection (socket)