avatarJim McAulay🍁 I'm nobody. Are you a nobody too?

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1120

Abstract

<span class="hljs-attribute">X</span> <span class="hljs-operator">=</span> input (“how many “)</pre></div><p id="21ba">Let’s try it and see what happens.</p><div id="c694"><pre><span class="hljs-attribute">X</span> <span class="hljs-operator">=</span> input (“how many “) print (x)</pre></div><p id="e17e">It works.</p><p id="80f6">Whatever number you enter is printed to the screen.</p><p id="9265">The problem is that you did not really print the number 2.</p><p id="edaa">What you printed was the symbol 2.</p><p id="b752">Print (2) is not the same as print (“2”).</p><p id="6786">Both of these commands will print what appears to be a number to the screen.</p><p id="e205">Print (2) will print an integer. That is a simple number without a decimal point.</p><p id="8d2f">Prin (“2”) will print the symbol which represents the number 2. This is called a string.</p><p id="6a51">The command input only accepts srings “2 “ or “two” or “#$@!”</p><p id="fee0">If you enter 2 from the keyboard. It can be used as the symbol 2 or the number 2 this is called <a href="https://python-intro.readthedocs.io/en/latest/polymorphi

Options

sm.html">polymorphism</a></p><p id="fa70">Let’s see what would happend when we add</p><div id="4eea"><pre>X = <span class="hljs-keyword">input</span> (“how many “) <span class="hljs-keyword">print</span> (x + x)</pre></div><p id="37d7">Surprise. You get the answer 22.</p><p id="8742">Print (“2”+”2”) would return “22”. You can add or join together strings. This is called concatenation.</p><p id="f54c">The function int will convert a string into an integer.</p><div id="cf7e"><pre>X = <span class="hljs-keyword">int</span> (<span class="hljs-keyword">input</span> (“how many “)) <span class="hljs-keyword">print</span> (x + x)</pre></div><p id="4973">The above code with give you the correct answer which is of course 4.</p><figure id="f245"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*2wNmaDbT3Z7CsDRr.png"><figcaption></figcaption></figure><h2 id="fb2a">This story is published in a Few Words, Medium’s publication that only accepts stories under 500 words.</h2><h2 id="0259">If you have a few meaningful words to say and want to be a writer in our publication, visit here.</h2></article></body>

2 + 2 = 22

source Pixaby

In the article Flip a coin

I wrote the following line of Python code.

x= int (input("How Many "))

Why not just

X = input (“how many “)

Let’s try it and see what happens.

X = input (“how many “)
print (x)

It works.

Whatever number you enter is printed to the screen.

The problem is that you did not really print the number 2.

What you printed was the symbol 2.

Print (2) is not the same as print (“2”).

Both of these commands will print what appears to be a number to the screen.

Print (2) will print an integer. That is a simple number without a decimal point.

Prin (“2”) will print the symbol which represents the number 2. This is called a string.

The command input only accepts srings “2 “ or “two” or “#$@!”

If you enter 2 from the keyboard. It can be used as the symbol 2 or the number 2 this is called polymorphism

Let’s see what would happend when we add

X = input (“how many “)
print (x + x)

Surprise. You get the answer 22.

Print (“2”+”2”) would return “22”. You can add or join together strings. This is called concatenation.

The function int will convert a string into an integer.

X = int (input (“how many “))
print (x + x)

The above code with give you the correct answer which is of course 4.

This story is published in a Few Words, Medium’s publication that only accepts stories under 500 words.

If you have a few meaningful words to say and want to be a writer in our publication, visit here.

Programming
Python
Jims Python
Recommended from ReadMedium