際際滷

際際滷Share a Scribd company logo
Basic Python (Part 1)
CSC1105 PROGRAMMING WITH PYTHON
Learning objectives
At the end of this chapter, student should be able to:
1. Identify the syntax and variable in python
Introduction to Python CSC1105 PROGRAMMING
WITH PYTHON
What is Python?
What can Python do?
used on a server to create web applications
can also read and modify files.
can be used to handle big data and perform complex mathematics.
Python Syntax compared to other
programming languages
 Python was designed for readability and has some similarities to the English
language with influence from mathematics.
 Python uses new lines to complete a command, as opposed to other
programming languages which often use semicolons or parentheses.
 Python relies on indentation, using whitespace, to define scope; such as the
scope of loops, functions and classes. Other programming languages often
use curly-brackets for this purpose.
Syntax CSC1105 PROGRAMMING
WITH PYTHON
What is syntax?
Syntax refers to the rules and structure that define how to write code in a specific language.
Python Indentation
Indentation refers to the spaces at the beginning of a code line.
Where in other programming languages the indentation in code is for readability
only, the indentation in Python is very important.
Python uses indentation to indicate a block of code.
Python Indentation
The number of spaces is up to you
as a programmer, the most common
use is four, but it has to be at least
one.
You have to use the same number
of spaces in the same block of code,
otherwise Python will give you an
error:
Comments CSC1105 PROGRAMMING
WITH PYTHON
Why need to use comment?
explain Python
code.
make the code
more readable.
prevent
execution when
testing code.
Creating a comment
Comments starts with a #, and Python will
ignore them
Comments can be placed at the end of a
line, and Python will ignore the rest of the
line
A comment does not have to be text that
explains the code, it can also be used to
prevent Python from executing code
Multiline comments
Python does not really have a syntax
for multiline comments. To add a
multiline comment, you could insert a #
for each line:
add a multiline string (triple quotes)
Variables CSC1105 PROGRAMMING
WITH PYTHON
What is variables?
Creating Variables
Python has no command for declaring a variable.
A variable is created the moment you first assign a
value to it.
Variables do not need to be declared with any
particular type, and can even change type after
they have been set.
Casting
If you want to specify the data type of a variable, this can be done with casting.
Get the type
You can get the data type of a variable with the type() function.
Variable Names
1. A variable can have a short name (like x and y) or a more descriptive name (age, carname,
total_volume). Rules for Python variables:
2. A variable name must start with a letter or the underscore character
3. A variable name cannot start with a number
4. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
5. Variable names are case-sensitive (age, Age and AGE are three different variables)
6. A variable name cannot be any of the Python keywords.
basic python part 1_powerpoint slideshare
Legal VS Illegal variable names
LEGAL ILLEGAL
Multi words variable Names
Multi words variable Names
Multi words variable Names
Assign Multiple Values
MANY VALUES TO MULTIPLE VARIABLES ONE VALUE TO MULTIPLE VARIABLES
Unpack a collection
Output Variables
SIMPLE MULTIPLE VARIABLES
Output Variables
+ OPERATOR NUMBER WITH + OPERATOR
Output Variables
+ OPERATOR
COMBINE STRING AND NUMBER
TRUE OR FALSE?
COMMA
COMBINE STRING AND NUMBER
TRUE OR FALSE?
Conclusions
What have you learned today?

More Related Content

Similar to basic python part 1_powerpoint slideshare (20)

