Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4,6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 20 pages
Class notes

Introduction to programming block 2 notes

Document preview thumbnail
Preview 3 out of 20 pages

Software engineering- Year 1 introduction to programming block 2 notes.

Content preview

1. BASIC PROGRAMMING CONCEPTS

1.1 Identify and Select Appropriate Predefined Data Types

What are Predefined Data Types?Built-in types that programming languages provide automatically.

Common Data Types:

Data Type Description Examples When to Use

Integer (int) Whole numbers, no decimals -5, 0, 42, 1000 Counting, ages, quantities


Float (float) Numbers with decimals 3.14, -0.5, 2.0 Measurements, prices, averages


String (str) Text data "Hello", "Johannesburg" Names, messages, text


Boolean (bool) True/False values True, False Conditions, flags, logic

Rules for Selecting Data Types:

• Choose the smallest type that fits your data (use int not float for ages)

• Consider memory efficiency

• Think about operations you'll perform (can't divide a string)

• Consider precision needed (floats have rounding errors)

,1.2 Use Simple Input/Output and Appropriate Operators

Input Functions:

• input() - gets text from user (returns string)

• Convert types: int(), float(), bool()

Output Functions:

• print() - displays to console

• Format: f"text {variable}"

Operator Types:

Category Operators Example Result

Arithmetic +, -, , /, //, , % 3.333...


Assignment =, +=, -=, =, /= x += 5 x=x+5


Comparison ==, !=, >, <, >=, <= 5>3 True


Logical and, or, not True and False False


String + (concatenate), * (repeat) "Hi" + "!" "Hi!"

Key Points:

, • / = division (float result)

• // = integer division (no decimal)

• % = remainder (modulo)

• ** = exponent (power)



1.3 Identify and Use Selection Structures and Loop Structures

SELECTION STRUCTURES (Decision Making):

Structure When to Use Example

if Simple condition Check if score ≥ 50


if-else Two options Pass/Fail decision


if-elif-else Multiple options Grade A/B/C/D/F


nested if Complex conditions Check age AND enrollment

LOOP STRUCTURES (Iteration):

Document information

Uploaded on
June 10, 2026
Number of pages
20
Written in
2025/2026
Type
Class notes
Professor(s)
Eduvos
Contains
All classes
R90,00

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
4
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions