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)
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")
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
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)
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]
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