SlideShare uma empresa Scribd logo
1 de 31
Python
Lecture 0
Problem Set 0: Basic
Topic
• Installation
• Hello World
• Input/ Output
• Variable (+Naming Convention)
• Data Type
• Type Casting
• Built in Function
• Problem Set 0: Basic (6)
Create First Python Program File
• Python IDLE
• File -> New File -> Save (/Save As) -> Hello.py
• Write Python Program
• Run -> Run Module (F5)
Write First Python Program
print("Hello World")
Comment
• # Single Line Comment
•
"""
Multi
Line
Comment
"""
First Python Program Modified
# First Python Program
# Program Name: Hello World
# Author Name: Mun Al Mamun
# A Program to Print a text
print("Hello World")
Input/ Output 1
# input a String
name = input()
print(name)
Input/ Output 1 (Con.)[Display Message 1]
#input a String
print("Input Your Name")
name = input()
print(name)
Input/ Output 1 (Con.)[Display Message 2]
#input a String
name = input("Input Your Name: ")
print(name)
Input/ Output 1 (Con.)[Data Type]
#input a String
name = input("Input Your Name: ")
print(name)
print(type(name))
Input Your Name
# input a String
#print("Input Your Name")
name = input("Input Your Name: ")
#name = input()
print(name)
#print(type(name))
Variable (+ Naming Convention) The Rules
• https://www.python.org/dev/peps/pep-0008/#naming-conventions
• lowercase_underscore for functions, methods, attributes, variables
• lowercase_underscore or ALL_CAPS for constants
• PascalCase for classes
• camelCase only to conform to pre-existing conventions
• _underscore for non-public methods and instance variables
Input an Integer Number
age = input()
print(age)
Input an Integer Number [2]
age = input()
print(age)
print(type(age))
• All Input is String in Python
• We have to Type Cast to convert String into Integer.
Input an Integer Number [3 (no way)]
age = input()
print(type(age))
print(age)
age = int(age)
print(age)
print(type(age))
Input an Integer Number [3] [Final]
age = int(input())
print(type(age))
print(age)
print(type(age))
Input an Float Number
cgpa = input()
print(cgpa)
print(type(cgpa))
Input an Float Number [1 (no way)]
cgpa = input()
print(type(cgpa))
cgpa = float(cgpa)
print(cgpa)
print(type(cgpa))
Input an Float Number [2] [Final]
cgpa = float(input())
print(type(cgpa))
print(cgpa)
print(type(cgpa))
Are you a liar? [1]
you = True
print(you)
print(type(you))
Are you a liar? [2]
you = False
print(you)
print(type(you))
Formatted I/O
#Input Name with Formatted Output
name = input("What is Your Name: ")
print("Hello, ",name)
#Input Age with Formatted Output
age = int(input("What is Your Age: "))
print("Your age is: ",age)
#Input CGPA with Formatted Output
cgpa = float(input("What is Your CGPA: "))
print("Your CGPA is ",cgpa)
Formatted I/O
#Input Name with Formatted Output
name = input("What is Your Name: ")
print("Hello, ",name)
print("Hello, ",name, "nHow are You?")
print("Hello, {}".format(name))
print(f"Hello, {name}")
Data Type
• str (String)
• int (Integer)
• float (Float)
• bool (Boolean)
• None (NoneType)
Built-in Function
• print()
• input()
• type()
• int()
• float()
• https://docs.python.org/3.6/library/functions.html
Problem Set 0: Basic (6)
• Hello World.
• IO Your Name.
• IO your Age.
• IO your CGPA.
• Are you a liar? (Boolean)
• Formatted I/O. (String + Numeric) [for Problem 2,3,4]
Online Resourse
• python.org -> Docs -> Tutorial
• YouTube
• Python Tutorials -> Corey Schafer
• Python Beginners Tutorials -> Mahmud Ahsan : Thinkdiff
• Learn Python Programming -> Clever Programmer
• Python 3.5 Basic (Bangla) -> Vubon Roy
• Python Tutorials for Absolute Beginners by CS Dojo -> CS Dojo
Any Question?
Prepared by
Mun Al Mamun
President
East West University Robotics Club
munewu@gmail.com
T h i s s l i d e i s p r o v i d e a s a c o u r s e
m a t e r i a l i n t h e w o r k s h o p
“ W o r k s h o p O n P y t h o n P r o g r a m m i n g ”
O r g a n i z e d b y
E a s t W e s t U n i v e r s i t y R o b o t i c s C l u b

