Mayungo's Python Learning Episode 8: I tried input

As you write a program, you may want to enter it yourself and move it accordingly.

Here we use input ().

Here, we put characters in a variable called word.

If you print it, it will come out as it is.

word = input()
aiueo

print(word)
aiueo

It can also be numbers.

However, the input method changes a little depending on whether you treat it as a letter or a number.

In the case of letters, it takes the form of input () as it is, and in the case of numbers, it takes the form of int (input ()).

Even if the same 1 is used, the treatment will be different as mentioned above depending on whether or not to add an int.

one = input()
two = int(input())
1
1

print(one + one)
print(two + two)
11
2

Note that if you put ordinary characters in int (input ()), an error will occur.

print(int(input()))
afsfa

ValueError                                Traceback (most recent call last)
<ipython-input-5-4d16d49e5846> in <module>
----> 1 print(int(input()))

ValueError: invalid literal for int() with base 10: 'afsfa'

Click here for a list of each story.

[The same content is also available in the video, so please have a look. ](Mayungo's Python Learning Episode 8: I tried input)

Recommended Posts

Mayungo's Python Learning Episode 8: I tried input
Mayungo's Python Learning Episode 1: I tried printing with print
Mayungo's Python Learning Episode 3: I tried to print numbers with print
Mayungo's Python Learning Episode 7: I tried printing with if, elif, else
Mayungo's Python Learning Episode 6: I tried to convert a character string to a number
Mayungo's Python Learning Episode 2: I tried to put out characters with variables
Mayungo's Python Learning Episode 5: I tried to do four arithmetic operations with numbers
Python3 standard input I tried to summarize
I tried Python> autopep8
I tried deep learning
I tried Python> decorator
Mayungo's Python Learning Episode 9: Gold Ax and Silver Ax
Mayungo's Python Learning Episode 4: I tried to see what happens when numbers are treated as letters
I tried fp-growth with python
I tried scraping with Python
I tried Python C extension
[Python] I tried using OpenPose
I tried input interpolation on UE4 Python VS Code
I tried gRPC with Python
I tried scraping with python
I tried to touch Python (installation)
I tried machine learning with liblinear
Input / output with Python (Python learning memo ⑤)
Notation I encountered while learning Python
I tried using Thonny (Python / IDE)
I tried Grumpy (Go running Python).
I tried reinforcement learning using PyBrain
I tried deep learning using Theano
I tried running prolog with python 3.8.2.
I tried Line notification in Python
I tried SMTP communication with Python
I tried learning LightGBM with Yellowbrick
[Python] I tried using YOLO v3
python learning
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I tried to implement permutation in Python
Wrangle x Python book I tried it [2]
[Episode 2] Beginners tried Numeron AI with python
[Episode 3] Beginners tried Numeron AI with python
I tried scraping Yahoo News with Python
I tried to implement PLSA in Python 2
I tried learning with Kaggle's Titanic (kaggle②)
[Kaggle] I tried ensemble learning using LightGBM
I tried sending an email with python.
I tried using Bayesian Optimization in Python
I tried non-photorealistic rendering with Python + opencv
I tried using UnityCloudBuild API from Python
I tried to implement ADALINE in Python
I tried a functional language with Python
[Episode 0] Beginners tried Numeron AI with python
I tried recursion with Python ② (Fibonacci sequence)
I tried to implement PPO in Python
Wrangle x Python book I tried it [1]
[Python] I tried to calculate TF-IDF steadily
I tried scraping Yahoo weather (Python edition)
I tried to touch Python (basic syntax)
I tried the Python Tornado Testing Framework
#I tried something like Vlookup with Python # 2
[ML-Aents] I tried machine learning using Unity and Python TensorFlow (v0.11β compatible)
[Python / DynamoDB / boto3] List of operations I tried