PCEP

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/136

flashcard set

Earn XP

Description and Tags

Python Certified Entry-Level Programmer

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

137 Terms

1
New cards

What type of language is python

An interpreted language

2
New cards

Interpreted language

Code that is translated one line/instruction at a time.

3
New cards

Is compilation or interpretation typically faster?

Translated compiled code tends to run faster, whereas the compilation itself takes longer.

4
New cards

Does the end-user need a compiler?

No

5
New cards

Does the end-user need an interpreter?

Yes

6
New cards

How is compiled code stored?

It is stored in machine language

7
New cards

How is interpreted code stored?

In the programming language

8
New cards

Where can python functions come from?

They can be built into the language, be user defined, or imported from modules

9
New cards

Can several things occur on the same line

NO

10
New cards

What happens when you dont pass arguments to print()

When you don't pass arguments to print(), it will just output a new line. You can also use the escape character \n.

11
New cards

How do you print a backslash in a print statement

Double it up, \

12
New cards

How do you print quotation marks in a print statement?

print(' " ')

13
New cards

What is a keyword argument

An argument unaffected by its position

14
New cards

What are the keyword arguments for the print statement

end, sep

15
New cards

Where do keyword arguments go?

After the positional argument

16
New cards

What is a positional argument

An argument that is dictated by its position

17
New cards

What is a literal

A literal is a sequence of characters used in a program to represent a constant value.

18
New cards

Is a char or string a literal in python?

NO

19
New cards

Python literals

integer, floating point. An int has no dots.

20
New cards

Can you use underscores in a literal?

Yes

21
New cards

Booleans

True 1, False 0

22
New cards

How to determine int or float in arithmetic?

When both arguments are integers, the result is an int. If any arguments are floats, the end result will be a float.

23
New cards

Integer division

An operation that divides one integer by another and yields an integer. Integer division yields only the whole number of times that the numerator is divisible by the denominator and DISCARDS ANY REMAINDER

24
New cards

Binding of an operator

the order of computations performed by operators with equivalent precedence

25
New cards

Only right binding operator

Exponentiation, **

26
New cards

Variable naming rules

Cannot be a keyword

Must begin with a letter

Can contain letters, digits, and underscores

Case-sensitive

27
New cards

Comments in python

#

28
New cards

How can you save input

Assign it to a variable

29
New cards

Can you concatenate strings

Yes, with +

30
New cards

Can you concatenate strings and integers

NO

31
New cards

How do you replicate strings

StringA * 10 or 10 * StringA

32
New cards

What happens if you multiply a string by a number less than or equal to0

The string will be null

33
New cards

String typecast

str()

34
New cards

Python follows PEMDAS.

True

35
New cards

If statement

An if keyword is followed by an expression which evaluates to a boolean. All code for this statement is indented, indicating that it falls within this statement.

36
New cards

Else statement

An else statement is the same thing, else followed by a colon. These statements can be nested if indentations are performed properly.

37
New cards

Elif statement

The elif statement is an else if, and if the first if does NOT evaluate to true, than the elif condition will be checked

38
New cards

How many else statements can you have for an if block

zero or one

39
New cards

max()

Accepts multiple arguments, returns the highest value argument

40
New cards

min()

accepts multiple arguments, returns least value argument

41
New cards

While loop

A while loop will repeat a series of statements for as long as a certain condition evaluates to true. Recall that 1 is true and 0 is false, so if arithmetic operations evaluate to either 1 or 0, that works as true or false!

42
New cards

While else branch

A while loop can be followed by an else branch that will execute NO MATTER WHAT

43
New cards

Multi-line printing

Three apostrophes

44
New cards

Are strings a sequence type

Yes

45
New cards

Can strings be sliced

Yes, they are a sequence type

46
New cards

for loop

The for loop opens with the "for" keyword. The variable following is the control variable of the loop. The control variable automatically counts iterations of the loop. The control variable is followed by the "in" keyword and the range() function.

47
New cards

range()

If passed one argument, it will start from zero and count up to, but not including, the passed argument

48
New cards

If passed two arguments, itll count from the first to the second

49
New cards

If passed three arguments, itll count from the first to the second with the increment specified by the third argument.

50
New cards

Does range() accept float values

No, the range() function only accepts integers.

51
New cards

break

Exits the loop completely, and does not resume on the next iteration

52
New cards

continue

exits current iteration and begins the next iteration

53
New cards

For else branch

The else branch will execute NO MATTER WHAT. The only case in which it wouldnt is if a break statement executed before the else was reached.

54
New cards

bitwise AND

argA & argB

55
New cards

bitwise OR

argA | argB

56
New cards

bitwise NOT

~argA

57
New cards

bitwise XOR

argA ^ argB

58
New cards

Can bitwise logic be passed floats?

NO. ONLY INTEGERS.

59
New cards

Lists

Lists are like arrays in Java, except they are mutable. Lists can store a sequence of values.

60
New cards

Can list store different data types

Yes

61
New cards

Are lists indexed?

Yes, zero-based.

62
New cards

List initialization

myList = [1, 2, 3]

63
New cards

List index of -1

An index of -1 would mean the last element, -2 the element before that, and so on.

64
New cards

Method

a method is owned by the data it works for while a function belongs to the whole code.

65
New cards

myList.append(arg)

66
New cards

myList.insert(index, arg)

67
New cards

Function

Does not belong to any data, but rather, the whole code. A function does not belong to any data, it gets data, may create new data, and typically produces a result.

68
New cards

Swapping values

var1, var2 = var2, var1

69
New cards

list.sort()

method that sorts elements in list

70
New cards

list.reverse()

Reverse the elements of the list, in place.

71
New cards

listA = listB

Creates two variables for the same list

72
New cards

listA = listB[:]

Copies listB values into list a

73
New cards

Slice [:]

Implicitly 0, -1

74
New cards

Used to retrieve portions of sequence data types

75
New cards

del myList[0:3]

Would delete the first 4 elements of myList

76
New cards

in/not in

will check if an element is or is not present in a data structure (or the range function)

77
New cards

Filling a list with a for loop

myList = [x**2 for x in range(10)]

78
New cards

2-D list with a for loop

A 2-D list is a list within a list. Assume EMPTY is a predefined symbol, then:

79
New cards
80
New cards

board = [[EMPTY for i in range(8)] for j in range(8)]

81
New cards

Function definition

def myFunction(parameters):

82
New cards

code

83
New cards

Where does a parameter exist

ONLY in the function

84
New cards

Where is a parameter defined

In the parentheses

85
New cards

When is a value given to a parameter

When arguments are passed to it during invocation

86
New cards

Parameter vs argument scope

Parameters live inside of the functions while arguments live outside of the function.

87
New cards

Positional arguments

Passed by the order in which they appear

88
New cards

Keyword arguments

Must come AFTER positional arguments, explicitly stated.

89
New cards

Default parameter values

def myFuncton(a = 0):

90
New cards

If a parameter has a default does it NEED to be initialized

No, but it still can be

91
New cards

How do you return

Use the return keyword, and if you follow with an argument, that value will be returned.

92
New cards

Can you return nothing?

Yes, it is of type None

93
New cards

What can be done with the None keyword

It can be assigned to variables

94
New cards

It can be compared to variables

95
New cards

It can be returned from functions

96
New cards

Scope

Where in the program the variable is accessible

97
New cards

Scope of variable in function

Only within that function

98
New cards

Scope of variable outside of functions

The entire program

99
New cards

Scope of global variables

The entire program

100
New cards

Function-variable interaction

Changing a parameter's value will not automatically change the argument, as an argument will pass its value and not its reference