- course Info
- what is computation
- python basics
- mathematical operations
- python variables and types

Burkay Genç, Ahmet Selman Bozkır, and Selma Dilek

01/03/2023

- course Info
- what is computation
- python basics
- mathematical operations
- python variables and types

**Subject**: Learn Python*a programming language***Classes**:- All classes are online until further notice
- All off-class communication will be on
*hadi*- hadi website
- You have to follow hadi daily for new announcements

**Grading**- 60%: Midterm (2x)
- Midterms format will be announced during the semester

- 40%: Final Exam (1x)

- 60%: Midterm (2x)

- You are
**strictly forbidden to cooperate**on exams - You are
**strictly forbidden to search for answers on the Internet** - You are
**strictly forbidden to copy/paste materials from the Internet**

- Cooperation
- you may cooperate with your friends to
**understand the course material** - all exam work needs to be individual
- cheaters will be
**harshly**penalized ->**-100**,**F3**,**disciplinary committee**

- cheaters will be

- you may cooperate with your friends to

- Position yourself to succeed!
- do practice early
- do not skip lectures

- New to programming?
*PRACTICE. PRACTICE? PRACTICE!*- can’t passively absorb programming as a skill
- download code before lecture and follow along
- don’t be afraid to try out Python commands!

- represent knowledge with
**data structures** **iteration and recursion**as computational metaphors**abstraction**of procedures and data types**organize and modularize**systems using object classes and methods- [maybe] different classes of
**algorithms**, searching and sorting - [maybe]
**complexity**of algorithms

- You can download your own copy, it is free
- Download Python
*recommended*

- Download Python
- More advanced tasks (data science, machine learning)
- Download Anaconda
- Not recommended at this level

- You can use online compilers/IDEs
- Google Colab
*recommended**will be used in course* - Jupyter Notebook
*recommended* - Python Fiddle
- PyFiddle
- Programiz

- Google Colab
- Use a Linux distribution such as Ubuntu, Manjaro etc.
- Python comes built in

- What is an
**IDE**?- An
**I**ntegrated**D**evelopment**E**nvironment allows you to write programs in a programming language and provides extra tools to help the process- Syntax highlighting
- Code completion
- Bracket completion/matching
- Debugging
- Profiling
- more…

- An
- PyCharm is a very powerful and popular IDE for Python
- IDLE comes built-in with any Python distribution
- Eric, Spyder, Eclipse+PyDev
- Sublime Text,
*VS Code*, Atom, etc. are generic editors that can be extended with Python capabilities

- Fundamentally:
- performs
**calculations**

a billion calculations per second! **remembers**results

100s of gigabytes of storage!

- performs
- What kinds of calculations?
**built-in**to the language- ones that
**you define**as the programmer

- computers only know what you tell them

**declarative knowledge**is*statements of fact*.- someone will win a Trophy before class ends

**imperative knowledge**is a*recipe*or “how-to”.- Students sign up for lottery
- Burkay opens his IDE
- Burkay chooses a random number between 1
^{st}and n^{th}responder - Burkay finds the number in the responders sheet. Winner!

square root of a number $x$ is $y$ such that $y\ast y=x$

recipe for deducing square root of a number $x$

- Start with a
**guess**, $g$ - If $g\ast g$ is
**close enough**to $x$, stop and say $g$ is the answer - Otherwise make a
**new guess**by averaging $g$ and $x/g$ - Using the new guess,
**repeat**process until close enough

- Start with a

$g$ | $g\ast g$ | $x/g$ | $(g+x/g)/2$ |
---|---|---|---|

3 | 9 | 16/3 | 4.17 |

4.17 | 17.36 | 3.837 | 4.0035 |

4.0035 | 16.0277 | 3.997 | 4.000002 |

- sequence of simple
**steps** **flow of control**process that specifies when each step is executed- a means of determining
**when to stop**

1 + 2 + 3 = an **algorithm**!

- how to capture a recipe in a mechanical process
**fixed program**computer- calculator

**stored program**computer- machine stores and executes instructions

- sequence of
**instructions stored**inside computer- built from predefined set of primitive instructions
- arithmetic and logic
- simple tests
- moving data

- built from predefined set of primitive instructions
- special program (interpreter)
**executes each instruction in order**- use tests to change flow of control through sequence
- stop when done

- Turing showed that you can
**compute anything**using 6 primitives - modern programming languages have more convenient set of primitives
- we can also
**create new primitives** - anything computable in one language is computable in any other programming language
- Python == Java == C == Pascal == C++ == C#
- They only differ in
**ease**of doing something

- a programming language provides a set of primitive
**constructs**- 2, 4.8, ‘a’, “burkay”, TRUE, +, -, *, …

**expressions**are complex but legal combinations of primitives in a programming language- 2 + 4.7
- TRUE && FALSE
- 3.0 + 2 / 5.4

- expressions and computations have
**values**and meanings in a programming language

**primitive constructs**- English: words
- programming language: numbers, strings, simple operators