Python (Level-2): Data type, for Loop, String, Functions
4. Data types(intro)
Data Types
- As in other programming languages, data types are very important.
- Since Python provides many practical data types,
it is very important to clearly understand and use them.
- For now, only the very basics of data types are covered.
data types 01
data types 02
### [Self-Practice] ###
5. loop statement: for
for loop 01
for loop 02
for loop 03
for loop 04
### [Self-Practice] ###
6. Do you know the difference between 'keywords' and 'statement'?
Keywords(Reserved Words)
- What are keywords?
- Literally meaning 'important word', it means that the programmer cannot change it.
- Keywords may differ slightly depending on the Python version.
difference between keywords_and_statements
7. Functions
Python has several functions that are readily available for use. These functions are called built-in functions. In this page, you will find all the built-in functions in Python.
import calendar
calendar.prmonth(2020, 3)
March 2020
Mo Tu We Th Fr Sa Su
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
def arithmetic_operation(a, b):
return a+b, a-b, a*b, a/b
c = arithmetic_operation(1, 2)
### [Self-Practice] ###
a little special control statement
- break
- continue
- pass
break, continue, pass keywords
# is this OK?
course_grade = [0, 100, 50, 100, 80]
sum = 0
for course in course_grade:
sum += course
print("course sum:", sum)
print("average:", sum / len(course_grade))
Can we use built-in function names for variables?
# Is this OK?
i = j = 20
print(i, j)
# Is this OK Too?
i = (j = 10)
print(i, j)
8. Operators review : operators in (2)
Comments
Post a Comment