[{"data":1,"prerenderedAt":2205},["ShallowReactive",2],{"doc-\u002Fexamples\u002Fpython-simple-calculator-example":3},{"id":4,"title":5,"body":6,"description":2198,"extension":2199,"meta":2200,"navigation":156,"path":2201,"seo":2202,"stem":2203,"__hash__":2204},"content\u002Fexamples\u002Fpython-simple-calculator-example.md","Python Simple Calculator Example",{"type":7,"value":8,"toc":2159},"minimark",[9,13,17,51,54,363,366,371,374,422,426,429,446,450,453,520,528,535,552,564,567,609,612,638,641,682,684,704,715,719,722,867,874,906,912,929,933,936,942,1009,1012,1015,1036,1047,1051,1054,1296,1300,1326,1330,1333,1337,1400,1404,1459,1463,1517,1521,1576,1580,1583,1586,1613,1616,1759,1762,1766,1769,1783,1792,1796,1799,1806,1812,1815,1870,1880,1889,1892,1904,1906,1941,1947,1950,1985,1989,1999,2003,2006,2024,2029,2033,2042,2046,2054,2066,2073,2083,2087,2093,2097,2104,2108,2152,2155],[10,11,5],"h1",{"id":12},"python-simple-calculator-example",[14,15,16],"p",{},"A simple calculator is a great beginner Python project. It helps you practice several important basics in one small script:",[18,19,20,24,27,30,45,48],"ul",{},[21,22,23],"li",{},"getting user input",[21,25,26],{},"storing values in variables",[21,28,29],{},"converting text to numbers",[21,31,32,33,37,38,41,42],{},"using ",[34,35,36],"code",{},"if",", ",[34,39,40],{},"elif",", and ",[34,43,44],{},"else",[21,46,47],{},"doing basic math",[21,49,50],{},"handling simple errors",[14,52,53],{},"In this example, you will build a calculator that asks for two numbers and an operator, then prints the result.",[55,56,61],"pre",{"className":57,"code":58,"language":59,"meta":60,"style":60},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","num1 = float(input(\"Enter first number: \"))\noperator = input(\"Enter operator (+, -, *, \u002F): \")\nnum2 = float(input(\"Enter second number: \"))\n\nif operator == \"+\":\n    print(num1 + num2)\nelif operator == \"-\":\n    print(num1 - num2)\nelif operator == \"*\":\n    print(num1 * num2)\nelif operator == \"\u002F\":\n    if num2 == 0:\n        print(\"Cannot divide by zero\")\n    else:\n        print(num1 \u002F num2)\nelse:\n    print(\"Invalid operator\")\n","python","",[34,62,63,103,126,151,158,181,199,217,232,250,265,283,300,317,325,340,347],{"__ignoreMap":60},[64,65,68,72,76,80,84,88,90,94,98,100],"span",{"class":66,"line":67},"line",1,[64,69,71],{"class":70},"su5hD","num1 ",[64,73,75],{"class":74},"smGrS","=",[64,77,79],{"class":78},"sZMiF"," float",[64,81,83],{"class":82},"sP7_E","(",[64,85,87],{"class":86},"sptTA","input",[64,89,83],{"class":82},[64,91,93],{"class":92},"sjJ54","\"",[64,95,97],{"class":96},"s_sjI","Enter first number: ",[64,99,93],{"class":92},[64,101,102],{"class":82},"))\n",[64,104,106,109,111,114,116,118,121,123],{"class":66,"line":105},2,[64,107,108],{"class":70},"operator ",[64,110,75],{"class":74},[64,112,113],{"class":86}," input",[64,115,83],{"class":82},[64,117,93],{"class":92},[64,119,120],{"class":96},"Enter operator (+, -, *, \u002F): ",[64,122,93],{"class":92},[64,124,125],{"class":82},")\n",[64,127,129,132,134,136,138,140,142,144,147,149],{"class":66,"line":128},3,[64,130,131],{"class":70},"num2 ",[64,133,75],{"class":74},[64,135,79],{"class":78},[64,137,83],{"class":82},[64,139,87],{"class":86},[64,141,83],{"class":82},[64,143,93],{"class":92},[64,145,146],{"class":96},"Enter second number: ",[64,148,93],{"class":92},[64,150,102],{"class":82},[64,152,154],{"class":66,"line":153},4,[64,155,157],{"emptyLinePlaceholder":156},true,"\n",[64,159,161,164,167,170,173,176,178],{"class":66,"line":160},5,[64,162,36],{"class":163},"sVHd0",[64,165,166],{"class":70}," operator ",[64,168,169],{"class":74},"==",[64,171,172],{"class":92}," \"",[64,174,175],{"class":96},"+",[64,177,93],{"class":92},[64,179,180],{"class":82},":\n",[64,182,184,187,189,192,194,197],{"class":66,"line":183},6,[64,185,186],{"class":86},"    print",[64,188,83],{"class":82},[64,190,71],{"class":191},"slqww",[64,193,175],{"class":74},[64,195,196],{"class":191}," num2",[64,198,125],{"class":82},[64,200,202,204,206,208,210,213,215],{"class":66,"line":201},7,[64,203,40],{"class":163},[64,205,166],{"class":70},[64,207,169],{"class":74},[64,209,172],{"class":92},[64,211,212],{"class":96},"-",[64,214,93],{"class":92},[64,216,180],{"class":82},[64,218,220,222,224,226,228,230],{"class":66,"line":219},8,[64,221,186],{"class":86},[64,223,83],{"class":82},[64,225,71],{"class":191},[64,227,212],{"class":74},[64,229,196],{"class":191},[64,231,125],{"class":82},[64,233,235,237,239,241,243,246,248],{"class":66,"line":234},9,[64,236,40],{"class":163},[64,238,166],{"class":70},[64,240,169],{"class":74},[64,242,172],{"class":92},[64,244,245],{"class":96},"*",[64,247,93],{"class":92},[64,249,180],{"class":82},[64,251,253,255,257,259,261,263],{"class":66,"line":252},10,[64,254,186],{"class":86},[64,256,83],{"class":82},[64,258,71],{"class":191},[64,260,245],{"class":74},[64,262,196],{"class":191},[64,264,125],{"class":82},[64,266,268,270,272,274,276,279,281],{"class":66,"line":267},11,[64,269,40],{"class":163},[64,271,166],{"class":70},[64,273,169],{"class":74},[64,275,172],{"class":92},[64,277,278],{"class":96},"\u002F",[64,280,93],{"class":92},[64,282,180],{"class":82},[64,284,286,289,292,294,298],{"class":66,"line":285},12,[64,287,288],{"class":163},"    if",[64,290,291],{"class":70}," num2 ",[64,293,169],{"class":74},[64,295,297],{"class":296},"srdBf"," 0",[64,299,180],{"class":82},[64,301,303,306,308,310,313,315],{"class":66,"line":302},13,[64,304,305],{"class":86},"        print",[64,307,83],{"class":82},[64,309,93],{"class":92},[64,311,312],{"class":96},"Cannot divide by zero",[64,314,93],{"class":92},[64,316,125],{"class":82},[64,318,320,323],{"class":66,"line":319},14,[64,321,322],{"class":163},"    else",[64,324,180],{"class":82},[64,326,328,330,332,334,336,338],{"class":66,"line":327},15,[64,329,305],{"class":86},[64,331,83],{"class":82},[64,333,71],{"class":191},[64,335,278],{"class":74},[64,337,196],{"class":191},[64,339,125],{"class":82},[64,341,343,345],{"class":66,"line":342},16,[64,344,44],{"class":163},[64,346,180],{"class":82},[64,348,350,352,354,356,359,361],{"class":66,"line":349},17,[64,351,186],{"class":86},[64,353,83],{"class":82},[64,355,93],{"class":92},[64,357,358],{"class":96},"Invalid operator",[64,360,93],{"class":92},[64,362,125],{"class":82},[14,364,365],{},"Use this as the main working example. The rest of the page explains each part step by step.",[367,368,370],"h2",{"id":369},"what-this-example-teaches","What this example teaches",[14,372,373],{},"This small project shows you how to:",[18,375,376,386,395,407,419],{},[21,377,378,379],{},"get values from the user with ",[380,381,383],"a",{"href":382},"\u002Freference\u002Fpython-input-function-explained\u002F",[34,384,385],{},"input()",[21,387,388,389],{},"convert text input into numbers with ",[380,390,392],{"href":391},"\u002Freference\u002Fpython-float-function-explained\u002F",[34,393,394],{},"float()",[21,396,397,398],{},"choose an action with ",[380,399,401,37,403,41,405],{"href":400},"\u002Flearn\u002Fpython-if-else-and-elif-explained\u002F",[34,402,36],{},[34,404,40],{},[34,406,44],{},[21,408,409,410,37,412,37,414,41,416,418],{},"perform ",[34,411,175],{},[34,413,212],{},[34,415,245],{},[34,417,278],{}," operations",[21,420,421],{},"handle invalid operators and division by zero",[367,423,425],{"id":424},"what-the-calculator-should-do","What the calculator should do",[14,427,428],{},"The calculator should:",[18,430,431,434,437,440,443],{},[21,432,433],{},"ask for the first number",[21,435,436],{},"ask for the operator",[21,438,439],{},"ask for the second number",[21,441,442],{},"run the correct math operation",[21,444,445],{},"print the result or a clear error message",[367,447,449],{"id":448},"step-1-read-user-input","Step 1: Read user input",[14,451,452],{},"The first part of the program gets values from the user.",[55,454,456],{"className":57,"code":455,"language":59,"meta":60,"style":60},"num1 = float(input(\"Enter first number: \"))\noperator = input(\"Enter operator (+, -, *, \u002F): \")\nnum2 = float(input(\"Enter second number: \"))\n",[34,457,458,480,498],{"__ignoreMap":60},[64,459,460,462,464,466,468,470,472,474,476,478],{"class":66,"line":67},[64,461,71],{"class":70},[64,463,75],{"class":74},[64,465,79],{"class":78},[64,467,83],{"class":82},[64,469,87],{"class":86},[64,471,83],{"class":82},[64,473,93],{"class":92},[64,475,97],{"class":96},[64,477,93],{"class":92},[64,479,102],{"class":82},[64,481,482,484,486,488,490,492,494,496],{"class":66,"line":105},[64,483,108],{"class":70},[64,485,75],{"class":74},[64,487,113],{"class":86},[64,489,83],{"class":82},[64,491,93],{"class":92},[64,493,120],{"class":96},[64,495,93],{"class":92},[64,497,125],{"class":82},[64,499,500,502,504,506,508,510,512,514,516,518],{"class":66,"line":128},[64,501,131],{"class":70},[64,503,75],{"class":74},[64,505,79],{"class":78},[64,507,83],{"class":82},[64,509,87],{"class":86},[64,511,83],{"class":82},[64,513,93],{"class":92},[64,515,146],{"class":96},[64,517,93],{"class":92},[64,519,102],{"class":82},[521,522,524,525,527],"h3",{"id":523},"important-idea-input-always-returns-text","Important idea: ",[34,526,385],{}," always returns text",[14,529,530,531,534],{},"Even if the user types ",[34,532,533],{},"12",", Python reads it as a string, not a number.",[14,536,537,538,540,541,543,544,547,548,551],{},"That is why the code uses ",[34,539,394],{}," around the ",[34,542,385],{}," calls for ",[34,545,546],{},"num1"," and ",[34,549,550],{},"num2",".",[18,553,554,559],{},[21,555,556,558],{},[34,557,385],{}," gets the user's typed value",[21,560,561,563],{},[34,562,394],{}," converts that text into a number with decimals",[14,565,566],{},"For example:",[55,568,570],{"className":57,"code":569,"language":59,"meta":60,"style":60},"value = input(\"Enter a number: \")\nprint(type(value))\n",[34,571,572,592],{"__ignoreMap":60},[64,573,574,577,579,581,583,585,588,590],{"class":66,"line":67},[64,575,576],{"class":70},"value ",[64,578,75],{"class":74},[64,580,113],{"class":86},[64,582,83],{"class":82},[64,584,93],{"class":92},[64,586,587],{"class":96},"Enter a number: ",[64,589,93],{"class":92},[64,591,125],{"class":82},[64,593,594,597,599,602,604,607],{"class":66,"line":105},[64,595,596],{"class":86},"print",[64,598,83],{"class":82},[64,600,601],{"class":78},"type",[64,603,83],{"class":82},[64,605,606],{"class":191},"value",[64,608,102],{"class":82},[14,610,611],{},"Output:",[55,613,615],{"className":57,"code":614,"language":59,"meta":60,"style":60},"\u003Cclass 'str'>\n",[34,616,617],{"__ignoreMap":60},[64,618,619,622,626,629,632,635],{"class":66,"line":67},[64,620,621],{"class":74},"\u003C",[64,623,625],{"class":624},"sbsja","class",[64,627,628],{"class":92}," '",[64,630,631],{"class":96},"str",[64,633,634],{"class":92},"'",[64,636,637],{"class":74},">\n",[14,639,640],{},"After conversion:",[55,642,644],{"className":57,"code":643,"language":59,"meta":60,"style":60},"value = float(input(\"Enter a number: \"))\nprint(type(value))\n",[34,645,646,668],{"__ignoreMap":60},[64,647,648,650,652,654,656,658,660,662,664,666],{"class":66,"line":67},[64,649,576],{"class":70},[64,651,75],{"class":74},[64,653,79],{"class":78},[64,655,83],{"class":82},[64,657,87],{"class":86},[64,659,83],{"class":82},[64,661,93],{"class":92},[64,663,587],{"class":96},[64,665,93],{"class":92},[64,667,102],{"class":82},[64,669,670,672,674,676,678,680],{"class":66,"line":105},[64,671,596],{"class":86},[64,673,83],{"class":82},[64,675,601],{"class":78},[64,677,83],{"class":82},[64,679,606],{"class":191},[64,681,102],{"class":82},[14,683,611],{},[55,685,687],{"className":57,"code":686,"language":59,"meta":60,"style":60},"\u003Cclass 'float'>\n",[34,688,689],{"__ignoreMap":60},[64,690,691,693,695,697,700,702],{"class":66,"line":67},[64,692,621],{"class":74},[64,694,625],{"class":624},[64,696,628],{"class":92},[64,698,699],{"class":96},"float",[64,701,634],{"class":92},[64,703,637],{"class":74},[14,705,706,707,547,711,551],{},"If you want more practice with this, see ",[380,708,710],{"href":709},"\u002Fhow-to\u002Fhow-to-get-user-input-in-python\u002F","how to get user input in Python",[380,712,714],{"href":713},"\u002Fhow-to\u002Fhow-to-convert-user-input-to-numbers-in-python\u002F","how to convert user input to numbers in Python",[367,716,718],{"id":717},"step-2-check-the-operator","Step 2: Check the operator",[14,720,721],{},"Next, the program checks which operator the user typed.",[55,723,725],{"className":57,"code":724,"language":59,"meta":60,"style":60},"if operator == \"+\":\n    print(num1 + num2)\nelif operator == \"-\":\n    print(num1 - num2)\nelif operator == \"*\":\n    print(num1 * num2)\nelif operator == \"\u002F\":\n    print(num1 \u002F num2)\nelse:\n    print(\"Invalid operator\")\n",[34,726,727,743,757,773,787,803,817,833,847,853],{"__ignoreMap":60},[64,728,729,731,733,735,737,739,741],{"class":66,"line":67},[64,730,36],{"class":163},[64,732,166],{"class":70},[64,734,169],{"class":74},[64,736,172],{"class":92},[64,738,175],{"class":96},[64,740,93],{"class":92},[64,742,180],{"class":82},[64,744,745,747,749,751,753,755],{"class":66,"line":105},[64,746,186],{"class":86},[64,748,83],{"class":82},[64,750,71],{"class":191},[64,752,175],{"class":74},[64,754,196],{"class":191},[64,756,125],{"class":82},[64,758,759,761,763,765,767,769,771],{"class":66,"line":128},[64,760,40],{"class":163},[64,762,166],{"class":70},[64,764,169],{"class":74},[64,766,172],{"class":92},[64,768,212],{"class":96},[64,770,93],{"class":92},[64,772,180],{"class":82},[64,774,775,777,779,781,783,785],{"class":66,"line":153},[64,776,186],{"class":86},[64,778,83],{"class":82},[64,780,71],{"class":191},[64,782,212],{"class":74},[64,784,196],{"class":191},[64,786,125],{"class":82},[64,788,789,791,793,795,797,799,801],{"class":66,"line":160},[64,790,40],{"class":163},[64,792,166],{"class":70},[64,794,169],{"class":74},[64,796,172],{"class":92},[64,798,245],{"class":96},[64,800,93],{"class":92},[64,802,180],{"class":82},[64,804,805,807,809,811,813,815],{"class":66,"line":183},[64,806,186],{"class":86},[64,808,83],{"class":82},[64,810,71],{"class":191},[64,812,245],{"class":74},[64,814,196],{"class":191},[64,816,125],{"class":82},[64,818,819,821,823,825,827,829,831],{"class":66,"line":201},[64,820,40],{"class":163},[64,822,166],{"class":70},[64,824,169],{"class":74},[64,826,172],{"class":92},[64,828,278],{"class":96},[64,830,93],{"class":92},[64,832,180],{"class":82},[64,834,835,837,839,841,843,845],{"class":66,"line":219},[64,836,186],{"class":86},[64,838,83],{"class":82},[64,840,71],{"class":191},[64,842,278],{"class":74},[64,844,196],{"class":191},[64,846,125],{"class":82},[64,848,849,851],{"class":66,"line":234},[64,850,44],{"class":163},[64,852,180],{"class":82},[64,854,855,857,859,861,863,865],{"class":66,"line":252},[64,856,186],{"class":86},[64,858,83],{"class":82},[64,860,93],{"class":92},[64,862,358],{"class":96},[64,864,93],{"class":92},[64,866,125],{"class":82},[14,868,869,870,873],{},"This works by comparing the ",[34,871,872],{},"operator"," variable to different strings.",[18,875,876,883,889,895,901],{},[21,877,878,879,882],{},"if the user enters ",[34,880,881],{},"\"+\"",", the program adds",[21,884,878,885,888],{},[34,886,887],{},"\"-\"",", the program subtracts",[21,890,878,891,894],{},[34,892,893],{},"\"*\"",", the program multiplies",[21,896,878,897,900],{},[34,898,899],{},"\"\u002F\"",", the program divides",[21,902,903,904],{},"anything else goes to ",[34,905,44],{},[14,907,908,909,911],{},"The ",[34,910,44],{}," part is useful for unsupported input such as:",[18,913,914,919,924],{},[21,915,916],{},[34,917,918],{},"%",[21,920,921],{},[34,922,923],{},"?",[21,925,926],{},[34,927,928],{},"add",[367,930,932],{"id":931},"step-3-handle-division-safely","Step 3: Handle division safely",[14,934,935],{},"Division needs one extra check.",[14,937,938,939,941],{},"If you try to divide by zero, Python raises an error. To avoid that, check ",[34,940,550],{}," before dividing.",[55,943,945],{"className":57,"code":944,"language":59,"meta":60,"style":60},"elif operator == \"\u002F\":\n    if num2 == 0:\n        print(\"Cannot divide by zero\")\n    else:\n        print(num1 \u002F num2)\n",[34,946,947,963,975,989,995],{"__ignoreMap":60},[64,948,949,951,953,955,957,959,961],{"class":66,"line":67},[64,950,40],{"class":163},[64,952,166],{"class":70},[64,954,169],{"class":74},[64,956,172],{"class":92},[64,958,278],{"class":96},[64,960,93],{"class":92},[64,962,180],{"class":82},[64,964,965,967,969,971,973],{"class":66,"line":105},[64,966,288],{"class":163},[64,968,291],{"class":70},[64,970,169],{"class":74},[64,972,297],{"class":296},[64,974,180],{"class":82},[64,976,977,979,981,983,985,987],{"class":66,"line":128},[64,978,305],{"class":86},[64,980,83],{"class":82},[64,982,93],{"class":92},[64,984,312],{"class":96},[64,986,93],{"class":92},[64,988,125],{"class":82},[64,990,991,993],{"class":66,"line":153},[64,992,322],{"class":163},[64,994,180],{"class":82},[64,996,997,999,1001,1003,1005,1007],{"class":66,"line":160},[64,998,305],{"class":86},[64,1000,83],{"class":82},[64,1002,71],{"class":191},[64,1004,278],{"class":74},[64,1006,196],{"class":191},[64,1008,125],{"class":82},[14,1010,1011],{},"This makes the program friendlier for beginners and users.",[14,1013,1014],{},"Without the check, code like this would fail:",[55,1016,1018],{"className":57,"code":1017,"language":59,"meta":60,"style":60},"print(8 \u002F 0)\n",[34,1019,1020],{"__ignoreMap":60},[64,1021,1022,1024,1026,1029,1032,1034],{"class":66,"line":67},[64,1023,596],{"class":86},[64,1025,83],{"class":82},[64,1027,1028],{"class":296},"8",[64,1030,1031],{"class":74}," \u002F",[64,1033,297],{"class":296},[64,1035,125],{"class":82},[14,1037,1038,1039,1042,1043,551],{},"That causes a ",[34,1040,1041],{},"ZeroDivisionError",". If you want to understand that error in more detail, see ",[380,1044,1046],{"href":1045},"\u002Ferrors\u002Fzerodivisionerror-division-by-zero-fix\u002F","ZeroDivisionError: division by zero fix",[367,1048,1050],{"id":1049},"full-calculator-example","Full calculator example",[14,1052,1053],{},"Here is the full program again:",[55,1055,1056],{"className":57,"code":58,"language":59,"meta":60,"style":60},[34,1057,1058,1080,1098,1120,1124,1140,1154,1170,1184,1200,1214,1230,1242,1256,1262,1276,1282],{"__ignoreMap":60},[64,1059,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078],{"class":66,"line":67},[64,1061,71],{"class":70},[64,1063,75],{"class":74},[64,1065,79],{"class":78},[64,1067,83],{"class":82},[64,1069,87],{"class":86},[64,1071,83],{"class":82},[64,1073,93],{"class":92},[64,1075,97],{"class":96},[64,1077,93],{"class":92},[64,1079,102],{"class":82},[64,1081,1082,1084,1086,1088,1090,1092,1094,1096],{"class":66,"line":105},[64,1083,108],{"class":70},[64,1085,75],{"class":74},[64,1087,113],{"class":86},[64,1089,83],{"class":82},[64,1091,93],{"class":92},[64,1093,120],{"class":96},[64,1095,93],{"class":92},[64,1097,125],{"class":82},[64,1099,1100,1102,1104,1106,1108,1110,1112,1114,1116,1118],{"class":66,"line":128},[64,1101,131],{"class":70},[64,1103,75],{"class":74},[64,1105,79],{"class":78},[64,1107,83],{"class":82},[64,1109,87],{"class":86},[64,1111,83],{"class":82},[64,1113,93],{"class":92},[64,1115,146],{"class":96},[64,1117,93],{"class":92},[64,1119,102],{"class":82},[64,1121,1122],{"class":66,"line":153},[64,1123,157],{"emptyLinePlaceholder":156},[64,1125,1126,1128,1130,1132,1134,1136,1138],{"class":66,"line":160},[64,1127,36],{"class":163},[64,1129,166],{"class":70},[64,1131,169],{"class":74},[64,1133,172],{"class":92},[64,1135,175],{"class":96},[64,1137,93],{"class":92},[64,1139,180],{"class":82},[64,1141,1142,1144,1146,1148,1150,1152],{"class":66,"line":183},[64,1143,186],{"class":86},[64,1145,83],{"class":82},[64,1147,71],{"class":191},[64,1149,175],{"class":74},[64,1151,196],{"class":191},[64,1153,125],{"class":82},[64,1155,1156,1158,1160,1162,1164,1166,1168],{"class":66,"line":201},[64,1157,40],{"class":163},[64,1159,166],{"class":70},[64,1161,169],{"class":74},[64,1163,172],{"class":92},[64,1165,212],{"class":96},[64,1167,93],{"class":92},[64,1169,180],{"class":82},[64,1171,1172,1174,1176,1178,1180,1182],{"class":66,"line":219},[64,1173,186],{"class":86},[64,1175,83],{"class":82},[64,1177,71],{"class":191},[64,1179,212],{"class":74},[64,1181,196],{"class":191},[64,1183,125],{"class":82},[64,1185,1186,1188,1190,1192,1194,1196,1198],{"class":66,"line":234},[64,1187,40],{"class":163},[64,1189,166],{"class":70},[64,1191,169],{"class":74},[64,1193,172],{"class":92},[64,1195,245],{"class":96},[64,1197,93],{"class":92},[64,1199,180],{"class":82},[64,1201,1202,1204,1206,1208,1210,1212],{"class":66,"line":252},[64,1203,186],{"class":86},[64,1205,83],{"class":82},[64,1207,71],{"class":191},[64,1209,245],{"class":74},[64,1211,196],{"class":191},[64,1213,125],{"class":82},[64,1215,1216,1218,1220,1222,1224,1226,1228],{"class":66,"line":267},[64,1217,40],{"class":163},[64,1219,166],{"class":70},[64,1221,169],{"class":74},[64,1223,172],{"class":92},[64,1225,278],{"class":96},[64,1227,93],{"class":92},[64,1229,180],{"class":82},[64,1231,1232,1234,1236,1238,1240],{"class":66,"line":285},[64,1233,288],{"class":163},[64,1235,291],{"class":70},[64,1237,169],{"class":74},[64,1239,297],{"class":296},[64,1241,180],{"class":82},[64,1243,1244,1246,1248,1250,1252,1254],{"class":66,"line":302},[64,1245,305],{"class":86},[64,1247,83],{"class":82},[64,1249,93],{"class":92},[64,1251,312],{"class":96},[64,1253,93],{"class":92},[64,1255,125],{"class":82},[64,1257,1258,1260],{"class":66,"line":319},[64,1259,322],{"class":163},[64,1261,180],{"class":82},[64,1263,1264,1266,1268,1270,1272,1274],{"class":66,"line":327},[64,1265,305],{"class":86},[64,1267,83],{"class":82},[64,1269,71],{"class":191},[64,1271,278],{"class":74},[64,1273,196],{"class":191},[64,1275,125],{"class":82},[64,1277,1278,1280],{"class":66,"line":342},[64,1279,44],{"class":163},[64,1281,180],{"class":82},[64,1283,1284,1286,1288,1290,1292,1294],{"class":66,"line":349},[64,1285,186],{"class":86},[64,1287,83],{"class":82},[64,1289,93],{"class":92},[64,1291,358],{"class":96},[64,1293,93],{"class":92},[64,1295,125],{"class":82},[521,1297,1299],{"id":1298},"how-it-works","How it works",[18,1301,1302,1307,1312,1317,1323],{},[21,1303,1304,1306],{},[34,1305,546],{}," stores the first number",[21,1308,1309,1311],{},[34,1310,872],{}," stores the math symbol",[21,1313,1314,1316],{},[34,1315,550],{}," stores the second number",[21,1318,1319,1320,1322],{},"the ",[34,1321,36],{}," structure chooses the correct calculation",[21,1324,1325],{},"the result is printed to the screen",[367,1327,1329],{"id":1328},"expected-output-examples","Expected output examples",[14,1331,1332],{},"Here are some sample runs.",[521,1334,1336],{"id":1335},"example-1","Example 1",[55,1338,1340],{"className":57,"code":1339,"language":59,"meta":60,"style":60},"Enter first number: 12\nEnter operator (+, -, *, \u002F): +\nEnter second number: 3\n15.0\n",[34,1341,1342,1353,1385,1395],{"__ignoreMap":60},[64,1343,1344,1347,1350],{"class":66,"line":67},[64,1345,1346],{"class":70},"Enter first number",[64,1348,1349],{"class":82},":",[64,1351,1352],{"class":296}," 12\n",[64,1354,1355,1358,1360,1362,1364,1367,1370,1372,1375,1377,1379,1382],{"class":66,"line":105},[64,1356,1357],{"class":70},"Enter ",[64,1359,108],{"class":191},[64,1361,83],{"class":82},[64,1363,175],{"class":74},[64,1365,1366],{"class":82},",",[64,1368,1369],{"class":74}," -",[64,1371,1366],{"class":82},[64,1373,1374],{"class":74}," *",[64,1376,1366],{"class":82},[64,1378,1031],{"class":74},[64,1380,1381],{"class":82},"):",[64,1383,1384],{"class":74}," +\n",[64,1386,1387,1390,1392],{"class":66,"line":128},[64,1388,1389],{"class":70},"Enter second number",[64,1391,1349],{"class":82},[64,1393,1394],{"class":296}," 3\n",[64,1396,1397],{"class":66,"line":153},[64,1398,1399],{"class":296},"15.0\n",[521,1401,1403],{"id":1402},"example-2","Example 2",[55,1405,1407],{"className":57,"code":1406,"language":59,"meta":60,"style":60},"Enter first number: 10\nEnter operator (+, -, *, \u002F): \u002F\nEnter second number: 2\n5.0\n",[34,1408,1409,1418,1445,1454],{"__ignoreMap":60},[64,1410,1411,1413,1415],{"class":66,"line":67},[64,1412,1346],{"class":70},[64,1414,1349],{"class":82},[64,1416,1417],{"class":296}," 10\n",[64,1419,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442],{"class":66,"line":105},[64,1421,1357],{"class":70},[64,1423,108],{"class":191},[64,1425,83],{"class":82},[64,1427,175],{"class":74},[64,1429,1366],{"class":82},[64,1431,1369],{"class":74},[64,1433,1366],{"class":82},[64,1435,1374],{"class":74},[64,1437,1366],{"class":82},[64,1439,1031],{"class":74},[64,1441,1381],{"class":82},[64,1443,1444],{"class":74}," \u002F\n",[64,1446,1447,1449,1451],{"class":66,"line":128},[64,1448,1389],{"class":70},[64,1450,1349],{"class":82},[64,1452,1453],{"class":296}," 2\n",[64,1455,1456],{"class":66,"line":153},[64,1457,1458],{"class":296},"5.0\n",[521,1460,1462],{"id":1461},"example-3","Example 3",[55,1464,1466],{"className":57,"code":1465,"language":59,"meta":60,"style":60},"Enter first number: 8\nEnter operator (+, -, *, \u002F): \u002F\nEnter second number: 0\nCannot divide by zero\n",[34,1467,1468,1477,1503,1512],{"__ignoreMap":60},[64,1469,1470,1472,1474],{"class":66,"line":67},[64,1471,1346],{"class":70},[64,1473,1349],{"class":82},[64,1475,1476],{"class":296}," 8\n",[64,1478,1479,1481,1483,1485,1487,1489,1491,1493,1495,1497,1499,1501],{"class":66,"line":105},[64,1480,1357],{"class":70},[64,1482,108],{"class":191},[64,1484,83],{"class":82},[64,1486,175],{"class":74},[64,1488,1366],{"class":82},[64,1490,1369],{"class":74},[64,1492,1366],{"class":82},[64,1494,1374],{"class":74},[64,1496,1366],{"class":82},[64,1498,1031],{"class":74},[64,1500,1381],{"class":82},[64,1502,1444],{"class":74},[64,1504,1505,1507,1509],{"class":66,"line":128},[64,1506,1389],{"class":70},[64,1508,1349],{"class":82},[64,1510,1511],{"class":296}," 0\n",[64,1513,1514],{"class":66,"line":153},[64,1515,1516],{"class":70},"Cannot divide by zero\n",[521,1518,1520],{"id":1519},"example-4","Example 4",[55,1522,1524],{"className":57,"code":1523,"language":59,"meta":60,"style":60},"Enter first number: 4\nEnter operator (+, -, *, \u002F): ?\nEnter second number: 2\nInvalid operator\n",[34,1525,1526,1535,1563,1571],{"__ignoreMap":60},[64,1527,1528,1530,1532],{"class":66,"line":67},[64,1529,1346],{"class":70},[64,1531,1349],{"class":82},[64,1533,1534],{"class":296}," 4\n",[64,1536,1537,1539,1541,1543,1545,1547,1549,1551,1553,1555,1557,1559],{"class":66,"line":105},[64,1538,1357],{"class":70},[64,1540,108],{"class":191},[64,1542,83],{"class":82},[64,1544,175],{"class":74},[64,1546,1366],{"class":82},[64,1548,1369],{"class":74},[64,1550,1366],{"class":82},[64,1552,1374],{"class":74},[64,1554,1366],{"class":82},[64,1556,1031],{"class":74},[64,1558,1381],{"class":82},[64,1560,1562],{"class":1561},"srjyR"," ?\n",[64,1564,1565,1567,1569],{"class":66,"line":128},[64,1566,1389],{"class":70},[64,1568,1349],{"class":82},[64,1570,1453],{"class":296},[64,1572,1573],{"class":66,"line":153},[64,1574,1575],{"class":70},"Invalid operator\n",[367,1577,1579],{"id":1578},"beginner-improvements","Beginner improvements",[14,1581,1582],{},"Once this version works, you can improve it in small steps.",[14,1584,1585],{},"Try one of these:",[18,1587,1588,1594,1597,1603],{},[21,1589,1590,1591],{},"round the result with ",[34,1592,1593],{},"round()",[21,1595,1596],{},"repeat the calculator in a loop",[21,1598,1599,1600],{},"let users quit with ",[34,1601,1602],{},"q",[21,1604,1605,1606,1609,1610,1612],{},"use ",[34,1607,1608],{},"int()"," instead of ",[34,1611,394],{}," if you only want whole numbers",[14,1614,1615],{},"For example, rounding the result:",[55,1617,1619],{"className":57,"code":1618,"language":59,"meta":60,"style":60},"num1 = float(input(\"Enter first number: \"))\noperator = input(\"Enter operator (+, -, *, \u002F): \")\nnum2 = float(input(\"Enter second number: \"))\n\nif operator == \"\u002F\":\n    if num2 == 0:\n        print(\"Cannot divide by zero\")\n    else:\n        print(round(num1 \u002F num2, 2))\n",[34,1620,1621,1643,1661,1683,1687,1703,1715,1729,1735],{"__ignoreMap":60},[64,1622,1623,1625,1627,1629,1631,1633,1635,1637,1639,1641],{"class":66,"line":67},[64,1624,71],{"class":70},[64,1626,75],{"class":74},[64,1628,79],{"class":78},[64,1630,83],{"class":82},[64,1632,87],{"class":86},[64,1634,83],{"class":82},[64,1636,93],{"class":92},[64,1638,97],{"class":96},[64,1640,93],{"class":92},[64,1642,102],{"class":82},[64,1644,1645,1647,1649,1651,1653,1655,1657,1659],{"class":66,"line":105},[64,1646,108],{"class":70},[64,1648,75],{"class":74},[64,1650,113],{"class":86},[64,1652,83],{"class":82},[64,1654,93],{"class":92},[64,1656,120],{"class":96},[64,1658,93],{"class":92},[64,1660,125],{"class":82},[64,1662,1663,1665,1667,1669,1671,1673,1675,1677,1679,1681],{"class":66,"line":128},[64,1664,131],{"class":70},[64,1666,75],{"class":74},[64,1668,79],{"class":78},[64,1670,83],{"class":82},[64,1672,87],{"class":86},[64,1674,83],{"class":82},[64,1676,93],{"class":92},[64,1678,146],{"class":96},[64,1680,93],{"class":92},[64,1682,102],{"class":82},[64,1684,1685],{"class":66,"line":153},[64,1686,157],{"emptyLinePlaceholder":156},[64,1688,1689,1691,1693,1695,1697,1699,1701],{"class":66,"line":160},[64,1690,36],{"class":163},[64,1692,166],{"class":70},[64,1694,169],{"class":74},[64,1696,172],{"class":92},[64,1698,278],{"class":96},[64,1700,93],{"class":92},[64,1702,180],{"class":82},[64,1704,1705,1707,1709,1711,1713],{"class":66,"line":183},[64,1706,288],{"class":163},[64,1708,291],{"class":70},[64,1710,169],{"class":74},[64,1712,297],{"class":296},[64,1714,180],{"class":82},[64,1716,1717,1719,1721,1723,1725,1727],{"class":66,"line":201},[64,1718,305],{"class":86},[64,1720,83],{"class":82},[64,1722,93],{"class":92},[64,1724,312],{"class":96},[64,1726,93],{"class":92},[64,1728,125],{"class":82},[64,1730,1731,1733],{"class":66,"line":219},[64,1732,322],{"class":163},[64,1734,180],{"class":82},[64,1736,1737,1739,1741,1744,1746,1748,1750,1752,1754,1757],{"class":66,"line":234},[64,1738,305],{"class":86},[64,1740,83],{"class":82},[64,1742,1743],{"class":86},"round",[64,1745,83],{"class":82},[64,1747,71],{"class":191},[64,1749,278],{"class":74},[64,1751,196],{"class":191},[64,1753,1366],{"class":82},[64,1755,1756],{"class":296}," 2",[64,1758,102],{"class":82},[14,1760,1761],{},"This prints the division result rounded to 2 decimal places.",[367,1763,1765],{"id":1764},"when-this-example-is-useful","When this example is useful",[14,1767,1768],{},"This project is useful:",[18,1770,1771,1774,1777,1780],{},[21,1772,1773],{},"as a first small Python project",[21,1775,1776],{},"to practice conditionals and input",[21,1778,1779],{},"to combine multiple beginner concepts in one script",[21,1781,1782],{},"to prepare for larger menu-based programs",[14,1784,1785,1786,1788,1789,1791],{},"It is a good next step after learning variables, ",[34,1787,385],{},", and basic ",[34,1790,36],{}," statements.",[367,1793,1795],{"id":1794},"common-mistakes","Common mistakes",[14,1797,1798],{},"Beginners often run into the same problems when building this calculator.",[521,1800,1802,1803,1805],{"id":1801},"forgetting-to-convert-input-values-to-numbers","Forgetting to convert ",[34,1804,385],{}," values to numbers",[14,1807,1808,1809,1811],{},"This is very common. If you skip ",[34,1810,394],{},", the values stay as strings.",[14,1813,1814],{},"Wrong:",[55,1816,1818],{"className":57,"code":1817,"language":59,"meta":60,"style":60},"num1 = input(\"Enter first number: \")\nnum2 = input(\"Enter second number: \")\nprint(num1 + num2)\n",[34,1819,1820,1838,1856],{"__ignoreMap":60},[64,1821,1822,1824,1826,1828,1830,1832,1834,1836],{"class":66,"line":67},[64,1823,71],{"class":70},[64,1825,75],{"class":74},[64,1827,113],{"class":86},[64,1829,83],{"class":82},[64,1831,93],{"class":92},[64,1833,97],{"class":96},[64,1835,93],{"class":92},[64,1837,125],{"class":82},[64,1839,1840,1842,1844,1846,1848,1850,1852,1854],{"class":66,"line":105},[64,1841,131],{"class":70},[64,1843,75],{"class":74},[64,1845,113],{"class":86},[64,1847,83],{"class":82},[64,1849,93],{"class":92},[64,1851,146],{"class":96},[64,1853,93],{"class":92},[64,1855,125],{"class":82},[64,1857,1858,1860,1862,1864,1866,1868],{"class":66,"line":128},[64,1859,596],{"class":86},[64,1861,83],{"class":82},[64,1863,71],{"class":191},[64,1865,175],{"class":74},[64,1867,196],{"class":191},[64,1869,125],{"class":82},[14,1871,1872,1873,547,1876,1879],{},"If the user enters ",[34,1874,1875],{},"2",[34,1877,1878],{},"3",", this prints:",[55,1881,1883],{"className":57,"code":1882,"language":59,"meta":60,"style":60},"23\n",[34,1884,1885],{"__ignoreMap":60},[64,1886,1887],{"class":66,"line":67},[64,1888,1882],{"class":296},[14,1890,1891],{},"That happens because Python joins the strings instead of adding numbers.",[521,1893,1895,1896,1609,1898,1900,1901,1903],{"id":1894},"using-instead-of-in-an-if-statement","Using ",[34,1897,75],{},[34,1899,169],{}," in an ",[34,1902,36],{}," statement",[14,1905,1814],{},[55,1907,1909],{"className":57,"code":1908,"language":59,"meta":60,"style":60},"if operator = \"+\":\n    print(num1 + num2)\n",[34,1910,1911,1927],{"__ignoreMap":60},[64,1912,1913,1915,1917,1919,1921,1923,1925],{"class":66,"line":67},[64,1914,36],{"class":163},[64,1916,166],{"class":70},[64,1918,75],{"class":74},[64,1920,172],{"class":92},[64,1922,175],{"class":96},[64,1924,93],{"class":92},[64,1926,180],{"class":82},[64,1928,1929,1931,1933,1935,1937,1939],{"class":66,"line":105},[64,1930,186],{"class":86},[64,1932,83],{"class":82},[64,1934,71],{"class":191},[64,1936,175],{"class":74},[64,1938,196],{"class":191},[64,1940,125],{"class":82},[14,1942,1943,1944,1946],{},"Use ",[34,1945,169],{}," when comparing values.",[14,1948,1949],{},"Correct:",[55,1951,1953],{"className":57,"code":1952,"language":59,"meta":60,"style":60},"if operator == \"+\":\n    print(num1 + num2)\n",[34,1954,1955,1971],{"__ignoreMap":60},[64,1956,1957,1959,1961,1963,1965,1967,1969],{"class":66,"line":67},[64,1958,36],{"class":163},[64,1960,166],{"class":70},[64,1962,169],{"class":74},[64,1964,172],{"class":92},[64,1966,175],{"class":96},[64,1968,93],{"class":92},[64,1970,180],{"class":82},[64,1972,1973,1975,1977,1979,1981,1983],{"class":66,"line":105},[64,1974,186],{"class":86},[64,1976,83],{"class":82},[64,1978,71],{"class":191},[64,1980,175],{"class":74},[64,1982,196],{"class":191},[64,1984,125],{"class":82},[521,1986,1988],{"id":1987},"not-checking-for-division-by-zero","Not checking for division by zero",[14,1990,1991,1992,1994,1995,1998],{},"If ",[34,1993,550],{}," is ",[34,1996,1997],{},"0",", division will fail unless you handle it first.",[521,2000,2002],{"id":2001},"typing-an-unsupported-operator","Typing an unsupported operator",[14,2004,2005],{},"Your program only supports:",[18,2007,2008,2012,2016,2020],{},[21,2009,2010],{},[34,2011,175],{},[21,2013,2014],{},[34,2015,212],{},[21,2017,2018],{},[34,2019,245],{},[21,2021,2022],{},[34,2023,278],{},[14,2025,2026,2027,551],{},"If the user types something else, the program should show ",[34,2028,358],{},[521,2030,2032],{"id":2031},"misspelling-variable-names","Misspelling variable names",[14,2034,2035,2036,1609,2039,2041],{},"For example, writing ",[34,2037,2038],{},"nub2",[34,2040,550],{}," will cause errors or wrong behavior.",[367,2043,2045],{"id":2044},"faq","FAQ",[521,2047,2049,2050,1609,2052,923],{"id":2048},"why-use-float-instead-of-int","Why use ",[34,2051,394],{},[34,2053,1608],{},[14,2055,2056,2058,2059,2062,2063,2065],{},[34,2057,394],{}," allows decimal numbers like ",[34,2060,2061],{},"2.5",". ",[34,2064,1608],{}," only works for whole numbers.",[521,2067,2069,2070,2072],{"id":2068},"why-does-input-need-conversion","Why does ",[34,2071,385],{}," need conversion?",[14,2074,2075,2077,2078,2080,2081,551],{},[34,2076,385],{}," returns a string. Math needs numbers, so convert with ",[34,2079,1608],{}," or ",[34,2082,394],{},[521,2084,2086],{"id":2085},"why-does-division-return-a-decimal","Why does division return a decimal?",[14,2088,2089,2090,2092],{},"In Python, ",[34,2091,278],{}," returns a float result even when both numbers are whole numbers.",[521,2094,2096],{"id":2095},"can-i-make-the-calculator-run-again-without-restarting","Can I make the calculator run again without restarting?",[14,2098,2099,2100,2103],{},"Yes. Put the code inside a ",[34,2101,2102],{},"while"," loop and ask the user whether to continue.",[367,2105,2107],{"id":2106},"see-also","See also",[18,2109,2110,2118,2124,2135,2140,2146],{},[21,2111,2112],{},[380,2113,2114,2115,2117],{"href":382},"Python ",[34,2116,385],{}," function explained",[21,2119,2120],{},[380,2121,2114,2122,2117],{"href":391},[34,2123,394],{},[21,2125,2126],{},[380,2127,2114,2128,37,2130,41,2132,2134],{"href":400},[34,2129,36],{},[34,2131,44],{},[34,2133,40],{}," explained",[21,2136,2137],{},[380,2138,2139],{"href":713},"How to convert user input to numbers in Python",[21,2141,2142],{},[380,2143,2145],{"href":2144},"\u002Ferrors\u002Fvalueerror-invalid-literal-for-int-with-base-10-fix\u002F","ValueError: invalid literal for int() with base 10 fix",[21,2147,2148],{},[380,2149,2151],{"href":2150},"\u002Fexamples\u002Fpython-number-guessing-game-example\u002F","Python number guessing game example",[14,2153,2154],{},"If you want more practice, try building a second version of this calculator with a loop, better input validation, or extra operators.",[2156,2157,2158],"style",{},"html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .srjyR, html code.shiki .srjyR{--shiki-light:#90A4AE;--shiki-light-font-style:inherit;--shiki-default:#B31D28;--shiki-default-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic}",{"title":60,"searchDepth":105,"depth":105,"links":2160},[2161,2162,2163,2167,2168,2169,2172,2178,2179,2180,2189,2197],{"id":369,"depth":105,"text":370},{"id":424,"depth":105,"text":425},{"id":448,"depth":105,"text":449,"children":2164},[2165],{"id":523,"depth":128,"text":2166},"Important idea: input() always returns text",{"id":717,"depth":105,"text":718},{"id":931,"depth":105,"text":932},{"id":1049,"depth":105,"text":1050,"children":2170},[2171],{"id":1298,"depth":128,"text":1299},{"id":1328,"depth":105,"text":1329,"children":2173},[2174,2175,2176,2177],{"id":1335,"depth":128,"text":1336},{"id":1402,"depth":128,"text":1403},{"id":1461,"depth":128,"text":1462},{"id":1519,"depth":128,"text":1520},{"id":1578,"depth":105,"text":1579},{"id":1764,"depth":105,"text":1765},{"id":1794,"depth":105,"text":1795,"children":2181},[2182,2184,2186,2187,2188],{"id":1801,"depth":128,"text":2183},"Forgetting to convert input() values to numbers",{"id":1894,"depth":128,"text":2185},"Using = instead of == in an if statement",{"id":1987,"depth":128,"text":1988},{"id":2001,"depth":128,"text":2002},{"id":2031,"depth":128,"text":2032},{"id":2044,"depth":105,"text":2045,"children":2190},[2191,2193,2195,2196],{"id":2048,"depth":128,"text":2192},"Why use float() instead of int()?",{"id":2068,"depth":128,"text":2194},"Why does input() need conversion?",{"id":2085,"depth":128,"text":2086},{"id":2095,"depth":128,"text":2096},{"id":2106,"depth":105,"text":2107},"Master python simple calculator example in our comprehensive Python beginner guide.","md",{},"\u002Fexamples\u002Fpython-simple-calculator-example",{"title":5,"description":2198},"examples\u002Fpython-simple-calculator-example","C9YHw200p5Q-FUEGjvoaWhFaaexOIJMPNrlfQhFn5ZM",1777585507264]