click below
click below
Normal Size Small Size show me how
CSCT
Python & Electronics
Question | Answer |
---|---|
Variable name rules: 1 | Names must be easily understood |
Variable name rules: 2 | Must be written in camelCase (first word lowercase, every word after has first letter capitalised) |
Variable name rules: 3 | Must begin with a lowercase letter |
Variable name rules: 4 | Must be a reasonable length |
Variable name rules: 5 | Must not contain python keywords or operators |
What are comments? (3) | - Can be used to explain bits of code - Must have a '#' in front to exclude it from code (it will error) |
What are constants? (3) | - A variable that holds a value and cannot be changed - You cannot declare a value or variable as constant in Python - Constants are named in all CAPS with underscores between words |
What are the spacing and lining rules? (3) | - Spaces should be used on either side of all operators (print) - Lines of code should be kept shorter - Avoid putting blank lines in between lines of code |
What are input? (2) | - Inputs are data inputted by the user - Inputs are saved as strings unless specified |
What are outputs? (1) | - Something printed by the computer to the user |
What is an Integer in python? | Any type of whole number |
What is a String? | A line of words encased in quotation marks |
What is a Float? | Any type of decimal numbers |
What is a Boolean? | It prints a message based on whether a condition is True or False |
What does an IF order do? | It orders the computer to read the code in the order |
What does a WHILE LOOP CONDITION do? | sets a loop repeating code until it is no longer true |
What does WHILE TRUE do? | It sets 'infinite' loops and requires a break condition |
What does a BREAK do in while loops? | Immediately terminates a repeating while loops completely |
What does the RANDOM LIBRARY do? (2) | It lets you choose a random number, given the range of numbers to choose from. To use a library, write import and then the library name at the top of your code. |
What does a WINSOUND LIBRARY do? | It accesses your computer's speakers to play sounds through You have to specify the duration and frequency info in code |
What do ELSE statements do? | It executes a code if the above code does not exceed the condition |
What doe ELIF statements do? | Specifies a new condition to test, if the first condition is false |
What does the '==' operator do? | It is a comparison operator and the computer checks if it is True or False {9==10: FALSE] |
What does the '=' operator do? | It assigns a value for a said variable |
What does the '!' mean? | Is not equal to (computer checks) |
What does the '>' mean? | More than (computer checks) |
What does the '<' mean? | Less than (computer checks) |
What does the '>=' mean? | More than or equal to (computer checks) |
What does the '<=' mean? | Less than or equal to (computer checks) |
What does the '+' do | Adds |
What does the '-' do | Subtracts |
What does the * do | Multiplies |
What does the '/' do | Divides |
What does the '//' | Gives a whole number to any division e.g. 5//2 = 2 |
What does the '%' do | Gives the remainder in the division e.g. 11%4 = 3 |
What does 'AND' do | It sets multiple conditions to have to be true |
What does 'OR' do | Sets multiple conditions of which any can be true |
How do positions in strings work? (2) | - Each place in a string has an index number - But counting starts at the number 0 |
How does SLICING STRINGS work? | 1. The first number is the start of the list of characters 2. The second number is the end -this gets the characters in between the two numbers 3. The third number is the frequency of the print |
What is the definition of a voltage in Electronics? | The difference in electrical potential energy between two places in a circuit |
What is the definition of current in Electronics? | A flow of electric charge |
What is the definition of resistance in Electronics? | What stops/slows the current |
How is voltage measured? | In volts (V) |
How is current measured? | In ampere (A) |
How is resistance measured? | In ohms (O) |
What are breadboards used for? | To plug in and test a circuit before soldering a permanent version |
How are the holes in the circuit board connected? | By metal rails under the holes |
How do we connect cables | By plugging them on the same side (not across to the other side) |
What are horizontal rails? | Two rails on each side of the breadboard (blue and red) |
What is the purpose of the red horizontal rails ? | - It has a positive charge - All the holes in the red rails are connected |
What is the purpose of the blue horizontal rails? | - It has a negative charge - All the holes in the blue rails are connected |
How do the cables get connected? | When both sides of the cable are placed in the same rail |
What happens in the black rails? | - it has a negative charge - All the holes in columns with each other and on the same side are connected |
What is the symbol for cables? | _____ (straight lines) |
What is the symbol for a battery? | -|I |I- (two cells) |
What is the symbol for a cell? | -|I- (long line, short line) |
What is the symbol for an LED bulb? | -(x)- (circle with cross) |
What is the symbol for a resistor? | _____ -| |- (rectangle) |
What is the symbol for a flip switch? | -o~o- (line between circles) |
What is the symbol for a push switch? | _--_ -o o- (button on circles) |
What is resistance in electronics? | An opposition a material offers to an electrical current |
What are series circuits? | When the current that flows through each component is connected through series. (if one light bulb on an LED strip goes out, they all go out) |
What are parallel circuits? (2) | - The current in a parallel circuit is shared between the components - If one lamp in a parallel circuit breaks, the other will still light |