{"id":3825,"date":"2021-04-12T07:10:57","date_gmt":"2021-04-12T06:10:57","guid":{"rendered":"https:\/\/blog.guvi.in\/?p=3825"},"modified":"2026-01-08T17:12:58","modified_gmt":"2026-01-08T11:42:58","slug":"how-can-i-read-input-as-numbersthe-easy-guide","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/how-can-i-read-input-as-numbersthe-easy-guide\/","title":{"rendered":"Python-How To Read Input As Numbers?[The Easy Guide]"},"content":{"rendered":"\n<p>How can I read input as numbers? Is this what is pondering you?<\/p>\n\n\n\n<p>You might be wondering how developers often interact with the users. Well, it is possible with the use of&nbsp;<strong><em>the input function.&nbsp;<\/em><\/strong>Most importantly, the prime purpose of using the inputs is to get data from the users or give them.&nbsp;<\/p>\n\n\n\n<p>Nowadays, several programs have dialog boxes to ask the users to provide similar or distant inputs. In Python 2, there are two different kinds of in-built functions. These functions help in reading input given by the user using keywords.<\/p>\n\n\n\n<p>Below, we have provided all the necessary details to answer your question-&nbsp;<strong>how can I read input as numbers<\/strong>. Moreover, we have provided valuable examples that help you understand each concept of the input function.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"480\" height=\"270\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2023\/09\/Ive-got-this-gif.gif\" alt=\"gif - how to read input as numbers in python\" class=\"wp-image-25011\" title=\"\"><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>What are the two different types of Input in Python 2.x?<\/strong><\/h3>\n\n\n\n<ul>\n<li><strong>input( ):<\/strong>&nbsp;Initially, it will take the information from the user. The next step will evaluate the expression (here, Python automatically identifies the input value as a string or list, or a number).&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>That is to say if the user&#8217;s input is incorrect, it will either show a syntax error or an exception in Python. For instance\u2013<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/xt51EMNewkHJw_ohopLWUV3pVd_YBqdk6M3hzGvJmhB-iLQhzYtXjc-jNJXSPjn6JWZiPV5pAVOpHqtUAHyTQel6Yvy9P_ant5sjt9CsG_xD_07zQzR-AVBpjnoktcYi_ymen3E\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter your name:<\/strong><\/p>\n\n\n\n<p><strong>123<\/strong><\/p>\n\n\n\n<p><strong>Hello 123<\/strong><\/p>\n<\/div><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft is-resized\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/GNHNYKcjyPz9ZZ3o5Bmis7th888NF4gGUTYJEg2tlP1w_MwShZ7mo5mvpi3zpGXav-pZ-JWN3AisEBzt5w7BWgKbRlboUCwuL9ARwmkWaAoHkSN49I-zm-zwer-DyF_A90UWjwc\" alt=\"\" style=\"width:823px;height:181px\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter number:123<\/strong><\/p>\n\n\n\n<p><strong>123<\/strong><\/p>\n<\/div><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/u06WGB1lj1LbUdh-iqyl7yNilt7jr7AEaymjKTVXHH1kCiA5ApzuH8QppC35zkzohgrfIUUlbXlNDJMMgzxxTI-83Rk2NDKm2y4EgTd1oC55dWBo9aDjDOruRR7WWn8xTS-0cIE\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>To print \u2018type\u2019 of the input value<\/strong><\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/j3hye3ayHQvcIzPYoifqjeLGODKvDOhlqvuYa_3OKoO3D6hyf41S_dPlb5wC0xYHZMa1iRMjPEeGkN5_jw9Q53cm_4PAyMAevnBYaAYLmHK1pTsnU7iqX9D-AYdMIxL7ZoBda9s\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>type of number &lt;class &#8216;str&#8217;&gt;<\/strong><\/p>\n\n\n\n<p><strong>type of name &lt;class &#8216;str&#8217;&gt;<\/strong><\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<ul>\n<li><strong>raw_input ( ):<\/strong> It takes what exactly is typed by the user from the keyboard. It converts to string and then returns the value to the variable as we like to store. For instance \u2013<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/B6Bh7cjxJKXrMjQgKwqPsrXuhFT-nTTFwM00wdP5yqzbNYd19N_liYZtnpOWhqL8aekXTXH0acdt72MIYYn3zccp70gVE8IphivUqlMv40Bo2lQ6MG4T9xa05_b_h44jvyMKZvo\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter input to test raw_input() function:0<\/strong><\/p>\n\n\n\n<p><strong>&lt;type &#8216;str&#8217;&gt;<\/strong><\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How can I read input as numbers in Python 3?<\/strong><\/h3>\n\n\n\n<p>To sum up, the key point to remember is a small difference between Python 2 input and Python 3 input. In Python 2, the input() function automatically evaluates the input data and converts it into an integer.&nbsp;<\/p>\n\n\n\n<p>However, in the case of Python 3, the input() function does <strong><em>not <\/em><\/strong>evaluate the user input. This means that Python 2&#8217;s raw_input() is <strong><em>equivalent <\/em><\/strong>to the Python3 input()_ function.<\/p>\n\n\n\n<p>So, let&#8217;s understand it with the help of an example:<\/p>\n\n\n\n<p><strong>Python 2 input() function<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/B6Bh7cjxJKXrMjQgKwqPsrXuhFT-nTTFwM00wdP5yqzbNYd19N_liYZtnpOWhqL8aekXTXH0acdt72MIYYn3zccp70gVE8IphivUqlMv40Bo2lQ6MG4T9xa05_b_h44jvyMKZvo\" alt=\"This image has an empty alt attribute; its file name is B6Bh7cjxJKXrMjQgKwqPsrXuhFT-nTTFwM00wdP5yqzbNYd19N_liYZtnpOWhqL8aekXTXH0acdt72MIYYn3zccp70gVE8IphivUqlMv40Bo2lQ6MG4T9xa05_b_h44jvyMKZvo\" title=\"\"><\/figure><\/div>\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter a number: 5&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>(5, &lt;type &#8216;int&#8217;&gt;)<\/strong><\/p>\n<\/div><\/div>\n\n\n\n<p><strong>Python 2 raw_input() function<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/wNP-mxloOhdrG0T9DwwJeu41qtpxpBHMgH_IsdZ9zgbh0OaiOamruu5olBcpQm4ECAXtiitn8ijezJMj1api-o-uKj3i8B_Vj97uU542vWVZiw5QcEqve2UGwSLjuRj4LpLqAmA\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter a number: 5&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>(5, &lt;type \u2018str\u2019&gt;)<\/strong><\/p>\n<\/div><\/div>\n\n\n\n<p><strong>NOTE: <\/strong>Here, you will notice that the input() function will show the data type like <strong><em>int, <\/em><\/strong>whereas the raw_input() shows the same data type as <strong><em>str. <\/em><\/strong>That is to say that raw_input does not evaluate the function and read it as it is.<\/p>\n\n\n\n<p><strong>Python 3 input() function<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/nCGdOUdapxkIdPtwXy83UAcO_DRyYzZJqTqPFB5Gf8kAj1KcL140FcSM6aGfe-ABx8-nWjjlQMHOD3BiEHwHJCuoGt2RgbFRGah4JLLL6Jh5WX-dq7XGrKbd0EOtXSfOSXMhkh0\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter a number: 5&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>(5, &lt;type \u2018str\u2019&gt;)<\/strong><\/p>\n<\/div><\/div>\n\n\n\n<p><strong>NOTE: <\/strong>Remember that the raw_input() function is not available in Python 3.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Does it mean that Python 3 does not identify the input data type?<\/strong><\/h3>\n\n\n\n<p>No, it doesn&#8217;t mean that! As we have already mentioned that the raw_input does not exist in Python 3. So, the older raw_input() is replaced with the input(), and the older input is replaced.&nbsp;<\/p>\n\n\n\n<p>Do not worry; the input data type can be evaluated by <strong><em>eval(input()) <\/em><\/strong>function. However, beware of the use of the eval() function. Let&#8217;s take an example of how to use the eval() function.<\/p>\n\n\n\n<p><strong>eval(input()) function<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/ZaRXsvlJ3LoVUVZohzMDHP8IGuICZa-WBO7Evlrpupkwr-ZqQMtLlvVZPv9opCuVRMj-gEj-sFgsheCucXUXB83khmBIAuluUlq_NPGHr8RMCURYLTqCOpX10CINBnEzKe3U8-w\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter a number: 5&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>(5, &lt;type \u2018int\u2019&gt;)<\/strong><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Can I put floating numbers rather than an integer in Python?<\/strong><\/h3>\n\n\n\n<p>Yes, you can! In short, to provide the floating values to the Python program, you need to write <strong><em>float <\/em><\/strong>instead of <strong><em>int <\/em><\/strong>function. Let us understand how the float function works with an easy example:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/WqxlWXEvbX3d933yftI7cVMKBKwU4g8Ko3xDeN2TF_WBqlyojMY82z468WC7ocCSFMHt50lPrypW0ikwA0BI99ioJvQ6DIxmyIJU4u_VjF6E7t8hjcYFc_qDj391onV1lwxGBm0\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>Enter a number:1.5<\/strong><\/p>\n\n\n\n<p><strong>(1.5, &lt;type &#8216;float&#8217;&gt;)<\/strong><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Can I put multiple integer or string input values in Python?<\/strong><\/h3>\n\n\n\n<p>Yes, you can do it easily using the <strong><em>split() <\/em><\/strong>function. Moreover, the user can put a split() function to divide the input value with &#8216;,&#8217;. Let&#8217;s understand it with the help of an example.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/tQsy0iktXtEteRdeUwjoJfwA_P-nOxkNTLUBNh1vuTNTncYhfREWakEnAIH9SeGOGoZPVNOTsJ5AXC3SynyUCKIa1hBfbt_yAGNDh_zlOrMJpIKCpKLW8-o02vr4gEeBLWdYR4Q\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#358535\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p><strong>#take the input from the user<\/strong><\/p>\n\n\n\n<p><strong>Enter multiple names<\/strong>&nbsp;<\/p>\n\n\n\n<p><strong>space-separated:- \u20181 2\u2019<\/strong><\/p>\n\n\n\n<p><strong>Enter multiple names&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>space-separated:- [&#8216;1&#8217;, &#8216;2&#8217;]<\/strong><\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p><strong>NOTE<\/strong>: Also, you can convert each input to the integer value using the <strong><em>map <\/em><\/strong>and <strong><em>int <\/em><\/strong>value function. How? Check the below section.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Is it possible to split the string into the list of integers in Python?<\/strong><\/h3>\n\n\n\n<p>Yes, it is possible with the help of <strong><em>str.split() <\/em><\/strong>and <strong><em>map() <\/em><\/strong>function. Call str.split() to represent each number. Then use map(func, lis) to create the map objects. Finally, use list(mapping) to change mapping. This is how you can create a map to the list.<\/p>\n\n\n\n<p>Let&#8217;s take an example of it:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/7fUU4prZmnhLSjeyen-hPupYdgpqr7HIQB3iCkQaKvAv1A-1c2XNvP8zm0Uy5f-JHrqZOQ7bhaEyTT3p5wGStji4FmatWF0yMeyPjo9DuXCJZrB73ldUmWjZ3bOCB0t3PZZ4Hxw\" alt=\"\" title=\"\"><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#06ac30\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-text-color is-layout-flow wp-block-group-is-layout-flow\" style=\"color:#32dc32\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:#32cd32\"><strong># split the data and convert each string number to int<\/strong><\/p>\n\n\n\n<p><strong>\u20181 2\u2019<\/strong><\/p>\n\n\n\n<p><strong># print the data<\/strong><\/p>\n\n\n\n<p><strong>Enter multiple numbers:- [1, 2]<\/strong><\/p>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h3>\n\n\n\n<p>Finally, it has been noticed that each program requires data from the user. And, the user can provide the data from the keyboard. But it is always necessary that the program must understand each input data type on its own. That is why users can use <strong><em>input() <\/em><\/strong>function in <strong>Python 2 <\/strong>and <strong><em>eval(raw_input())<\/em><\/strong> function in <strong>Python 3<\/strong>.<\/p>\n\n\n\n<p>Above, we have provided enough examples that help you to understand how can I read input as numbers. If you still have any queries with your <a href=\"https:\/\/www.guvi.in\/blog\/do-you-know-how-to-create-variables-in-python\/\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/blog\/do-you-know-how-to-create-variables-in-python\/\">Python program<\/a>, you can comment on it in the comment section. We will try our best to help you with your Python programs. Hope you like the blog; if you find it worthy, don&#8217;t forget to share it with the future Python geeks.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>\u201c<a href=\"https:\/\/www.guvi.in\/courses\/programming\/python\/\">Master Python with ease, with HCL GUVI<\/a>\u00a0.\u201d<\/em><\/strong><\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<h3 class=\"wp-block-heading\"><strong>Multiple Choice Questions: Test what you have studied in this blog!&nbsp;<\/strong><\/h3>\n\n\n\n<div class=\"wp-block-group has-very-light-gray-to-cyan-bluish-gray-gradient-background has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p><strong>1. Anything that you enter as input in Python3, the input() function changes it to a string.&nbsp;<\/strong><\/p>\n\n\n\n<p>(A) True&nbsp;<\/p>\n\n\n\n<p>(B) False<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Correct Answer: (A). We have discussed that raw_input() of Python 2 and input() of Python 3 is equivalent to each other. Therefore, it takes all input as a string.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-group has-very-light-gray-to-cyan-bluish-gray-gradient-background has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p><strong>2. Which function is used in Python3 to accept input values from a user?&nbsp;<\/strong><\/p>\n\n\n\n<p>(A) raw_input()&nbsp;<\/p>\n\n\n\n<p>(B) string()&nbsp;<\/p>\n\n\n\n<p>(C) input()&nbsp;<\/p>\n\n\n\n<p>(D) rawinput()&nbsp;<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Correct Answer: (C) In Python3, the user uses the input() function to accept the user&#8217;s values.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-group has-very-light-gray-to-cyan-bluish-gray-gradient-background has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p><strong>3. What would be the output of the given code :&nbsp;<\/strong><\/p>\n\n\n\n<p><strong><em>print type(type(int))&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p>(A) Error&nbsp;<\/p>\n\n\n\n<p>(B) 0&nbsp;<\/p>\n\n\n\n<p>(C) type &#8216;int&#8217;&nbsp;<\/p>\n\n\n\n<p>(D) type &#8216;type&#8217;&nbsp;<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Correct Answer: (D) The type() function will give the argument&#8217;s class to which the object belongs. Hence, type(int) will give the value of the type &#8216;type&#8217; object.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-group has-very-light-gray-to-cyan-bluish-gray-gradient-background has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p><strong>4. What is the output of:&nbsp;<\/strong><\/p>\n\n\n\n<p>num1 = int(input(&#8220;Enter first number &#8220;))&nbsp;<\/p>\n\n\n\n<p>num2 = int(input(&#8220;Enter second number &#8220;))&nbsp;<\/p>\n\n\n\n<p>res = num1 + num2&nbsp;<\/p>\n\n\n\n<p>print(&#8220;Sum is&#8221;, res)&nbsp;<\/p>\n\n\n\n<p>print (type(res))&nbsp;<\/p>\n\n\n\n<p><strong><em>[input: num1 =5, num2 = 2]&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p>(A) Sum is 7 &lt;class &#8216;int&#8217;&gt;&nbsp;<\/p>\n\n\n\n<p>(B) Sum is 7 &lt;class &#8216;str&#8217;&gt;<\/p>\n\n\n\n<p>(C) Error&nbsp;<\/p>\n\n\n\n<p>(D) res is undefined&nbsp;<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Correct Answer: (A) The addition of 5 +2 (that is num1 + num2) = 7. Moreover, the defined input is of integer type; therefore, the output will be class &#8216;int&#8217;.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-group has-very-light-gray-to-cyan-bluish-gray-gradient-background has-background is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p><strong>5. What is the output of:&nbsp;<\/strong><\/p>\n\n\n\n<p>str = input(&#8220;Enter multiple names:- &#8220;)&nbsp;<\/p>\n\n\n\n<p>str = str.split()&nbsp;<\/p>\n\n\n\n<p>print(str)&nbsp;<\/p>\n\n\n\n<p><strong><em>[Input: &#8216;John Emma&#8217;]&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p>(A) Error&nbsp;<\/p>\n\n\n\n<p>(B) 0&nbsp;<\/p>\n\n\n\n<p>(C) [&#8216;John&#8217;, &#8216;Emma&#8217;]&nbsp;<\/p>\n\n\n\n<p>(D) Undefined value<\/p>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Correct Answer: (C) The split function is used to change the string into the list.<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>How can I read input as numbers? Is this what is pondering you? You might be wondering how developers often interact with the users. Well, it is possible with the use of&nbsp;the input function.&nbsp;Most importantly, the prime purpose of using the inputs is to get data from the users or give them.&nbsp; Nowadays, several programs [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":3842,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,717],"tags":[],"views":"5276","authorinfo":{"name":"Archana","url":"https:\/\/www.guvi.in\/blog\/author\/archana\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2021\/04\/WhatsApp-Image-2021-04-12-at-09.10.02-300x150.jpeg","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/3825"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=3825"}],"version-history":[{"count":55,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/3825\/revisions"}],"predecessor-version":[{"id":98657,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/3825\/revisions\/98657"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/3842"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=3825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=3825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=3825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}