Intro Python crash course, Summaries of Introduction to Computers

All the needed notes for this class.

Typology: Summaries

2025/2026

Uploaded on 06/20/2026

jake-modex
jake-modex ๐Ÿ‡จ๐Ÿ‡ฆ

2 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
INTRODUCTION TO PYTHON โ€“
COMPLETE STUDY NOTES
1. What is Python?
Python is a high-level programming language that is:
โ— Easy to read
โ— Easy to learn
โ— Interpreted (runs line by line)
โ— Used for web development, data science, artificial intelligence, automation, and software
development
Example:
print("Hello World")
Output:
Hello World
2. Variables
Variables store information.
Example:
name = "Kyle"
age = 19
height = 5.8
Rules:
โ— Cannot start with a number
โ— Cannot contain spaces
โ— Case sensitive
Valid:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Intro Python crash course and more Summaries Introduction to Computers in PDF only on Docsity!

INTRODUCTION TO PYTHON โ€“

COMPLETE STUDY NOTES

1. What is Python?

Python is a high-level programming language that is:

โ— Easy to read โ— Easy to learn โ— Interpreted (runs line by line) โ— Used for web development, data science, artificial intelligence, automation, and software development

Example:

print("Hello World")

Output:

Hello World

2. Variables

Variables store information.

Example:

name = "Kyle" age = 19 height = 5.

Rules:

โ— Cannot start with a number โ— Cannot contain spaces โ— Case sensitive

Valid:

student_name age x

Invalid:

2age student name

3. Data Types

Integer (int)

Whole numbers

x = 5 y = -

Float (float)

Decimal numbers

price = 19. pi = 3.

String (str)

Text

name = "Kyle" course = "CSC108"

Boolean (bool)

Example:

name = input("Enter your name: ")

print(name)

Converting Input

Input always returns a string.

Example:

age = int(input("Age: "))

price = float(input("Price: "))

5. Arithmetic Operators

Addition

โ—

Example:

5 + 3

Output:

8

Subtraction

โ—

Example:

5 - 3

Output:

Multiplication

โ—

Example:

5 * 3

Output:

15

Division

/

Example:

10 / 2

Output:

Floor Division

//

Example:

10 // 3

Output:

3

Modulus (Remainder)

7. Comparison Operators

== Equal

!= Not Equal

Greater Than

< Less Than

= Greater Than or Equal

<= Less Than or Equal

Example:

5 > 3

Output:

True

8. Logical Operators

and

Both conditions must be true.

Example:

x > 0 and x < 10

or

At least one condition must be true.

Example:

x < 0 or x > 100

not

Reverses a boolean value.

Example:

not True

Output:

False

9. If Statements

Used for decision making.

Example:

age = 18

if age >= 18: print("Adult")

10. If-Else Statements

Example:

age = 16

if age >= 18: print("Adult") else: print("Minor")

x = 1

while x <= 5: print(x) x += 1

Output:

1 2 3 4 5

14. For Loops

Repeat a specific number of times.

Example:

for i in range(5): print(i)

Output:

0 1 2 3 4

Common Range Forms

range(5)

0 to 4

range(1,6)

1 to 5

range(0,10,2)

0 2 4 6 8

15. Strings

Example:

name = "Python"

Length

len(name)

Output:

6

Indexing

name[0]

Output:

P

name[1]

Output:

y

Negative Indexing

name[-1]

Output:

Removing Elements

numbers.remove(3)

Length

len(numbers)

17. Functions

Functions allow code reuse.

Example:

def greet(): print("Hello")

greet()

Function with Parameters

def greet(name): print("Hello", name)

greet("Kyle")

Output:

Hello Kyle

Return Statement

def square(x): return x * x

result = square(5)

Output:

18. Local vs Global Variables

Global:

x = 10

def test(): print(x)

Local:

def test(): y = 5

y only exists inside the function.

19. Lists and Loops

Example:

numbers = [1,2,3,4]

for num in numbers: print(num)

Output:

1 2 3 4

student["name"]

Output:

Kyle

22. Tuples

Like lists but cannot be modified.

Example:

coordinates = (10,20)

23. Basic File Handling

Writing to a file

file = open("data.txt","w")

file.write("Hello")

file.close()

Reading a file

file = open("data.txt","r")

content = file.read()

file.close()

24. Common Errors

Syntax Error

Missing colon, bracket, etc.

Name Error

Using a variable that doesn't exist.

Type Error

Using incompatible data types.

Example:

"5" + 5

Index Error

Accessing an index that doesn't exist.

25. Big-O Basics

Measures efficiency.

O(1)

Constant time

Example:

list[0]

O(n)

Linear time

for i in range(5): code

While Loop:

while condition: code

Function:

def function_name(): code

List:

numbers = [1,2,3]

Dictionary:

data = {"key":"value"}

Length:

len(object)

Add to List:

append()

Return Value:

return value

Most Important Topics for Intro Python Exams

  1. Variables and Data Types
  2. Input and Output
  3. Arithmetic Operators
  4. If Statements
  5. For Loops
  6. While Loops
  7. Functions
  8. Lists
  9. Strings
  10. Dictionaries
  11. File Handling
  12. Tracing Code
  13. Debugging Errors