0% found this document useful (0 votes)
3 views21 pages

1.0 Introduction To Python

This document serves as an introduction to Python for a Senior 1 Science class, covering its history, setup, and key features. It highlights Python's popularity due to its simplicity and versatility, and provides guidance on installing Python and choosing an IDE. The document also includes basic programming concepts such as the print() command and encourages practice through assignments.

Uploaded by

Theodore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views21 pages

1.0 Introduction To Python

This document serves as an introduction to Python for a Senior 1 Science class, covering its history, setup, and key features. It highlights Python's popularity due to its simplicity and versatility, and provides guidance on installing Python and choosing an IDE. The document also includes basic programming concepts such as the print() command and encourages practice through assignments.

Uploaded by

Theodore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

INTRODUCTION TO

PYTHON
Senior 1 Science Class, 2nd semester
LESSON 1
INTRODUCTION TO PYTHON

•Why Python?

•A Brief History of Python

•Setting Up Your Python Environment

•Python 2 vs. Python 3

•First Python Program

•print() command
WHAT IS PYTHON?

Python is a widely-used, interpreted, object-oriented, and


high-level programming language with dynamic
semantics, used for general-purpose programming. It’s
everywhere, and people use numerous Python-powered
devices on a daily basis, whether they realize it or not.
WHY PYTHON?

Python has gained tremendous popularity in recent years. It is


known for its simplicity, readability, and vast ecosystem of
libraries and frameworks. Python's design philosophy
emphasizes code readability and maintainability, making it an
excellent choice for beginners and experienced developers
alike. Its extensive range of applications includes web
development, data analysis, machine learning, scientific
computing, automation, and more.
TIOBE INDEX FOR JUNE 2023

Data as of 14 June 2023


A BRIEF HISTORY OF
PYTHON

Python was created by Guido van Rossum in the late 1980s


and was first released in 1991. Guido aimed to develop a
language that would prioritize productivity and ease of
use. Python's name was inspired by the British comedy
group Monty Python, indicating its focus on fun and
friendliness.​
SETTING UP YOUR PYTHON
ENVIRONMENT

Before diving into Python programming, you need to set up your


development environment. This involves installing Python itself
and any necessary tools or libraries. This chapter will guide you
through the process of installing Python on different operating
systems (Windows, macOS, and Linux) and provide instructions
for verifying the installation. It will also introduce you to
popular integrated development environments (IDEs) and text
editors for Python development, helping you choose the one
that suits your needs.
INSTALL PYTHON AND IDE

Install PYTHON to your computer locally


- Download Python -> https://www.python.org/downloads/
- Install IDE (Integrated Development Environment) -> https://thonny.org/

Using Online PYTHON Compiler


- https://www.programiz.com/python-programming/online-compiler/
PYTHON 2 VS. PYTHON 3

Python has two major versions: Python 2 and Python 3. Python


2 was widely used until Python 3 was released in 2008. Python
3 introduced several improvements and new features while
addressing some of the limitations of Python 2. However, due to
backward compatibility issues, Python 2 code is still present in
legacy systems. In this chapter, we will discuss the key
differences between Python 2 and Python 3 and the reasons
why you should focus on Python 3 for new projects. We will also
cover strategies for migrating from Python 2 to Python 3.
FIRST PYTHON
PROGRAM
Print(“Hello World”)
FIRST PYTHON PROGRAM
Code
Line 1 Comment
Line 2 Comment
Line 3 Code
Outcome

Line which start with # (Hash) sign is a comment


- Comment are use for annotate, explain and label line(s) of code to help programmer understand the code easier
- Long, Old or multi programmer’s code are hard to understand without comment.
- Compiler will NOT compile comment; thus, comment will NOT affect the outcome of the code.

print() command
- print() command is used to display the wordings in the (“”)quotes.
PRINT() COMMAND
Code
Line 1 Comment
Line 2 Comment
Line 3 Code
Outcome

Symbol is IMPORTANT in programming!


- Single quote (‘) or double quote (“) can be use in print() command
- print(“Hello world”)
- print(‘Hello world’)

- If quote are to be displayed (Single quote or double quote), the alternate quote can be used to contain the words.
- print(‘Hello “world”’)
- print(“Hello ‘world’”)
PRINT() COMMAND
Code Outcome
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7

Line 1: will show Sabah with a space at the end. The parameter end=“ “ will put a space at the end of the line.
Line 2: will combine two wordings together. A space will put in between the words
Line 3: similar to line 2, two worlds will combine, but no space will put in between the words
Line 4: a blank print command will display a blank line in the outcome
Line 5: The parameter sep=‘-’ will put a – symbol in between words
Line 6: the parameter end=“@” will put @ symbol at the end of the line
Line 7: the parameter sep=“.” will put . Symbol in between the wordings.
Note:
end parameter will make the next line displayed at the same line. E.g (line 1 and line 2 are displayed at the same
line)
PRACTICE TIME
PRACTICE

What will be the outcome of this code? What will happen if we change the end=“” to
1. end=“~”

What will be the outcome of this code? What will happen if we change the
2.
sep=“.” to sep=“/”. Can we change to sep=‘/’ ?
What will be the outcome of this code? What will happen if we change the
3.
‘”WARNING!!!”’to ”’WARNING!!!’”
ASSIGNMENT
ASSIGNMENT
Outcome

Instruction
Try produce above outcome from what you have learn.
Your code must have
1. end=
2. sep=
Take a screenshot of your full screen (Please don’t crop) and submit into google classroom

You might also like