1/10
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Function
block of reusable code that performs a specific task.
Syntax: Defined using the def
keyword.
example: def function_name(parameters):
Reusable Code
Allows the same code to be performed multiple times without duplication
Parameters
Inputs that the function can accept.
Syntax: def function_name(parameters):
example: def add_numbers(a, b):
Return Value
The result that it gives back when you use it
Syntax: return
example: return a + b
Input function
lets users enter information.
Syntax: input("Prompt message")
Print function
A Python function that shows information on the screen.
Syntax: print("Message or variable")
Type Checking
Checking what kind of data a variable holds.
syntax: type(variable)
Random Module
A Python module for generating random numbe
Import Syntax: import random
Random Number Generation
Description: Provides functions for generating random integers.
Example: random.randint(start, end)
Commenting
Notes in the code that are not performed
syntax: #
Sum
adds up numbers and gives total
syntax: sum(variable)