Python Over View (Python for mobile app Devt)1.ppt
Python Over View (Python for mobile app Devt)1.pptPython Over View (Python for mobile app Devt)1.ppt
Python Over View (Python for mobile app Devt)1.ppt
AbdurehmanDawud
Py-際際滷s-1.ppt1234444444444444444444444444444444444444444
Py-際際滷s-1.ppt1234444444444444444444444444444444444444444Py-際際滷s-1.ppt1234444444444444444444444444444444444444444
Py-際際滷s-1.ppt1234444444444444444444444444444444444444444
divijareddy0502
Py-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdf
Py-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdfPy-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdf
Py-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdf
shetoooelshitany74
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
notwa dfdfvs gf fdgfgh  s thgfgh frg regggnotwa dfdfvs gf fdgfgh  s thgfgh frg reggg
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
Godwin585235
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptxa9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
cigogag569
Python Programming for Beginners
Python Programming for BeginnersPython Programming for Beginners
Python Programming for Beginners
DivyanganaBharadwaj
Python Fundamentals for the begginers in programming
Python Fundamentals for the begginers in programmingPython Fundamentals for the begginers in programming
Python Fundamentals for the begginers in programming
bsse20142018
Pyhton problem solving introduction and examples
Pyhton problem solving introduction and examplesPyhton problem solving introduction and examples
Pyhton problem solving introduction and examples
ssuser65733f
PYTHON-Unit-I-Notes for python learnerss
PYTHON-Unit-I-Notes for python learnerssPYTHON-Unit-I-Notes for python learnerss
PYTHON-Unit-I-Notes for python learnerss
Sree Saraswathi Thiagaraja College
Unit-I-PPT-1.ppt
Unit-I-PPT-1.pptUnit-I-PPT-1.ppt
Unit-I-PPT-1.ppt
Chinmaya M. N
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
Francis Densil Raj
Python 01.pptx
Python 01.pptxPython 01.pptx
Python 01.pptx
AliMohammadAmiri
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds
hardikbhagwaria83
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptxpython notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
yuvarajkumar334
Python Interview Questions For Freshers
Python Interview Questions For FreshersPython Interview Questions For Freshers
Python Interview Questions For Freshers
zynofustechnology
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
samiwaris2
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
KAUSHAL KUMAR JHA
Introduction to Python Basics for PSSE Integration
Introduction to Python Basics for PSSE IntegrationIntroduction to Python Basics for PSSE Integration
Introduction to Python Basics for PSSE Integration
FarhanKhan978284
Python Over View (Python for mobile app Devt)1.ppt
Python Over View (Python for mobile app Devt)1.pptPython Over View (Python for mobile app Devt)1.ppt
Python Over View (Python for mobile app Devt)1.ppt
AbdurehmanDawud
Py-際際滷s-1.ppt1234444444444444444444444444444444444444444
Py-際際滷s-1.ppt1234444444444444444444444444444444444444444Py-際際滷s-1.ppt1234444444444444444444444444444444444444444
Py-際際滷s-1.ppt1234444444444444444444444444444444444444444
divijareddy0502
Py-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdf
Py-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdfPy-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdf
Py-際際滷s- easuajsjsjejejjwlqpqpqpp1.pdf
shetoooelshitany74
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
notwa dfdfvs gf fdgfgh  s thgfgh frg regggnotwa dfdfvs gf fdgfgh  s thgfgh frg reggg
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
Godwin585235
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptxa9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
cigogag569
Python Programming for Beginners
Python Programming for BeginnersPython Programming for Beginners
Python Programming for Beginners
DivyanganaBharadwaj
Python Fundamentals for the begginers in programming
Python Fundamentals for the begginers in programmingPython Fundamentals for the begginers in programming
Python Fundamentals for the begginers in programming
bsse20142018
Pyhton problem solving introduction and examples
Pyhton problem solving introduction and examplesPyhton problem solving introduction and examples
Pyhton problem solving introduction and examples
ssuser65733f
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds
hardikbhagwaria83
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptxpython notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
yuvarajkumar334
Python Interview Questions For Freshers
Python Interview Questions For FreshersPython Interview Questions For Freshers
Python Interview Questions For Freshers
zynofustechnology
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
samiwaris2
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
KAUSHAL KUMAR JHA
Introduction to Python Basics for PSSE Integration
Introduction to Python Basics for PSSE IntegrationIntroduction to Python Basics for PSSE Integration
Introduction to Python Basics for PSSE Integration
FarhanKhan978284

More from AnisZahirahAzman (17)

Week 1A Introduction to Computers and Digital Systems.pdf
Week 1A Introduction to Computers and Digital Systems.pdfWeek 1A Introduction to Computers and Digital Systems.pdf
Week 1A Introduction to Computers and Digital Systems.pdf
AnisZahirahAzman
Chapter 6.pdf
Chapter 6.pdfChapter 6.pdf
Chapter 6.pdf
AnisZahirahAzman
Chapter 4.pdf
Chapter 4.pdfChapter 4.pdf
Chapter 4.pdf
AnisZahirahAzman
Chapter 10.pdf
Chapter 10.pdfChapter 10.pdf
Chapter 10.pdf
AnisZahirahAzman
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
AnisZahirahAzman
Chapter 2.pdf
Chapter 2.pdfChapter 2.pdf
Chapter 2.pdf
AnisZahirahAzman
Chapter 1.pdf
Chapter 1.pdfChapter 1.pdf
Chapter 1.pdf
AnisZahirahAzman
Chapter 2.pdf
Chapter 2.pdfChapter 2.pdf
Chapter 2.pdf
AnisZahirahAzman
Chapter 1.pdf
Chapter 1.pdfChapter 1.pdf
Chapter 1.pdf
AnisZahirahAzman
Chapter 1.pdf
Chapter 1.pdfChapter 1.pdf
Chapter 1.pdf
AnisZahirahAzman
Chapter 13.pptx
Chapter 13.pptxChapter 13.pptx
Chapter 13.pptx
AnisZahirahAzman
IoT Protocol Stack.pdf
IoT Protocol Stack.pdfIoT Protocol Stack.pdf
IoT Protocol Stack.pdf
AnisZahirahAzman
Chapter 9.pptx
Chapter 9.pptxChapter 9.pptx
Chapter 9.pptx
AnisZahirahAzman
connecting smart object in IoT.pptx
connecting smart object in IoT.pptxconnecting smart object in IoT.pptx
connecting smart object in IoT.pptx
AnisZahirahAzman
Chapter 5.pptx
Chapter 5.pptxChapter 5.pptx
Chapter 5.pptx
AnisZahirahAzman
introduction to c.pptx
introduction to c.pptxintroduction to c.pptx
introduction to c.pptx
AnisZahirahAzman
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
AnisZahirahAzman

Recently uploaded (20)

Hire Odoo Developer OnestopDA Experts.
Hire Odoo Developer  OnestopDA Experts.Hire Odoo Developer  OnestopDA Experts.
Hire Odoo Developer OnestopDA Experts.
OnestopDA
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
Ava Isley
Adobe InDesign Crack Full Version Free Download 2025
Adobe InDesign Crack  Full Version Free Download 2025Adobe InDesign Crack  Full Version Free Download 2025
Adobe InDesign Crack Full Version Free Download 2025
sannnasaba545
Online Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi NcrOnline Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi Ncr
Home
Tenorshare 4uKey Crack Fre e Download
Tenorshare  4uKey  Crack  Fre e DownloadTenorshare  4uKey  Crack  Fre e Download
Tenorshare 4uKey Crack Fre e Download
oyv9tzurtx
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
salesforce development services - Alt digital
salesforce development services - Alt digitalsalesforce development services - Alt digital
salesforce development services - Alt digital
Alt Digital Technologies
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
mohammadasim74
Instagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo websiteInstagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo website
AxisTechnolabs
How John started to like TDD (instead of hating it) - TED talk
How John started to like TDD (instead of hating it) - TED talkHow John started to like TDD (instead of hating it) - TED talk
How John started to like TDD (instead of hating it) - TED talk
Nacho Cougil
AI-Powered Chatbots for Employee Support
AI-Powered Chatbots for Employee SupportAI-Powered Chatbots for Employee Support
AI-Powered Chatbots for Employee Support
AutomationEdge Technologies
AI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI AssistansAI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI Assistans
HusseinMalikMammadli
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
OutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdfOutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdf
mail496323
Computer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .pptComputer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .ppt
jaysen110
LDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free DownloadLDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free Download
5ls1bnl9iv
SE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.pptSE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.ppt
theworldimagine985
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Shubham Joshi
Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025
Anadea
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc
Hire Odoo Developer OnestopDA Experts.
Hire Odoo Developer  OnestopDA Experts.Hire Odoo Developer  OnestopDA Experts.
Hire Odoo Developer OnestopDA Experts.
OnestopDA
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
Ava Isley
Adobe InDesign Crack Full Version Free Download 2025
Adobe InDesign Crack  Full Version Free Download 2025Adobe InDesign Crack  Full Version Free Download 2025
Adobe InDesign Crack Full Version Free Download 2025
sannnasaba545
Online Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi NcrOnline Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi Ncr
Home
Tenorshare 4uKey Crack Fre e Download
Tenorshare  4uKey  Crack  Fre e DownloadTenorshare  4uKey  Crack  Fre e Download
Tenorshare 4uKey Crack Fre e Download
oyv9tzurtx
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
salesforce development services - Alt digital
salesforce development services - Alt digitalsalesforce development services - Alt digital
salesforce development services - Alt digital
Alt Digital Technologies
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
mohammadasim74
Instagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo websiteInstagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo website
AxisTechnolabs
How John started to like TDD (instead of hating it) - TED talk
How John started to like TDD (instead of hating it) - TED talkHow John started to like TDD (instead of hating it) - TED talk
How John started to like TDD (instead of hating it) - TED talk
Nacho Cougil
AI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI AssistansAI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI Assistans
HusseinMalikMammadli
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
OutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdfOutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdf
mail496323
Computer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .pptComputer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .ppt
jaysen110
LDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free DownloadLDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free Download
5ls1bnl9iv
SE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.pptSE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.ppt
theworldimagine985
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Shubham Joshi
Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025
Anadea
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc

