Difference in how to write if statement between ruby ​​and python

I'm studying the basic grammar of python with Progate, so I will summarize the differences from ruby.

ruby if statement

・ Enclose in if ~ end

x = 100

if x == 100
 print "x is 100"
else
 print "x is not 100"
end

python if statement

-Add ": (colon)" at the end of the conditional expression -Indent the description of the process to be executed

x = 100
if x == 100:
    print('x is 100')
else:
    print('x is not 100')

Indentation directly affects the operation of python, so it's good that it naturally seems to be highly readable code.

Recommended Posts

Difference in how to write if statement between ruby ​​and python
How to write Ruby to_s in Python
How to write the correct shebang in Perl, Python and Ruby scripts
Difference between Ruby and Python split
Difference between list () and [] in Python
Difference between == and is in python
Difference in writing method to read external source code between Ruby and Python
Differences between Ruby and Python in scope
difference between statements (statements) and expressions (expressions) in Python
Difference between @classmethod and @staticmethod in Python
Difference between append and + = in Python list
Difference between nonlocal and global in Python
How to use is and == in Python
Offline real-time how to write E11 ruby and python implementation example
How to generate permutations in Python and C ++
[python] Difference between variables and self. Variables in class
About the difference between "==" and "is" in python
How to write async and await in Vue.js
How to plot autocorrelation and partial autocorrelation in python
[Introduction to Python] How to judge authenticity with if statement (True and None)
How to get the date and time difference in seconds with python
How to write string concatenation in multiple lines in Python
Write tests in Python to profile and check coverage
[Python] How to sort dict in list and instance in list
Difference between return, return None, and no return description in Python
How to use argparse and the difference between optparse
How to develop in Python
How to handle JSON in Ruby, Python, JavaScript, PHP
[Note] How to write QR code and description in the same image with python
[python] How to check if the Key exists in the dictionary
[Introduction to Python] How to write conditional branches using if statements
Python module num2words Difference in behavior between English and Russian
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
How to define multiple variables in a python for statement
[Road to intermediate Python] Use if statement in list comprehension
Comparison of how to use higher-order functions in Python 2 and 3
How to write a metaclass that supports both python2 and python3
How to execute external shell scripts and commands in python
How to log in to AtCoder with Python and submit automatically
How to write a Python class
[Python] How to do PCA in Python
How to write soberly in pandas
How to collect images in Python
Difference between python2 series and python3 series dict.keys ()
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
[Python] Difference between function and method
Python --Difference between exec and eval
How to handle Japanese in Python
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)
I want to absorb the difference between the for statement on the Python + numpy matrix and the Julia for statement
[Python / Ruby] Understanding with code How to get data from online and write it to CSV
How to install OpenCV on Cloud9 and run it in Python
Repeated @ app.callback in Dash How to write Input and State neatly
How to use functions in separate files Perl and Python versions
How to write offline real time Solve E04 problems in Python
[ROS2] How to describe remap and parameter in python format launch
Difference in execution speed depending on how to write Cython function