Previous Module
Next Module

COMPUTER SYSTEMS: Encoding and compression

COMPUTER SYSTEMS: Network topologies

COMPUTER SYSTEMS: Wired and wireless networks, protocols, and layers

COMPUTER SYSTEMS: Threats to computer systems and networks

COMPUTER SYSTEMS: Operating systems and utility software

ALGORITHMS AND PROGRAMMING: Types of data

ALGORITHMS AND PROGRAMMING: Producing robust programs

ALGORITHMS AND PROGRAMMING: Designing, creating, and refining algorithms

  • Variables and data types:

name = “Kai”         # String

age = 16             # Integer

height = 1.68        # Float

is_student = True    # Boolean

  • Input and output:

name = input(“Enter name:”)

print(“Hello”, name)

  • Control flow:

# If statements

if age > = 18

print(“Adult”)

else:

print(“Child”)

 
 

# For loops

for i in range(5):

print(i)

 
 

# While loops

count = 0

while count < 5:

print(count)

count += 1

  • Lists (arrays):

fruits = [“apple”, “banana”, “cherry”]

print(fruits[1]) # Output: banana

  • Functions:

def greet(name):

print(“Hello” name)

greet(“Kai”)

  • Operators:

# Arithmetic

+ # Addition

# Subtraction

* # Multiplication

/ # Division

// # Integer division

% # Modulus

** # Exponentiation

 
 

# Comparison

== # Equal to

! = # Not equal to

> # Greater than

< # Less than

> = # Greater than or equal to

< = # Less than or equal to

 
 

Boolean

and # both True

or # at least one True

not # reverses value

Unlock Basic structure of Python

Subscribe to SnapRevise+ to get immediate access to the rest of this resource.

Premium accounts get immediate access to this resource.

Previous Module
Next Module