python-cheat-sheet
Python用のチートシート
https://plantuml-proxy.vercel.app/svg/https://scrapbox.io/api/code/suto3scratchpad/python-cheat-sheet/cs01.pu#.svg
code:cs01.pu
@startuml
skinparam backgroundColor transparent
object Python3CheetSheet {
code:cs01.pu
Arithmetic Operators
|= Operators |= Operation |= Examples |
| + | Addition | 1+3=4 |
| - | Subtraction | 1-3=-2 |
| * | Multiplication | 1*3=3|
| / | Division | 1/3=0.33… |
| // | Floored Division | 1//3=0 |
| % | Remainder | 1%3=1 |
---
DataTypes
|= DataTypes |= Examples|
| Integers| 0, 2, -1, 5|
| Strings| “a”, “hello”, “1234”, “12 Hello.”|
| Boolean| True, False|
| Floating Point Numbers| 16.0, -11.0, 2021.5|
---
Variables
>> variable_name = "Hello"
---
Comments
<U+0023> inline comment
<U+0027><U+0027><U+0027>
docstring comment
<U+0027><U+0027><U+0027>
---
Relational Operators
|= Operator |= What it does|
| == | Is equal to|
| >= | Is Greater than or Equal to|
| <= | Is Less than or Equal to|
| > | Is Greater than|
| < | Is Less than|
| != | Not Equal to|
---
Boolean Operators
|= Operator |= What it does|
| and | Returns True if both operands are True, else False|
| or | Returns True if both operands are True, else False|
| not | Returns value opposite to the Truth value of the expression|
---
Conditional Statements
- if
- elif
- else
---
Loop Statements
* For Loops
- For with range
- For with range(start, stop, step)
- For with in
* While Loops
---
Jump Statements
*break
*continue
*pass
*return
---
Functions
- def
- functon name
- arguments
- functon body
* statments
* reuturn value
---
Variable Scope Resolution
- Built-in
- Global
- Enclosed
- Local
---
Importing Modules
* import
- ex. import math
---
Exception Handling
*try
*except
*finally
---
Lists
---
Tuples
---
Dictionaries
dict = {'first' : 'sunday', 'second' : 'monday', 'third' : 'tuesday'}
---
Sets
---
Comprehensions
code:cs01.pu
}
@enduml