Python study note_004

The sample in Chapter 2 has been modified as follows.

--Points to check --Distinguishing between double quotes "" "and single quotes"'" in strings ――Both can be used, but it is a prerequisite to use them as a pair. : x: print (' this is a test ** ") or: x: print (" ** this is a test ') : o: print (' this is a test ') or: o: print (** "** this is a test **" **) --When double quotation mark "" "or single quotation mark"'" exists in the character string, it can be realized by the following two types of correspondence. :o: print( " this is Tom's pen ")
:o: print( ' this is Tom's pen ')
:o: print( ' I said "Hello!" ')
:o: print( " I said "Hello!" ")
--The output result of the input function always returns with the character type. --Order of operation code In the United States, PEMDAS (Parentheses: parentheses, Exponents: power, Use the acronym Multiplication: Multiplication, Division: Division, Addition: Addition, Subtraction: Subtraction). --If you enter multiple character strings you want to output in the print function, a space will be inserted between them.

sample02.py


#Ask for the dog's name
dog_name = input('What is the name of the dog?')

#Ask the age of the dog
dog_age = input('How old is the dog?')

#Multiply the age of the dog by 7 to find the human equivalent age
human_age = int(dog_age) * 7

#The return type of input is a string(str)
print('As it is, the result of age x 7:',dog_age * 7)

#If you enter multiple character strings you want to output to the print function, a space will be inserted between them.
print('your dog',
      dog_name,
      'Human equivalent age',
      human_age,
      'I'm old')

Recommended Posts

Python study note_002
Python study note_004
Python study note_003
Note: Python
Python note
[WIP] Fluent Python Study Note
Note: Python Decorator
Python programming note
Python study notes _000
Python study notes_006
Python study notes _005
Jupyter Study Note_002
[Note] openCV + python
Python beginner's note
Python study notes_001
Jupyter Study Note_003
Jupyter Study Note_007
Jupyter Study Note_005
Python study day 1
[Note] future sentence ~ Python ~
[Note] File reading ~ Python ~
Note to daemonize python
Note: python Skeleton Nya
Python basic grammar note (4)
Python basic grammar note (3)
Python Tkinter Primer Note
Note
Python
Study Python with Google Colaboratory
Study from Python Hour4: Object-oriented ②
Python Input Note in AtCoder
[Note] Operate MongoDB with Python
Study from Python Hour3: Functions
Note
Note
python pandas study recent summary
3 months note for starting Python
Study from Python Hour4: Object-oriented ①
[AtCoder] ABC165C Personal Note [Python]
Note that it supports Python 3
A note about [python] __debug__
Python Note: About comparison using is
[Note] Project Euler in Python (Problem 1-22)
Python: A Note About Classes 1 "Abstract"
selenium case study summary python pyCharm
(Note) Be careful with python argparse
Study from Python Hour2: Control statements
Study on Tokyo Rent Using Python (3-2)
[Note] Hello world output with python
boto3 (AWS SDK for Python) Note
Foreign Key in Python SQLite [Note]
Study on Tokyo Rent Using Python (3-3)
Study, number guessing game in Python
Study Note 9_Install Jenkins on CentOS7
Python Note: Get the current month
A note about mock (Python mock library)
Basic study of OpenCV with Python
kafka python
Python & Machine Learning Study Memo: Environment Preparation
Django note 4
Python basics ⑤