basic python part 1_powerpoint slideshare

  • 1. Basic Python (Part 1) CSC1105 PROGRAMMING WITH PYTHON
  • 2. Learning objectives At the end of this chapter, student should be able to: 1. Identify the syntax and variable in python
  • 3. Introduction to Python CSC1105 PROGRAMMING WITH PYTHON
  • 5. What can Python do? used on a server to create web applications can also read and modify files. can be used to handle big data and perform complex mathematics.
  • 6. Python Syntax compared to other programming languages Python was designed for readability and has some similarities to the English language with influence from mathematics. Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses. Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.
  • 8. What is syntax? Syntax refers to the rules and structure that define how to write code in a specific language.
  • 9. Python Indentation Indentation refers to the spaces at the beginning of a code line. Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important. Python uses indentation to indicate a block of code.
  • 10. Python Indentation The number of spaces is up to you as a programmer, the most common use is four, but it has to be at least one. You have to use the same number of spaces in the same block of code, otherwise Python will give you an error:
  • 12. Why need to use comment? explain Python code. make the code more readable. prevent execution when testing code.
  • 13. Creating a comment Comments starts with a #, and Python will ignore them Comments can be placed at the end of a line, and Python will ignore the rest of the line A comment does not have to be text that explains the code, it can also be used to prevent Python from executing code
  • 14. Multiline comments Python does not really have a syntax for multiline comments. To add a multiline comment, you could insert a # for each line: add a multiline string (triple quotes)
  • 17. Creating Variables Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. Variables do not need to be declared with any particular type, and can even change type after they have been set.
  • 18. Casting If you want to specify the data type of a variable, this can be done with casting.
  • 19. Get the type You can get the data type of a variable with the type() function.
  • 20. Variable Names 1. A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables: 2. A variable name must start with a letter or the underscore character 3. A variable name cannot start with a number 4. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) 5. Variable names are case-sensitive (age, Age and AGE are three different variables) 6. A variable name cannot be any of the Python keywords.
  • 22. Legal VS Illegal variable names LEGAL ILLEGAL
  • 26. Assign Multiple Values MANY VALUES TO MULTIPLE VARIABLES ONE VALUE TO MULTIPLE VARIABLES
  • 29. Output Variables + OPERATOR NUMBER WITH + OPERATOR
  • 30. Output Variables + OPERATOR COMBINE STRING AND NUMBER TRUE OR FALSE? COMMA COMBINE STRING AND NUMBER TRUE OR FALSE?
  • 31. Conclusions What have you learned today?