Python

tmp.py



#variable
s = "str..."
l = ["1", "2", "3", "3", "4"]
t = ("A", "B", "C")
d = {"key": "value"}

s_ = str("str")
i_ = int("99")
f_ = float("100.0")
l_ = list((1,2,3))
d_ = dict([["key, "value"]])
e = set("0123456789")
ss = '''
dup
dup
dup
'''

#Print syntax
print(s, end="")

#slice
s[0:1]
s[-1]
s[::1]

#Built-in functions
len(s)
s.split()
",".join(l)
s.strip(".")
s.capitalize()
s.title()
s.upper()
s.lower()
s.swapcase()
s.replace(".", "!")
l.append("5")
l.insert(0, "10")
del l[0]
l.remove("10")
l.pop()
l.index("1")
l.count("3")
l.sort()
c = l.copy()
d.keys()
d.values()
d.items()

#for loop
for val in l:
    print(val)

#Calculation
False | True
True & True
1 > 0
0 >= 0

#if statement
if s == "s":
    print("s!")
elif s == "str":
    print("str!")
else:
    print("!!!")

#while loop
count = 0
while count < 3:
    print(count)
    count += 1

while True:
    print(count)
    if count == 5:
        break
    count += 1

#List comprehension
ll = [v for v in range(10)]

#function
def f(a,b):
    return a+b

#class
class S():
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def rep():
        print(self.a + " " + self.b)

ss = S("Thank", "you")
ss.rep()

Recommended Posts

Python
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Python comprehension
Python technique
Studying python
Python memorandum
Python FlowFishMaster
Python service
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
Python comprehension
install python
Python Singleton
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
python tips
Installing Python 3.4.3.
Try python
Python memo
Python iterative
Python algorithm
Python2 + word2vec
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial
Python decimals
python underscore
Python summary
Start python
[Python] Sort
Note: Python
Python basics ③
python log
Python basics
[Scraping] Python scraping
Python update (2.6-> 2.7)
python memo
Python memorandum
Python # sort
ufo-> python
Python nslookup
python learning
Hannari Python 2020
[Rpmbuild] Python 3.7.3.
Prorate Python (1)
python memorandum
Download python
python memorandum