0% found this document useful (0 votes)
12 views

Introduction To Programming and Python Basics

Uploaded by

do.ebrarr
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Introduction To Programming and Python Basics

Uploaded by

do.ebrarr
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Course Introduction

Course Name: Computer Programming (CENG103)


Instructor: Prof.Dr. Servet Soygüder
Assistant: Resch.Assist. Bülent Herdem

Course Objectives:
 Understand core computational concepts using Python.
 Develop problem-solving skills through programming.
 Learn to write small programs to solve real-world problems.
 Build a strong foundation for further studies in computer science.

Course Language: English

Assessment: Homework(weekly), Quizzes(3), Midterm, Final Exam


19 SEPTEMBER 2024
PREPARED BY BÜLENT
HERDEM
What is Programming ?
Definition:
The process of creating a set of instructions for a computer to perform tasks.

Key Concepts:
 Problem Solving:
Breaking down problems into smaller, manageable parts.

 Algorithms:
Step-by-step instructions for solving a problem.

 Programming Languages:
Instructions written in a language the computer understands.

 Code:
A set of instructions written in a programming language.

Applications: Web development, data science, AI, robotics …


Introduction to Python
What is Python?: A high-level, versatile programming language.

Advantages of Python:
 Easy to learn and use, ideal for beginners.
 Versatile: used in web development, data science, automation.
 Large community and numerous libraries.

Where Python is Used:


 Data analysis (NumPy, Pandas).
 Artificial intelligence and machine learning.
 Automation and scripting.
 Web development (Django, Flask).

History of Python: Created by Guido van Rossum, released in 1991.


Input, Process, Output (IPO) Model
Apples Squeezing Apple juice

INPUT PROCESS OUTPUT

Keyboard Mainboard LCD Monitor

2,5 2+5 7

Salty Sea water Heating Fresh Water, salt


IPO Model Examples

1. Online Shopping System


 Input: User selects items, enters shipping information, and payment details.
 Process: The system verifies the payment, checks inventory, and prepares the order.
 Output: An order confirmation and receipt are sent to the user, and the package is dispatched.
2. Email Sending System
 Input: A user writes an email, attaches files, and enters the recipient's address.
 Process: The system processes the email, validates the recipient's address, and sends the
message through the network.
 Output: The email is delivered to the recipient’s inbox, and the sender gets a confirmation.
3. Washing Machine
 Input: User selects the washing cycle and adds clothes and detergent.
 Process: The machine fills with water, agitates the clothes, rinses, and spins to remove excess
water.
 Output: Clean, spun clothes are ready to be taken out of the machine.
4. Search Engine (e.g., Google)
 Input: A user types a query into the search bar.
 Process: The search engine algorithm processes the query, searches its database, and ranks the
results.
 Output: A list of relevant search results is displayed to the user.
IPO in Python Programming Language(PL)

An example:

 Input: Taking user input in Python,

 Process: adding the numbers

 Output: Display The result after adding process.


Basic Python Operations / Functions

 input(): Takes user input in Python,

 print(): Displays output to the screen

 float(): Converts string data type to number data type


Python Basics
https://www.online-python.com/

Syntax: (Writing Rules) Simple and easy-to-read code structure. Python's syntax is close to human
language.

Variables: Containers for storing data. name = "Alice" age = 25

Data Types: Numbers(1,2..), Strings(‘Hello World’), Booleans(True/False), etc.

Mathematical Operators: Addition (+), subtraction (-), multiplication (*), division (/).
a = 10
b=5
c=a+b
print(c) # or you can use print(a+b)

!!! Variable Naming Rules: Must start with a letter or underscore. Cannot contain spaces.
Correct Variable Definition: ‘Size’, ‘_fileType’, ‘’
Incorrect Variable Definition: ‘file type’, ‘1_length’
Python Basics
https://www.online-python.com/

print("I am", 30, "years old and my height is",


1.75)

name = "Alice" # String


age = 30 # Integer
height = 1.75 # Float
is_student = False # Boolean
print("Name:", name, "Age:", age, "Height:", height, "Is student:", is_student)
print(f"Name: {name}, Age: {age}, Height: {height}, Is student:
{is_student}")
Writing Your First Python Program
https://www.online-python.com/

Temperature Converter Example


# Get temperature in Celsius from the user
celsius = float(input("Enter temperature in Celsius: "))

# Convert to Fahrenheit
fahrenheit = (celsius * 9/5) + 32

# Print the result


print(f"The temperature in Fahrenheit is {fahrenheit}")

Be careful, Python is case sensitive, uppercase and lowercase are different


Class Activities
https://www.online-python.com/

Activite-1: Calculate the user age


1. Get birth year from user
2. Calculate the age and set a variable. ( use 2024 for current year statically )
3. Display the result

Activite-2: Use arithmetic operations to calculate the area and perimeter of a rectangle

Activite-3: Calculate the average of three numbers

Activite-4: Create a tip calculator for a restaurant bill. Use tip amount ratio 15%.

Activite-5: Create a simple currency converter. From USD to EUR. (use 0.85 EUR = 1 USD )

Activite-6: Convert the total minutes into hours and the remaining minutes.
Homework time 
HW-1: Write a Simple Calculator Programs. Required ability the calculator:

1. Take five numbers from user as input,


2. You are free to choose the formula; your formula must include all operations of
addition, subtraction, multiplication, and division at least once. Calculate the result as
process
3. Display the result as output

 Write your codes in a text file or word document


 Upload your homework to Aybuzem until September 23rd
 Everyone will run their codes on https://www.online-python.com/
 In the next lesson, we will review your study and correct any errors.
Problem-Solving in Python
Debugging Basics

Debugging:
Identifying and fixing errors.

Types of errors:
Syntax errors ( does not work your code, when push RUN button. )
runtime errors (works your code, when push RUN button, but the error occurs later.
Example 1/0 )
logic errors ( for example; if you write -> if (x >= 0) print(‘number is negative’) )

Walk through common mistakes and debugging techniques in Python.


Summary and Next Week's Topics

Recap of Week 1:
 Programming basics
 Python syntax
 variables
 input/output
 simple operations

Next Week:
 Control Structures
 Loops.
Thank You!
Any Question?
bulent.herdem@gmail.com

You might also like