<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>itlabo</author_name>
  <author_url>https://blog.hatena.ne.jp/itlabo/</author_url>
  <blog_title>フロントエンドエンジニアのスターティングノート</blog_title>
  <blog_url>https://www.flavor-of-life.com/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>はじめに Pythonでif文を書いていると単純なコードなのに長いコードになることがあります。 単純なコードは三項演算子にして視認性の良いコードを書いてみませんか？ 三項演算子を使って奇数、偶数を判定する 例として三項演算子を使って奇数、偶数を判定するプログラムをPythonで書いてみましょう。 x = 1 y = '偶数' if x % 2 == 0 else '奇数' print(y) // 奇数 x = 2 y = '偶数' if x % 2 == 0 else '奇数' print(y) // 偶数 とても短くifを書くことができました。 このPythonのプログラムの意味は下記です。…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.flavor-of-life.com%2Fentry%2Fhow_to_python_ternary_operator&quot; title=&quot;【Python】三項演算子を使って奇数、偶数を判定する - フロントエンドエンジニアのスターティングノート&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2024-03-26 00:00:00</published>
  <title>【Python】三項演算子を使って奇数、偶数を判定する</title>
  <type>rich</type>
  <url>https://www.flavor-of-life.com/entry/how_to_python_ternary_operator</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