Mais conteúdo relacionado

Semelhante a Lecture 0 python basic (ewurc)

Python for scientific computing
Python for scientific computingPython for scientific computing
Python for scientific computing
Go Asgard
 

Semelhante a Lecture 0 python basic (ewurc) (20)

python_class.pptx
python_class.pptxpython_class.pptx
python_class.pptx
 
なぜ検索しなかったのか
なぜ検索しなかったのかなぜ検索しなかったのか
なぜ検索しなかったのか
 
Introduction to Python3 Programming Language
Introduction to Python3 Programming LanguageIntroduction to Python3 Programming Language
Introduction to Python3 Programming Language
 
Python basics_ part1
Python basics_ part1Python basics_ part1
Python basics_ part1
 
Python Loop
Python LoopPython Loop
Python Loop
 
Python Crawler
Python CrawlerPython Crawler
Python Crawler
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Core Concept_Python.pptx
Core Concept_Python.pptxCore Concept_Python.pptx
Core Concept_Python.pptx
 
go.ppt
go.pptgo.ppt
go.ppt
 
Python basics
Python basicsPython basics
Python basics
 
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Python for scientific computing
Python for scientific computingPython for scientific computing
Python for scientific computing
 
First session
First sessionFirst session
First session
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__
 
Python入門 : 4日間コース社内トレーニング
Python入門 : 4日間コース社内トレーニングPython入門 : 4日間コース社内トレーニング
Python入門 : 4日間コース社内トレーニング
 
#Code2Create: Python Basics
#Code2Create: Python Basics#Code2Create: Python Basics
#Code2Create: Python Basics
 

Mais de Al-Mamun Riyadh (Mun) (6)

Lecture 1 python arithmetic (ewurc)
Lecture 1 python arithmetic (ewurc)Lecture 1 python arithmetic (ewurc)
Lecture 1 python arithmetic (ewurc)
 
Prime Number (Sieve)
Prime Number (Sieve)Prime Number (Sieve)
Prime Number (Sieve)
 
Workshop on arduino (ewurc)
Workshop on arduino (ewurc)Workshop on arduino (ewurc)
Workshop on arduino (ewurc)
 
Lecture 6 python oop (ewurc)
Lecture 6 python oop (ewurc)Lecture 6 python oop (ewurc)
Lecture 6 python oop (ewurc)
 
Lecture 4 python string (ewurc)
Lecture 4 python string (ewurc)Lecture 4 python string (ewurc)
Lecture 4 python string (ewurc)
 
Lecture 2 python conditional (ewurc)
Lecture 2 python conditional (ewurc)Lecture 2 python conditional (ewurc)
Lecture 2 python conditional (ewurc)
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Último (20)

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 

