basic programming

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/57

flashcard set

Earn XP

Description and Tags

week 1

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

58 Terms

1
New cards

program

is a set of instruction given to a computer in a programming language to solve a problem

2
New cards

programming

is the process of writing an algorithm for the computer to program / act of writing a program

3
New cards

programming language

language that the computer understand

4
New cards

algorithm

set of instructions written

5
New cards

process of program execution

input —>process data internally —> output

6
New cards

note to remember

A = 65 B=66 C=67

7
New cards

What is Python?

a general purpose and high interpreted language

8
New cards

4. History

python was inverted in 1980s/1990s by Guido Van Rossum

9
New cards

Programs Are Text Files

we store python program as test files in extension .py

10
New cards

Name Origin

it was named after Monty python’s flying circus

11
New cards

IDE

integrated development environment e.g wing101

functions

  • code complier

  • debugging

12
New cards

print ()

built in function

13
New cards

print(“hello world”)

argument

14
New cards

"argument

value you pass in a function

15
New cards

comments

  • not for the computer

  • it always start with #

16
New cards

print(“name”)

When you call a function, the values you pass into it are arguments.

17
New cards

print(name)

When you define a function, the variables listed in the parentheses are parameters.

18
New cards

Logic errors

the program runs but doesn’t not work as expected

19
New cards

Syntax errors

it happens when the program doesn’t follow the programming rules e.i wrong structure and wrong spelling of key words and the program will not start at all

20
New cards

Escape Sequences

scape sequences are special character combinations

21
New cards

\n

newline

22
New cards

\’

prints ‘

23
New cards

\”

prints “

24
New cards

\a

makes a beep sound (bell)

25
New cards

\\

prints back slash \

26
New cards

\b

backspace — deleted the previous character in an output

example print(“Hello\b World”)

output — Hell World

27
New cards

\t

tab , leaves spaces

example print("Name\tAge\tCity")

output — Name Age city

28
New cards

integer

whole number

29
New cards

floating n

fractional number

30
New cards

Integers: Literals

  • fixed value written into a code

  • example numeric literals 1; 2

31
New cards

common operations

  • precedence of operations

  • high ()

  • middle % * /

  • last + -

32
New cards

//

division for integers

that is 3//2 = 1 {floor division}

33
New cards

integer operand

it simply means a whole number

34
New cards

modulus (%)

  • remainder

  • 5%2 = 1

  • 2%4 = 2

35
New cards

Identifiers

names used to identify variables; functions; classes and modules

36
New cards

Rules for Naming Identifiers

  • never start with numbers

  • start with underscore _ or letters

  • it can be followed by numbers

  • hyphens - are not allowed

  • no spaces

37
New cards

🚫 Invalid characters in identifiers:

  • @ (at symbol)

  • # (hash)

  • $ (dollar sign — except in some languages like JavaScript or PHP)

  • !, ?, &, +, -, *, /, etc.

38
New cards

Reserved Words (Keywords)

words that can not be used as identifiers

  • Attempting to use reserved words as identifiers will result in a syntax error.

39
New cards

variables

name section memory used to store data

  • zenora03 = “Botha”

40
New cards

note

Normally, print adds a newline character (\n) after printing, which moves the cursor to the next line.

41
New cards

sep=’*’

you have to put * between each value and not spaces

42
New cards

end= ‘‘

telling python not to add a newline or space after

43
New cards

prompt

text asking user for input

44
New cards

eval()

a function that converts strings into a number

45
New cards

Increment

x=10

x+=2

x=x+2

x=12

46
New cards

decrement

x=10

x-=2

x=x-2

x=8

47
New cards

Implicit Type Conversions (Type Coercion)

Python promotes int to float in operations if needed.

48
New cards

Explicit Type Conversions (Type Casting)

You can manually convert data types using built-in functions:

49
New cards

note

floats do not become int()

50
New cards

math.ceil

round up

51
New cards

math.floor

rounds down

52
New cards

Comment

a part of code starting with # and is for human reading

53
New cards

Function

performs collective purpose

54
New cards

Identifier

used to name variables and functions

55
New cards

Variable

container for date and named using identifier rules

56
New cards

String literal, numeric literal

fixed words or values used directly

57
New cards

arithmetic operators

-

+

*

/

58
New cards

Syntax

The fundamental rules of a programming language Similar to the spelling and grammar rules of natural languages