Python day 1

Start python

・ Start with Tamitaru (MAC) OR CMD (WIN).

Data type

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)

Basic syntax used in Python

① 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!

Functions often used in strings

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

Feeling, doubt

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

Python day 1
Python learning day 4
Python study day 1
Python
[1day1lang AdventCalender] day4 Python
Effective Python Learning Memorandum Day 15 [15/100]
Umemura style Python expedition Day 0
Effective Python Learning Memorandum Day 6 [6/100]
Effective Python Learning Memorandum Day 12 [12/100]
Effective Python Learning Memorandum Day 9 [9/100]
Effective Python Learning Memorandum Day 8 [8/100]
Sparta Camp Python 2019 Day2 Challenge
Effective Python Learning Memorandum Day 14 [14/100]
Effective Python Learning Memorandum Day 1 [1/100]
Effective Python Learning Memorandum Day 13 [13/100]
Effective Python Learning Memorandum Day 3 [3/100]
Effective Python Learning Memorandum Day 5 [5/100]
Effective Python Learning Memorandum Day 4 [4/100]
Umemura style Python expedition day 1
Effective Python Learning Memorandum Day 7 [7/100]
Effective Python Learning Memorandum Day 2 [2/100]
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python comprehension
Python technique
Studying python
Python 2.7 Countdown
Python memorandum
Python FlowFishMaster
Python service
python tips
[Introduction to Python3 Day 1] Programming and Python
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
[Introduction to Python3 Day 13] Chapter 7 Strings (7.1-7.1.1.1)
[Python] function
Python installation
python tips
Try python
Python memo
Python iterative
Python2 + word2vec
Python functions
[Introduction to Python3 Day 14] Chapter 7 Strings (7.1.1.1 to 7.1.1.4)
Python tutorial
python underscore
Python summary