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

G11 CS WK8 Introduction to Python

This document is an introduction to Python programming, covering its usability, installation, and basic coding concepts. It outlines key topics such as variables, data types, expressions, and includes practical exercises for students. The document aims to equip students with foundational knowledge to start coding in Python.

Uploaded by

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

G11 CS WK8 Introduction to Python

This document is an introduction to Python programming, covering its usability, installation, and basic coding concepts. It outlines key topics such as variables, data types, expressions, and includes practical exercises for students. The document aims to equip students with foundational knowledge to start coding in Python.

Uploaded by

nermeen
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

INTRODUCTION TO PYTHON

WEEK 8
AGENDA:
1. What is Python (Introduction).
2. Python main usability.
3. How to download and install python?
4. Python Compartments.
5. Print, Print String, Variables, Expression and Variables examples.
6. Values, Integers, Floats, Strings and Booleans.
7. Exercise.
OBJECTIVES

• Coding will be introduced where students will be able to


identify the differences between Front-end and Back-end
fields.
• Students will be introduced to first coding line in Python.
• The different variables values and definition will be
discussed.
WHAT IS PYTHON?
 Python is frequently used by software engineers as a support language for build control and
administration, testing, and a variety of other tasks.
 It's commonly used to create websites and applications, as well as automate operations and
perform data analysis. Python is a general-purpose programming language, which means it can
be used to develop a wide range of applications and isn't designed for any specific problem.

IT COULD BE
USED BY
PC & MAC
SYSTEMS
PYTHON MAIN USABILITY:

 Python programmers can earn tons of money yearly depend where they are
going to use the program, first, you need to define which field are you going
to use Python in, here are some examples below;

1. Automation: Such as sending out, replying to, and sorting emails. Filling out PDFs and Excel
files. Sending HTTP requests. Converting image files.
2. Artificial Intelligence (AI): refers to a computer's or a robot's ability to perform jobs normally
performed by humans.
3. Application: Open-source high-level language, general-purpose programming language that
combines object-oriented, structural, and functional programming capabilities.
4. Web: It uses a shared backend logic, which means the code runs on the server (could be
your computer) rather than in the browser.

TAKE NOTES IN YOUR BINDER PLEASE


LETS START KNOWING MORE ABOUT
HOW TO DOWNLOAD AND INSTALL PYTHON?
 First, make sure your machine is connected to the internet and follow the steps below;

1. Visit https://www.python.org/ and click on downloads tab.


2. The website should identify your operating system type (Mac/Windows) and generate the correct
file for you.
3. Start downloading the file and open it. (Make sure of ticking
only for windows users.
4. Next step, you need to download the program that will work along with Python and will make our
life easier.
5. Visit https://codewith.mu/en/download and download MU Editor by clicking download (Free
version).
STARTING YOUR FIRST PROJECT:

 Open you MU Editor, select (Create new project)

 Identify the location you wish to save your project in and change the last name to Seniors_2024.

TIME TO
START
CODING
PYTHON COMPARTMENTS

Python usually is using interpreter system, that means the file getting executed
automatically once you start writing your first line in the project, unlike compiler
where you must hit run and redo your work anytime you want to apply any changes.
PRINT:
 First line: Add print (‘ ‘ ) to apply values on screen. Note you can use a single quote or
double quoting, but for this method single quote in preferable.
 In between the quotes start writing your name. print (‘Your Name’)

 Anytime you wish to see the results, go to Run tab  Run. Now you can choose Python
program.
 You should see a small window below has your print on screen.

 Now let’s draw a smiley face by typing, print (‘O O’). Double space between the eyes.
 Then in the second line type, print (‘ I’). Make sure it’s aligned between the eyes.
 Third line type, print (‘ U’). Make sure they are all aligned in the middle of the first
line (eyes).
 Use spaces to align the values correctly.

 Hit Run.
APPLYING PRINT STRING:

 A string is a programming term which means a series of characters that follow each other
within the same value.
 A quick trick, add a value then add space + asterisk (*) and a number after the quotation, it
