・ Start with Tamitaru (MAC) OR CMD (WIN).
What is a variable? -> Named data. (e.g your size = 100-> your_size = 100)
--Boolean (with True or False values) --Integer (number without decimal point, such as 42) --Floating point numbers (numbers with a decimal point, such as 3.141592, or exponential functions such as 10e8 [10 to the 8th power]) --String (just a string)
① Conditional branch An IF statement that begins with the so-called "If".
if 3 > 1:
Print('Hello World.')
After saving in document format, when you start it via Python, Hello World
is displayed.
Add a colon after the conditional branch!
your_size = 36
if your_size <= 15:
Print('s')
elif your_size < 30:
print ('M')
else:
print ('L')
<= Below elif Multiple conditional branches else Condition "other than that"
② Repeat Store multiple data in one variable. In the example below, 1 to 5 are ** elements that are subject to iterative processing **.
array =[1,2,3,4,5]
for v in array:
print(v)
Arrange the stored elements in order in the for ~ in statement!
-Str () function Expansion of character strings.
>>> str(98.6)
`98.6`
>>> str(true)
`ture`
・ Escape using
You can use \ n to convert to multiple lines with a single digit input.
・ Repeat using * You can use * to repeat a string.
>>>start = 'Na ' *3 + ' \na'
>>>print (start)
Na Na Na
(kuhaku is born)
In the case of numerical representation, you can basically take out, divide, count, and replace the stored elements. I haven't compared it, but it seems that Python is easier to write than other languages. Anyway, with WIN, I'm at a loss as to how to save Doc files. Don't start Python from CMD. I think this is probably because there is no Python App in User. All you need to do is what you want to do. You can do them by thinking and writing logical ways such as how you want to display the stored data.
Recommended Posts