Programming Essentials Webinar Day 1
Programming Essentials Webinar Day 1
DAY 1
Contents
•INTRODUCTION •PYTHON BASICS
• A brief Introduction • Variables
• Why Python? • Data Types
• About the webinar
• Input and Output
• Python2 vs. Python3 • String Concatenation
• Requirements • (Type)casting
• Installation steps
• Python Basics
• Two Modes
A brief introduction (Python) /1
◦Why Python?
◦ High-level programming language
◦ It's syntax is easy to learn, even a grade schooler can learn it!
◦ It's popular by industry standards
◦ It's fast to do web development in Python.
◦ It's used to create scripts for vulnerability testing.
A brief introduction (Python) /2
◦Why Python?
◦ It's been heavily utilized in the field of data science
◦ The first super massive black hole was visualized using Pythonic libraries.
◦ It's easy to learn program logic with Python
◦ It's almost like 'pseudo-code'!
A brief introduction (webinar)
◦Our resources will be uploaded in a google classroom
◦ Class code: cjofiqm
◦ Invite link: https://classroom.google.com/c/Mzg4NDEyMTUzODY1?cjc=cjofiqm
◦ Please have your actual full name on your google accounts.
◦ Questions about DICT related concerns can be directed with our moderator
from DICT.
◦ Pythonic questions – however – I can entertain. ☺
◦ ogsablazo@gmail.com
Python 2 vs Python 3
◦Python 2.x is now at its EOL (2020).
◦If you wish to start learning python, or implementing
python-based projects, use Python 3.x (3.9.x)
◦The latest stable release is 3.6+
◦There are minimal changes to syntax, but there are more
additional features per version/iteration.
Requirements
◦An operating system (Windows / Mac / Linux – pref.
Debian)
◦ Important: Python 3.9.x interpreter
◦ Optional:
◦ Text editors / IDEs: Sublime, VS Code, PyCharm, Anaconda, etc.
Python Basics | Two Modes of Python
•Interactive Mode
• Can be accessed via command line (windows) or terminal
(mac/linux/*nix) by typing the command python
• Can be accessed by accessing the IDLE program.
• This mode allows us to test certain code snippets – if we are
unsure if a condition or code outputs expected results.
Python Basics | Two Modes of Python
•Script Mode
• Can be accessed by accessing the IDLE program, and pressing
ctrl N (for windows) command N (for mac) to create a new
file.
• Can be accessed with other IDE's (just save your file as
your_filename.py )
• For UI/IDLE: <dot>py scripts are then interpreted and run by
pressing F5.
• For terminals: <dot>py scripts are then interpreted and run by
typing
python filename.py
Variables
• Storage locations that have a human-readable name
• Name-value pairs
• Case sensitive
• Must start with a letter, can contain numbers or
underscores.
• Unlike other PL's there is no need to indicate a variable's
datatype in Python because it is a Dynamic Typed language.
Datatypes
Types of data stored in a variable
•String
•Integer
•Float
•Boolean
•Bytes
Datatypes | Examples /1
•String
>>> Hello123world = 'test'
>>> hello_world = "test"
>>> helloWorld = '"test"'
>>> _ = "\"hi there!\""
Datatypes | Examples /2
•Integers
>>> a = 1
>>> B = 2
>>> c = -22
Datatypes | Examples /3
•Float
>>> a = 1.23
>>> b = 0.00001
>>> c = 3.1415
Datatypes | Examples /4
•Boolean
>>> a = 1 > 2
>>> b = True
>>> c = False
Input and Output /1
The input() is a built-in string function which accepts a
keyboard input from the user and on enter this input is
interpreted as a string data.
name = input("Enter Full Name: \n")
email = input("Enter Email: \n")
Input and Output /2
The print() is a built-in function which outputs string
data for the user to see on a terminal or shell.
print("Name: "+name)
print("Email: "+email)
String Concatenation /1
The plus (+) sign is used to concatenate two or more string
data in Python.
print("Name: "+name)
print("Email: "+email)
String Concatenation /2
What is the output of the given script?
a = 'word'
b = 1
print("String: "+a)
print("Number: "+b)
Typecasting /1
a = 'word' Typecasting
b = 1 • Converting one data
print("String: "+a) type into another
print("Number: "+str(b))
Typecasting /2
a = input() What is the output of the
script on the left?
b = input()
c = a + b What if we wanted to print
print("The Sum is: "+c) the sum of the two inputs?