Summary of study done this week (H29.1.30 ~ 2.5)

This is a notebook I made for my study.

** What I did **

last week "Introduction to Programming Language Python 3" https://www.udemy.com/intro-to-python3/ I've finished up to Section 2. However, I stumbled on the way and decided to stop.

Instead, I decided to do paiza learning. https://paiza.jp/works

This was to actually devote programming to video learning and exercises without doing troublesome things such as environment construction.

In a week, I finished the python beginner's course and learned a lot about what I didn't understand.

** Don't know **

・ I don't understand "input".

In paiza, there are places to input and output, and when you input to the input place and execute it, the output result is displayed.

  1. Display the entered value
  2. Display the entered one-line numerical value
  3. Display the entered multi-line number

1. Display the entered value

a = input() print(a)

Input value sample Output value sample

2. Display the entered one-line numerical value

data = input() print(data)

Input value 1 2 3 Output value 1 2 3

3. Display the entered multi-line numbers

import sys for line in sys.stdin.readlines(): print(line.rstrip)

Input value 1 2 3

Output value 1 2 3

I wasn't sure why this happened, but apparently the sys.stdin.readlines function reads the file and processes it line by line, so it's like this.

development

Next, I will give the total value for development

num = [20,30,40,60]

print(sum(num))

The output value is 150.

Let's do this with the one-line and multi-line numbers.

~~ I tried it, but I can't do it yet. ~~

~~ I will post it if possible. ~~ (2/6 was done!) I'm not sure about numbers, arrays, and type transformations right now.

line = input() print(line)

Input value 1 2 3 Output value 1 2 3

I understand that

line = input().split() print(line)

Input value 1 2 3 Output value ['1', '2', '3']

You can see this too. You made it into an array, didn't you?

Output value [1,2,3] How do you do it?

line = input().split()

line_int = list(map(int,line))

print(line_int)

The output value is now [1,2,3]! !!

Apparently, the map function and the list function were the key.

The map function "processes all elements". It is not well understood.

I don't really understand the list function.

I will check it from time to time.

So the total is

print(sum(line_int))

Recommended Posts

Summary of study done this week (H29.2.13 ~ 2.24)
Summary of study done this week (H29.1.30 ~ 2.5)
H29.2.27 ~ 3.5 Summary of what I did
Numerical summary of data
Summary of Tensorflow / Keras
Programming study site summary
Summary of pyenv usage
Summary of string operations
Summary of Python arguments
Summary of logrotate software logrotate
Summary of test method