Business Programing

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/115

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

116 Terms

1
New cards

How do you read user input in python and store it in a variable?

use input() aka name = input(“enter your name”)

2
New cards

what issue can occur when numerical values are inputted by the user? 

input() returns as a string, so numeric input must be converted for numeric type calculations 

3
New cards

how do you convert numeric user input from a string to a number?

use int() for integers, and float() for decimals, aka age = int(input(“enter age: “))

4
New cards

what are the python symbols for the basic mathematical operators?

+ (addition), - (subtraction), * (multiplication), / (division), // (integer division), % (modulus), ** (exponentiation).

5
New cards

what is an operand

a value or vairiable which an operator performs an operation, (2+3) and 2, 3 are oprands

6
New cards

how do you store the result of a calculation in a variable? 

use = 

7
New cards

how do we type percentages in a calculation?

divide the percentage by 100

8
New cards

what are two division operators in python and what do they return?

/ returns with a float, // returns an integer (floor divison)

9
New cards

does integer division round up of down

down (towards negative infinity

10
New cards

how do you determine the remainder of a division? 

use the modulus operator %, aka 7 % 3 returns 1 

11
New cards

how do you perform exponentation

use **

12
New cards

what is the precedence of operators in python

pemdas

13
New cards

what is a magic number 

a number used directly in code 

14
New cards

what is a constant

a variable that the value is not meant to change

15
New cards

what is the naming convention for constants

typically all uppercase letter

16
New cards

what is a syntax error? 

error caused by iccorect python code strucutre, missing parenthesis etc. 

17
New cards

what is a logic error

an error code where code runs but produces the wrong result

18
New cards

what is an exception?

error detected during program execution

19
New cards

what is the alternate name for an exception 

runtime error 

20
New cards

what does name error mean

attempting to use a variable that has not been defined

21
New cards

what does type error mean

an operation or function that is applied to the wrong data type

22
New cards

what is data type conversion 

changing value from one data type to another, ex string to an integer 

23
New cards

what is implicit conversion

automatic type of conversion done by python in calculations

24
New cards

what are rules for implicit conversion

integer + integer = integer
float + float = float

integer + float = float

25
New cards

how do we perform explicit conversion? 

use int() for float () to manually convert types when needed 

26
New cards

how does int() work

converts to an integer rounding down

27
New cards

how does float() work

converts to a float

28
New cards

why do we perform explicit conversion:? 

because intput() automatically returns a string 

29
New cards

what is the definition of software

a collection of programs that perform tasks on a computer

30
New cards

what is a program

a set of instructions that tell the computer how to perform a task

31
New cards

what is a statement 

indevidual commands in a program 

32
New cards

what are the steps in a program development cycle

  1. analyze the program

  2. design the program

  3. code (write) the program

  4. test/debug the program

  5. document the program

  6. maintain/modify the program

33
New cards

what is the difference between syntax error and logic error 

syntax - mistake in the code structure prevents the code from running 

logic error - code runs but inccorect results 

34
New cards

what is IPO

input, process, output

35
New cards

how to construct a program flowchart,

start/end - oval

input - parralellogram

process- rectangle

output- paralellogram

36
New cards

can numeric types hold negative numbers,

yes both int and float can be negative

37
New cards

how must True and False be written in bool, with or without quotes? 

capitalized without quotes 

38
New cards

how can you identify the data type of a value,

use the type() function

39
New cards

what is a function

a reusable block of code that performs a task

40
New cards

what is an argument 

values passed on to a function for processing 

41
New cards

what is a variable, and how is it related to ram

variable is a named location in memory that stores a value

42
New cards

How do you write an assignment statement? What is the assignment operator?

Use =; e.g., x = 5.

43
New cards

What happens with variable reassignment?

The variable’s old value is replaced with the new value in memory.

44
New cards

Can a variable be reassigned to a different value or data type?

yes, it can hold a new value and can change data types.

45
New cards

Can a variable be reassigned to another variable?

Yes, e.g., y = x.

46
New cards

What are the rules for naming variables? What convention do we use?

  • Cannot start with a number, contain spaces, or reserved keywords

  • Can use letters, numbers, and underscores

    • Convention: snake_case, e.g., student_name

47
New cards

What is a string literal?

Text written in quotes, e.g., "Hello".

48
New cards

What is a numeric literal? Can special symbols be included?

A numeric value written directly in code, e.g., 100. Special symbols like $, %, , cannot be included in numeric literals.

49
New cards

What happens if commas are added to a numeric literal?

it causes a SyntaxError; Python does not accept commas in numbers.

50
New cards

Can a number be a string literal? Implication in calculations?

Yes, e.g., "5" is a string. Must convert to int() or float() to use in calculations.


51
New cards

How do you display multiple arguments in print()?

Separate them with commas, e.g., print("Age:", age).

52
New cards

What character is automatically inserted between arguments?

A space.

53
New cards

How do you add a comment? Purpose?``

Use # for single-line comments. Purpose: explain code to humans; ignored by Python.

54
New cards

How should comments be aligned?

Aligned with the code they describe (may be indented to match code block).

55
New cards

Difference between Shell Window and Editor Window? Purpose of both?

  • Shell Window: Interactive; shows immediate results.

    • Editor Window: Write and save full programs.

56
New cards

To see a variable’s value in the Shell, do you need print()?

Not always; typing the variable shows its value. print() is needed in scripts.

57
New cards

Keyboard shortcuts in IDLE (Windows)?Run program: F5

  • Save: Ctrl + S

  • Copy/Paste: Ctrl + C / Ctrl + V

  • Undo: Ctrl + Z

58
New cards

What is an escape character?

A backslash (\) followed by a character that has a special meaning in a string.

59
New cards

What is the escape character for a new line? Where is it typed?

\n – typed inside a string, e.g., "Hello\nWorld".

60
New cards

What is the escape character for a tab? Where is it typed?

\t – typed inside a string, e.g., "Name:\tJohn".

61
New cards

What is a positional argument? Does order matter?

An argument assigned by position; yes, order matters.

62
New cards

What is a keyword argument? Does order matter?

An argument specified with its parameter name; order does not matter.

63
New cards

What is the purpose of the sep keyword argument in print()? What is the default value?

sets the separator between arguments. Default is a space " ".

64
New cards

What is the purpose of the end keyword argument in print()? What is the default value?

Sets what is printed at the end. Default is a newline "\n".`

65
New cards

How do you use both sep and end in one print()?

print("A", "B", sep="-", end="!")A-B!.

66
New cards

What is string repetition? What symbol is used?

Repeating a string using *. Example: "Hi" * 3HiHiHi.

`

67
New cards

What is string concatenation? What symbol is used?

Joining strings with +.

68
New cards

How do you store a concatenated string in a variable?

full = "Hello" + " " + "World".

69
New cards

How do you embed concatenation in print()?

print("Hello" + " " + "World").

70
New cards

How do you break long statements into multiple lines?

Use the backslash \ at the end of a line.

71
New cards

How do you spread a function call with many arguments across lines?

Place each argument on a new line within parentheses, e.g.:

print("one", "two", "three", 
      "four", "five")	

72
New cards

How do you construct an f-string?

Prefix with f and use {} for variables, e.g., f"Hello {name}".

73
New cards

How do you format strings, integers, floats, and percents with f-strings?

  • String: f"{name}"

  • Integer: f"{age:d}"

  • Float: f"{price:.2f}"

    • Percent: f"{rate:.0%}"

74
New cards

How do you write multiple placeholders in an f-string?

f"{name} is {age} years old".

75
New cards

What is a format specifier?

Extra instructions inside {} that control alignment, width, commas, precision, and type.

76
New cards

How do you align columns with f-strings?

Use width and alignment, e.g., f"{name:<10}{score:>5}".

77
New cards

How do you nest an f-string in print()?

print(f"{item}: {price:.2f}").

78
New cards

How do you save an f-string to a variable?

message = f"Hello {name}".

79
New cards

How do you use f-strings for tabular data?

Format rows with consistent width/alignment, e.g.:

print(f"{'Item':<10}{'Price':>8}")
print(f"{'Apple':<10}{1.25:>8.2f}")	

80
New cards

What is a control structure?

A block of code that determines the flow of program execution.

81
New cards

Difference between sequence, decision, and repetition structures?

  • Sequence: Executes statements in order.

  • Decision: Executes statements based on a condition (IF).

    • Repetition: Repeats statements while a condition is true (loops).

82
New cards

How do you construct a decision structure in a flowchart? Which symbol is used?

Use a diamond shape for decisions; flow branches based on Yes/No outcomes.

83
New cards

How do you write a basic IF statement?

if condition:

# block of code

84
New cards

What is an IF clause? What special character ends it?

The line with if and the Boolean expression; ends with a colon :.

85
New cards

What is a block?

The indented lines of code that execute if the condition is True.

86
New cards

How can we recognize the end of an IF structure?

The block ends when indentation returns to the previous level.

87
New cards

What is a Boolean expression? Synonyms?

An expression that evaluates to True or False; also called conditional test or logical test.

88
New cards

Which part of an IF clause is the Boolean expression?

The condition following if.

89
New cards

What are comparison (relational) operators?

== (equal), != (not equal), <, >, <=, >=.

90
New cards

How do you construct an IF-ELSE statement?

if condition:
    # block1
else:
    # block2	

91
New cards

Why does a NameError occur in an IF-ELSE?

Because a variable name is misspelled or undefined.

92
New cards

How do you construct an IF-ELSE-IF structure?

Multiple IF-ELSE statements chained; less preferred.

93
New cards

Why does a NameError occur in an IF-ELSE?

Because a variable name is misspelled or undefined.

94
New cards

How do you construct an IF-ELSE-IF structure?

Multiple IF-ELSE statements chained; less preferred.

95
New cards

How do you construct an IF-ELIF-ELSE structure? Why is it preferred?

if condition1:

# block1

elif condition2:

# block2

else:

# block3

96
New cards

How do you test a range of values in an IF statement?

Use comparison operators; e.g., if 50 <= score <= 100:

97
New cards

Rule of thumb for number of IFs?

Usually one IF per category/value range.

98
New cards

How to code a series left to right vs right to left?

Left to right: if 50 <= score <= 100:; Right to left: if score >= 50 and score <= 100:

99
New cards

Why avoid using and in a series unnecessarily?

Can create logic errors and redundancy.

100
New cards

Why avoid independent IFs in a series?

They may all execute even if one condition is met; use IF-ELIF-ELSE instead.