Lecture 0 python basic (ewurc)

  • 1.
  • 3. Topic • Installation • Hello World • Input/ Output • Variable (+Naming Convention) • Data Type • Type Casting • Built in Function • Problem Set 0: Basic (6)
  • 4.
  • 5. Create First Python Program File • Python IDLE • File -> New File -> Save (/Save As) -> Hello.py • Write Python Program • Run -> Run Module (F5)
  • 6. Write First Python Program print("Hello World")
  • 7. Comment • # Single Line Comment • """ Multi Line Comment """
  • 8. First Python Program Modified # First Python Program # Program Name: Hello World # Author Name: Mun Al Mamun # A Program to Print a text print("Hello World")
  • 9. Input/ Output 1 # input a String name = input() print(name)
  • 10. Input/ Output 1 (Con.)[Display Message 1] #input a String print("Input Your Name") name = input() print(name)
  • 11. Input/ Output 1 (Con.)[Display Message 2] #input a String name = input("Input Your Name: ") print(name)
  • 12. Input/ Output 1 (Con.)[Data Type] #input a String name = input("Input Your Name: ") print(name) print(type(name))
  • 13. Input Your Name # input a String #print("Input Your Name") name = input("Input Your Name: ") #name = input() print(name) #print(type(name))
  • 14. Variable (+ Naming Convention) The Rules • https://www.python.org/dev/peps/pep-0008/#naming-conventions • lowercase_underscore for functions, methods, attributes, variables • lowercase_underscore or ALL_CAPS for constants • PascalCase for classes • camelCase only to conform to pre-existing conventions • _underscore for non-public methods and instance variables
  • 15. Input an Integer Number age = input() print(age)
  • 16. Input an Integer Number [2] age = input() print(age) print(type(age)) • All Input is String in Python • We have to Type Cast to convert String into Integer.
  • 17. Input an Integer Number [3 (no way)] age = input() print(type(age)) print(age) age = int(age) print(age) print(type(age))
  • 18. Input an Integer Number [3] [Final] age = int(input()) print(type(age)) print(age) print(type(age))
  • 19. Input an Float Number cgpa = input() print(cgpa) print(type(cgpa))
  • 20. Input an Float Number [1 (no way)] cgpa = input() print(type(cgpa)) cgpa = float(cgpa) print(cgpa) print(type(cgpa))
  • 21. Input an Float Number [2] [Final] cgpa = float(input()) print(type(cgpa)) print(cgpa) print(type(cgpa))
  • 22. Are you a liar? [1] you = True print(you) print(type(you))
  • 23. Are you a liar? [2] you = False print(you) print(type(you))
  • 24. Formatted I/O #Input Name with Formatted Output name = input("What is Your Name: ") print("Hello, ",name) #Input Age with Formatted Output age = int(input("What is Your Age: ")) print("Your age is: ",age) #Input CGPA with Formatted Output cgpa = float(input("What is Your CGPA: ")) print("Your CGPA is ",cgpa)
  • 25. Formatted I/O #Input Name with Formatted Output name = input("What is Your Name: ") print("Hello, ",name) print("Hello, ",name, "nHow are You?") print("Hello, {}".format(name)) print(f"Hello, {name}")
  • 26. Data Type • str (String) • int (Integer) • float (Float) • bool (Boolean) • None (NoneType)
  • 27. Built-in Function • print() • input() • type() • int() • float() • https://docs.python.org/3.6/library/functions.html
  • 28. Problem Set 0: Basic (6) • Hello World. • IO Your Name. • IO your Age. • IO your CGPA. • Are you a liar? (Boolean) • Formatted I/O. (String + Numeric) [for Problem 2,3,4]
  • 29. Online Resourse • python.org -> Docs -> Tutorial • YouTube • Python Tutorials -> Corey Schafer • Python Beginners Tutorials -> Mahmud Ahsan : Thinkdiff • Learn Python Programming -> Clever Programmer • Python 3.5 Basic (Bangla) -> Vubon Roy • Python Tutorials for Absolute Beginners by CS Dojo -> CS Dojo
  • 31. Prepared by Mun Al Mamun President East West University Robotics Club munewu@gmail.com T h i s s l i d e i s p r o v i d e a s a c o u r s e m a t e r i a l i n t h e w o r k s h o p “ W o r k s h o p O n P y t h o n P r o g r a m m i n g ” O r g a n i z e d b y E a s t W e s t U n i v e r s i t y R o b o t i c s C l u b