will multiply the value as many as the number is stating. For example;
 Print  space Open bracket  one quotation  Asterisk  one quotation  space multiply (*)
 space  Number (10)
 print (‘*’ * 10)

 So in the above variable we have multiplied the value 10 times to appear in the screen as a
series of the same value

 This type of coding called an Expression. TAKE NOTES IN YOUR BINDER PLEASE
EXPRESSION:
 Expression is a piece of code that produces a value. So, when
Python interprets, it executes the line by evaluating the code that is
added between the parenthesis/brackets.

AFTER EVALUATION =
TAKE NOTES IN YOUR
BINDER PLEASE
VARIABLES:
 Variable means being able to change inputs on the go.

 Variables are used to temporarily store data in computers memory. For Example;

price = 10
rating = 4.5
course_name = CS Python Project
is_published = True

In the above example variables must be always be in lower case,

• price like 10 is an integer (a whole number without a decimal point)


• rating like 4.5 is a float (a number with a decimal point)
• subject_name is a string (a sequence of characters)
• is_published as question is a Boolean (coding). Boolean values can be True or False.
COMMENTS:

 We use comments to add notes to our code. Good comments explain the hows and whys,
not what the code does. That should be reflected in the code itself. We use comments to
add reminders to yourself or other developers, or also explain your assumptions and the
reasons you’ve written code in a certain way.

# This is a comment and it won’t get executed.


# Our comments can be multiple lines.
VARIABLES EXAMPLE:
 Variables are one of the most fundamental concepts in programming, they are not specified for
Python, but they are used in programming language out there.
 Let’s start using them;

 Type price = 10 (Python will start memorizing the number and will attach it this price label in its
memory location).
 Now use print to enter value. (Make sure you don’t add quotations at this point as we are
entering variables not values…
 Enter print = (price)  Run

 Now you only see number 10 in the screen below.

Variables

+ Values
=

Output
VARIABLES EXAMPLE:

 Now as you see number 10 is stored in the memory and converted to binary (Low-Level
Language)
 Let’s take the program to the next level!

 Let’s add in the second line price = 20 this time and we will keep the price = 10 in the first
line and print(price) at the last line. WHAT HAPPENED !!!

 As we know Python is an interpreter program so any input in any line will be automatically
updated on the screen/terminal.
 So, adding another variable after another is called Re-Set, therefore, the new line will
TAKE NOTES IN YOUR BINDER PLEASE
reset the first line, and the number now will appear as the new input.
VARIABLES EXAMPLE:
 So, the output put will appear as 20 now.

New output
CS
STUDENTS
WILL BE
WHAAAT?!
LIKE
VARIABLES INTEGER VS FLOATS:
 Integer are the number that are written in python without a decimal added into them.

 Numbers with a decimal point can be used in other variables such as rate.

 Giving an example of decimal numbers, lets replace line 2 with; rating = 4.8…

 Those numbers we refer to them as a floating-point numbers or floats for short.

INTEGER NUMBER FLOAT NUMBER

50 7.0 TAKE NOTES IN YOUR


BINDER PLEASE
ALL VARIABLES EXAMPLES:
 Now let’s start writing the previous variable mentioned in page 12.

 Let’s write the following below;

1. price = 10 Integers

2. rating = 4.5 Floats


3. name = “Tom” Strings
4. is_published = True or Fales Booleans
5. print (price) Values
ALL VARIABLES EXAMPLES:

VARIABLES ALWAYS COMES

AS A lowercase LETTERS

Special keywords have


FIRST LETTER UPPERCASE
FINAL OUTPUT:
EXERCISE:
You are checking in a student
named Amr Ahmed, he is 17
years old and he is a new
student in Kayan College
school
…………… Give it a go
SOLUTION:
 So here we need to input three variables;

1. Student Name  name= ‘Amr Ahmed’ It could be fullname = ‘Amr Ahmed’


2. Student age  age = 20

3. Checking if he is new  is_new = True

WE ARE FINALLY
DONE!

You might also like