[{"data":1,"prerenderedAt":1416},["ShallowReactive",2],{"doc-\u002Fglossary\u002Fwhat-is-a-variable-in-python":3},{"id":4,"title":5,"body":6,"description":1409,"extension":1410,"meta":1411,"navigation":85,"path":1412,"seo":1413,"stem":1414,"__hash__":1415},"content\u002Fglossary\u002Fwhat-is-a-variable-in-python.md","What Is a Variable in Python?",{"type":7,"value":8,"toc":1379},"minimark",[9,13,17,29,36,117,120,135,138,158,161,166,169,172,189,192,222,224,233,243,251,255,258,261,272,275,309,312,349,352,356,359,374,376,402,404,413,424,428,431,436,466,470,496,500,526,530,557,569,573,576,582,628,630,645,648,651,655,658,683,686,725,728,749,752,771,775,778,781,784,801,804,821,828,831,835,838,846,848,889,891,906,909,929,932,949,962,965,969,972,979,987,1001,1011,1018,1022,1067,1069,1082,1085,1089,1092,1102,1105,1116,1120,1143,1149,1156,1160,1163,1166,1176,1179,1261,1264,1312,1316,1320,1323,1327,1330,1334,1337,1341,1344,1348,1375],[10,11,5],"h1",{"id":12},"what-is-a-variable-in-python",[14,15,16],"p",{},"A variable in Python is a name that refers to a value.",[14,18,19,20,24,25,28],{},"You use variables to store data and use it later in your code. For example, you can store a person's name, an age, a price, or a ",[21,22,23],"code",{},"True","\u002F",[21,26,27],{},"False"," value in a variable.",[14,30,31,32,35],{},"In Python, you create a variable by assigning a value with ",[21,33,34],{},"=",".",[37,38,43],"pre",{"className":39,"code":40,"language":41,"meta":42,"style":42},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","name = \"Sam\"\nage = 12\n\nprint(name)\nprint(age)\n","python","",[21,44,45,68,80,87,105],{"__ignoreMap":42},[46,47,50,54,57,61,65],"span",{"class":48,"line":49},"line",1,[46,51,53],{"class":52},"su5hD","name ",[46,55,34],{"class":56},"smGrS",[46,58,60],{"class":59},"sjJ54"," \"",[46,62,64],{"class":63},"s_sjI","Sam",[46,66,67],{"class":59},"\"\n",[46,69,71,74,76],{"class":48,"line":70},2,[46,72,73],{"class":52},"age ",[46,75,34],{"class":56},[46,77,79],{"class":78},"srdBf"," 12\n",[46,81,83],{"class":48,"line":82},3,[46,84,86],{"emptyLinePlaceholder":85},true,"\n",[46,88,90,94,98,102],{"class":48,"line":89},4,[46,91,93],{"class":92},"sptTA","print",[46,95,97],{"class":96},"sP7_E","(",[46,99,101],{"class":100},"slqww","name",[46,103,104],{"class":96},")\n",[46,106,108,110,112,115],{"class":48,"line":107},5,[46,109,93],{"class":92},[46,111,97],{"class":96},[46,113,114],{"class":100},"age",[46,116,104],{"class":96},[14,118,119],{},"Output:",[37,121,123],{"className":39,"code":122,"language":41,"meta":42,"style":42},"Sam\n12\n",[21,124,125,130],{"__ignoreMap":42},[46,126,127],{"class":48,"line":49},[46,128,129],{"class":52},"Sam\n",[46,131,132],{"class":48,"line":70},[46,133,134],{"class":78},"12\n",[14,136,137],{},"In this example:",[139,140,141,150],"ul",{},[142,143,144,146,147],"li",{},[21,145,101],{}," is a variable that refers to the text ",[21,148,149],{},"\"Sam\"",[142,151,152,154,155],{},[21,153,114],{}," is a variable that refers to the number ",[21,156,157],{},"12",[14,159,160],{},"This is the basic idea of a variable: a named place for storing data.",[162,163,165],"h2",{"id":164},"what-a-variable-means","What a variable means",[14,167,168],{},"A variable is a name that refers to a value.",[14,170,171],{},"That means:",[139,173,174,177,185],{},[142,175,176],{},"It lets you store data and use it later",[142,178,179,180,24,182,184],{},"The value can be text, a number, ",[21,181,23],{},[21,183,27],{},", or other kinds of data",[142,186,31,187],{},[21,188,34],{},[14,190,191],{},"Example:",[37,193,195],{"className":39,"code":194,"language":41,"meta":42,"style":42},"message = \"Hello\"\nprint(message)\n",[21,196,197,211],{"__ignoreMap":42},[46,198,199,202,204,206,209],{"class":48,"line":49},[46,200,201],{"class":52},"message ",[46,203,34],{"class":56},[46,205,60],{"class":59},[46,207,208],{"class":63},"Hello",[46,210,67],{"class":59},[46,212,213,215,217,220],{"class":48,"line":70},[46,214,93],{"class":92},[46,216,97],{"class":96},[46,218,219],{"class":100},"message",[46,221,104],{"class":96},[14,223,119],{},[37,225,227],{"className":39,"code":226,"language":41,"meta":42,"style":42},"Hello\n",[21,228,229],{"__ignoreMap":42},[46,230,231],{"class":48,"line":49},[46,232,226],{"class":52},[14,234,235,236,238,239,242],{},"Here, ",[21,237,219],{}," is the variable name, and ",[21,240,241],{},"\"Hello\""," is the value.",[14,244,245,246,35],{},"If you are new to Python, you may also want to read ",[247,248,250],"a",{"href":249},"\u002Flearn\u002Fpython-variables-explained-for-beginners\u002F","Python variables explained for beginners",[162,252,254],{"id":253},"why-variables-are-useful","Why variables are useful",[14,256,257],{},"Variables are used in almost every Python program because they make code easier to work with.",[14,259,260],{},"They help because:",[139,262,263,266,269],{},[142,264,265],{},"They make code easier to read",[142,267,268],{},"They let you reuse values without typing them again",[142,270,271],{},"They make it easier to update data in one place",[14,273,274],{},"Example without a variable:",[37,276,278],{"className":39,"code":277,"language":41,"meta":42,"style":42},"print(\"Sam\")\nprint(\"Sam\")\n",[21,279,280,295],{"__ignoreMap":42},[46,281,282,284,286,289,291,293],{"class":48,"line":49},[46,283,93],{"class":92},[46,285,97],{"class":96},[46,287,288],{"class":59},"\"",[46,290,64],{"class":63},[46,292,288],{"class":59},[46,294,104],{"class":96},[46,296,297,299,301,303,305,307],{"class":48,"line":70},[46,298,93],{"class":92},[46,300,97],{"class":96},[46,302,288],{"class":59},[46,304,64],{"class":63},[46,306,288],{"class":59},[46,308,104],{"class":96},[14,310,311],{},"Example with a variable:",[37,313,315],{"className":39,"code":314,"language":41,"meta":42,"style":42},"name = \"Sam\"\nprint(name)\nprint(name)\n",[21,316,317,329,339],{"__ignoreMap":42},[46,318,319,321,323,325,327],{"class":48,"line":49},[46,320,53],{"class":52},[46,322,34],{"class":56},[46,324,60],{"class":59},[46,326,64],{"class":63},[46,328,67],{"class":59},[46,330,331,333,335,337],{"class":48,"line":70},[46,332,93],{"class":92},[46,334,97],{"class":96},[46,336,101],{"class":100},[46,338,104],{"class":96},[46,340,341,343,345,347],{"class":48,"line":82},[46,342,93],{"class":92},[46,344,97],{"class":96},[46,346,101],{"class":100},[46,348,104],{"class":96},[14,350,351],{},"The second version is easier to update. If the name changes, you only need to change it once.",[162,353,355],{"id":354},"how-to-create-a-variable","How to create a variable",[14,357,358],{},"To create a variable in Python:",[360,361,362,365,371],"ol",{},[142,363,364],{},"Write the variable name on the left",[142,366,367,368,370],{},"Write ",[21,369,34],{}," in the middle",[142,372,373],{},"Write the value on the right",[14,375,191],{},[37,377,379],{"className":39,"code":378,"language":41,"meta":42,"style":42},"score = 100\nprint(score)\n",[21,380,381,391],{"__ignoreMap":42},[46,382,383,386,388],{"class":48,"line":49},[46,384,385],{"class":52},"score ",[46,387,34],{"class":56},[46,389,390],{"class":78}," 100\n",[46,392,393,395,397,400],{"class":48,"line":70},[46,394,93],{"class":92},[46,396,97],{"class":96},[46,398,399],{"class":100},"score",[46,401,104],{"class":96},[14,403,119],{},[37,405,407],{"className":39,"code":406,"language":41,"meta":42,"style":42},"100\n",[21,408,409],{"__ignoreMap":42},[46,410,411],{"class":48,"line":49},[46,412,406],{"class":78},[14,414,415,416,418,419,423],{},"It helps to remember that ",[21,417,34],{}," here means ",[420,421,422],"strong",{},"assignment",", not mathematical equality. It means “put this value into this variable name.”",[162,425,427],{"id":426},"simple-variable-examples","Simple variable examples",[14,429,430],{},"Variables can store different kinds of values.",[432,433,435],"h3",{"id":434},"store-text","Store text",[37,437,439],{"className":39,"code":438,"language":41,"meta":42,"style":42},"city = \"London\"\nprint(city)\n",[21,440,441,455],{"__ignoreMap":42},[46,442,443,446,448,450,453],{"class":48,"line":49},[46,444,445],{"class":52},"city ",[46,447,34],{"class":56},[46,449,60],{"class":59},[46,451,452],{"class":63},"London",[46,454,67],{"class":59},[46,456,457,459,461,464],{"class":48,"line":70},[46,458,93],{"class":92},[46,460,97],{"class":96},[46,462,463],{"class":100},"city",[46,465,104],{"class":96},[432,467,469],{"id":468},"store-a-whole-number","Store a whole number",[37,471,473],{"className":39,"code":472,"language":41,"meta":42,"style":42},"count = 5\nprint(count)\n",[21,474,475,485],{"__ignoreMap":42},[46,476,477,480,482],{"class":48,"line":49},[46,478,479],{"class":52},"count ",[46,481,34],{"class":56},[46,483,484],{"class":78}," 5\n",[46,486,487,489,491,494],{"class":48,"line":70},[46,488,93],{"class":92},[46,490,97],{"class":96},[46,492,493],{"class":100},"count",[46,495,104],{"class":96},[432,497,499],{"id":498},"store-a-decimal-number","Store a decimal number",[37,501,503],{"className":39,"code":502,"language":41,"meta":42,"style":42},"price = 9.99\nprint(price)\n",[21,504,505,515],{"__ignoreMap":42},[46,506,507,510,512],{"class":48,"line":49},[46,508,509],{"class":52},"price ",[46,511,34],{"class":56},[46,513,514],{"class":78}," 9.99\n",[46,516,517,519,521,524],{"class":48,"line":70},[46,518,93],{"class":92},[46,520,97],{"class":96},[46,522,523],{"class":100},"price",[46,525,104],{"class":96},[432,527,529],{"id":528},"store-a-boolean","Store a boolean",[37,531,533],{"className":39,"code":532,"language":41,"meta":42,"style":42},"is_ready = True\nprint(is_ready)\n",[21,534,535,546],{"__ignoreMap":42},[46,536,537,540,542],{"class":48,"line":49},[46,538,539],{"class":52},"is_ready ",[46,541,34],{"class":56},[46,543,545],{"class":544},"s39Yj"," True\n",[46,547,548,550,552,555],{"class":48,"line":70},[46,549,93],{"class":92},[46,551,97],{"class":96},[46,553,554],{"class":100},"is_ready",[46,556,104],{"class":96},[14,558,559,560,564,565,35],{},"These are different ",[247,561,563],{"href":562},"\u002Fglossary\u002Fwhat-is-a-data-type-in-python\u002F","data types in Python",". If you want a broader view, see ",[247,566,568],{"href":567},"\u002Flearn\u002Fpython-data-types-overview\u002F","Python data types overview",[162,570,572],{"id":571},"changing-a-variable-value","Changing a variable value",[14,574,575],{},"A variable can point to a new value later.",[14,577,578,579,35],{},"This is called ",[420,580,581],{},"reassignment",[37,583,585],{"className":39,"code":584,"language":41,"meta":42,"style":42},"count = 5\nprint(count)\n\ncount = 6\nprint(count)\n",[21,586,587,595,605,609,618],{"__ignoreMap":42},[46,588,589,591,593],{"class":48,"line":49},[46,590,479],{"class":52},[46,592,34],{"class":56},[46,594,484],{"class":78},[46,596,597,599,601,603],{"class":48,"line":70},[46,598,93],{"class":92},[46,600,97],{"class":96},[46,602,493],{"class":100},[46,604,104],{"class":96},[46,606,607],{"class":48,"line":82},[46,608,86],{"emptyLinePlaceholder":85},[46,610,611,613,615],{"class":48,"line":89},[46,612,479],{"class":52},[46,614,34],{"class":56},[46,616,617],{"class":78}," 6\n",[46,619,620,622,624,626],{"class":48,"line":107},[46,621,93],{"class":92},[46,623,97],{"class":96},[46,625,493],{"class":100},[46,627,104],{"class":96},[14,629,119],{},[37,631,633],{"className":39,"code":632,"language":41,"meta":42,"style":42},"5\n6\n",[21,634,635,640],{"__ignoreMap":42},[46,636,637],{"class":48,"line":49},[46,638,639],{"class":78},"5\n",[46,641,642],{"class":48,"line":70},[46,643,644],{"class":78},"6\n",[14,646,647],{},"The newest assigned value is the current one.",[14,649,650],{},"This is another reason variables are useful. You can update information as your program runs.",[162,652,654],{"id":653},"basic-naming-rules","Basic naming rules",[14,656,657],{},"Python variable names must follow some simple rules:",[139,659,660,663,666,669],{},[142,661,662],{},"Names can contain letters, numbers, and underscores",[142,664,665],{},"Names cannot start with a number",[142,667,668],{},"Names cannot contain spaces",[142,670,671,672,675,676,679,680],{},"You cannot use Python keywords like ",[21,673,674],{},"if",", ",[21,677,678],{},"for",", or ",[21,681,682],{},"class",[14,684,685],{},"Valid names:",[37,687,689],{"className":39,"code":688,"language":41,"meta":42,"style":42},"user_name = \"Ana\"\nscore1 = 10\ntotal_price = 19.99\n",[21,690,691,705,715],{"__ignoreMap":42},[46,692,693,696,698,700,703],{"class":48,"line":49},[46,694,695],{"class":52},"user_name ",[46,697,34],{"class":56},[46,699,60],{"class":59},[46,701,702],{"class":63},"Ana",[46,704,67],{"class":59},[46,706,707,710,712],{"class":48,"line":70},[46,708,709],{"class":52},"score1 ",[46,711,34],{"class":56},[46,713,714],{"class":78}," 10\n",[46,716,717,720,722],{"class":48,"line":82},[46,718,719],{"class":52},"total_price ",[46,721,34],{"class":56},[46,723,724],{"class":78}," 19.99\n",[14,726,727],{},"Invalid names:",[37,729,731],{"className":39,"code":730,"language":41,"meta":42,"style":42},"# 2name = \"Ana\"\n# user name = \"Ana\"\n# class = \"Math\"\n",[21,732,733,739,744],{"__ignoreMap":42},[46,734,735],{"class":48,"line":49},[46,736,738],{"class":737},"sutJx","# 2name = \"Ana\"\n",[46,740,741],{"class":48,"line":70},[46,742,743],{"class":737},"# user name = \"Ana\"\n",[46,745,746],{"class":48,"line":82},[46,747,748],{"class":737},"# class = \"Math\"\n",[14,750,751],{},"Those examples are invalid because:",[139,753,754,760,766],{},[142,755,756,759],{},[21,757,758],{},"2name"," starts with a number",[142,761,762,765],{},[21,763,764],{},"user name"," contains a space",[142,767,768,770],{},[21,769,682],{}," is a Python keyword",[162,772,774],{"id":773},"good-variable-names","Good variable names",[14,776,777],{},"Choose names that describe the value clearly.",[14,779,780],{},"Good variable names make code easier to read and debug.",[14,782,783],{},"Prefer names like:",[139,785,786,791,796],{},[142,787,788],{},[21,789,790],{},"total_price",[142,792,793],{},[21,794,795],{},"user_name",[142,797,798],{},[21,799,800],{},"is_logged_in",[14,802,803],{},"Instead of unclear names like:",[139,805,806,811,816],{},[142,807,808],{},[21,809,810],{},"tp",[142,812,813],{},[21,814,815],{},"x",[142,817,818],{},[21,819,820],{},"a1",[14,822,823,824,827],{},"A common Python style is to use ",[420,825,826],{},"lowercase_with_underscores"," for variable names.",[14,829,830],{},"Clear names are especially helpful for beginners.",[162,832,834],{"id":833},"variables-are-not-the-same-as-values","Variables are not the same as values",[14,836,837],{},"A variable name and a value are not the same thing.",[139,839,840,843],{},[142,841,842],{},"The variable name is the label",[142,844,845],{},"The value is the actual data",[14,847,191],{},[37,849,851],{"className":39,"code":850,"language":41,"meta":42,"style":42},"name = \"Ana\"\nprint(name)\nprint(\"name\")\n",[21,852,853,865,875],{"__ignoreMap":42},[46,854,855,857,859,861,863],{"class":48,"line":49},[46,856,53],{"class":52},[46,858,34],{"class":56},[46,860,60],{"class":59},[46,862,702],{"class":63},[46,864,67],{"class":59},[46,866,867,869,871,873],{"class":48,"line":70},[46,868,93],{"class":92},[46,870,97],{"class":96},[46,872,101],{"class":100},[46,874,104],{"class":96},[46,876,877,879,881,883,885,887],{"class":48,"line":82},[46,878,93],{"class":92},[46,880,97],{"class":96},[46,882,288],{"class":59},[46,884,101],{"class":63},[46,886,288],{"class":59},[46,888,104],{"class":96},[14,890,119],{},[37,892,894],{"className":39,"code":893,"language":41,"meta":42,"style":42},"Ana\nname\n",[21,895,896,901],{"__ignoreMap":42},[46,897,898],{"class":48,"line":49},[46,899,900],{"class":52},"Ana\n",[46,902,903],{"class":48,"line":70},[46,904,905],{"class":52},"name\n",[14,907,908],{},"Why is the output different?",[139,910,911,919],{},[142,912,913,916,917],{},[21,914,915],{},"print(name)"," uses the variable called ",[21,918,101],{},[142,920,921,924,925,928],{},[21,922,923],{},"print(\"name\")"," prints the text ",[21,926,927],{},"\"name\""," exactly as written",[14,930,931],{},"So in:",[37,933,935],{"className":39,"code":934,"language":41,"meta":42,"style":42},"name = \"Ana\"\n",[21,936,937],{"__ignoreMap":42},[46,938,939,941,943,945,947],{"class":48,"line":49},[46,940,53],{"class":52},[46,942,34],{"class":56},[46,944,60],{"class":59},[46,946,702],{"class":63},[46,948,67],{"class":59},[139,950,951,956],{},[142,952,953,955],{},[21,954,101],{}," is the variable",[142,957,958,961],{},[21,959,960],{},"\"Ana\""," is the string value",[14,963,964],{},"This difference matters when printing, comparing, and updating data.",[162,966,968],{"id":967},"common-mistakes","Common mistakes",[14,970,971],{},"Beginners often run into the same problems when learning variables.",[432,973,975,976,978],{"id":974},"thinking-means-equals-in-the-math-sense","Thinking ",[21,977,34],{}," means “equals” in the math sense",[14,980,981,982,984,985,35],{},"In Python, ",[21,983,34],{}," usually means ",[420,986,422],{},[37,988,990],{"className":39,"code":989,"language":41,"meta":42,"style":42},"x = 5\n",[21,991,992],{"__ignoreMap":42},[46,993,994,997,999],{"class":48,"line":49},[46,995,996],{"class":52},"x ",[46,998,34],{"class":56},[46,1000,484],{"class":78},[14,1002,1003,1004,1007,1008,1010],{},"This means “assign the value ",[21,1005,1006],{},"5"," to ",[21,1009,815],{},".”",[14,1012,1013,1014,1017],{},"It does ",[420,1015,1016],{},"not"," mean “x equals 5” in the same way as a math equation.",[432,1019,1021],{"id":1020},"using-quotes-around-a-variable-name-by-mistake","Using quotes around a variable name by mistake",[37,1023,1025],{"className":39,"code":1024,"language":41,"meta":42,"style":42},"name = \"Sam\"\n\nprint(name)\nprint(\"name\")\n",[21,1026,1027,1039,1043,1053],{"__ignoreMap":42},[46,1028,1029,1031,1033,1035,1037],{"class":48,"line":49},[46,1030,53],{"class":52},[46,1032,34],{"class":56},[46,1034,60],{"class":59},[46,1036,64],{"class":63},[46,1038,67],{"class":59},[46,1040,1041],{"class":48,"line":70},[46,1042,86],{"emptyLinePlaceholder":85},[46,1044,1045,1047,1049,1051],{"class":48,"line":82},[46,1046,93],{"class":92},[46,1048,97],{"class":96},[46,1050,101],{"class":100},[46,1052,104],{"class":96},[46,1054,1055,1057,1059,1061,1063,1065],{"class":48,"line":89},[46,1056,93],{"class":92},[46,1058,97],{"class":96},[46,1060,288],{"class":59},[46,1062,101],{"class":63},[46,1064,288],{"class":59},[46,1066,104],{"class":96},[14,1068,119],{},[37,1070,1072],{"className":39,"code":1071,"language":41,"meta":42,"style":42},"Sam\nname\n",[21,1073,1074,1078],{"__ignoreMap":42},[46,1075,1076],{"class":48,"line":49},[46,1077,129],{"class":52},[46,1079,1080],{"class":48,"line":70},[46,1081,905],{"class":52},[14,1083,1084],{},"With quotes, Python treats it as text, not as a variable.",[432,1086,1088],{"id":1087},"using-an-invalid-variable-name","Using an invalid variable name",[14,1090,1091],{},"These names are not valid:",[139,1093,1094,1098],{},[142,1095,1096],{},[21,1097,758],{},[142,1099,1100],{},[21,1101,764],{},[14,1103,1104],{},"Use names like:",[139,1106,1107,1112],{},[142,1108,1109],{},[21,1110,1111],{},"name2",[142,1113,1114],{},[21,1115,795],{},[432,1117,1119],{"id":1118},"trying-to-use-a-variable-before-assigning-it","Trying to use a variable before assigning it",[37,1121,1123],{"className":39,"code":1122,"language":41,"meta":42,"style":42},"print(age)\nage = 12\n",[21,1124,1125,1135],{"__ignoreMap":42},[46,1126,1127,1129,1131,1133],{"class":48,"line":49},[46,1128,93],{"class":92},[46,1130,97],{"class":96},[46,1132,114],{"class":100},[46,1134,104],{"class":96},[46,1136,1137,1139,1141],{"class":48,"line":70},[46,1138,73],{"class":52},[46,1140,34],{"class":56},[46,1142,79],{"class":78},[14,1144,1145,1146,1148],{},"This causes an error because ",[21,1147,114],{}," does not have a value yet.",[14,1150,1151,1152,35],{},"Python often shows this as a ",[247,1153,1155],{"href":1154},"\u002Ferrors\u002Fnameerror-name-is-not-defined-fix\u002F","NameError: name is not defined",[432,1157,1159],{"id":1158},"confusing-variables-with-data-types","Confusing variables with data types",[14,1161,1162],{},"A variable is the name you use.",[14,1164,1165],{},"A data type is the kind of value stored there, such as a string, integer, or boolean.",[14,1167,1168,1169,35],{},"You can inspect a value's type with the ",[247,1170,1172,1175],{"href":1171},"\u002Freference\u002Fpython-type-function-explained\u002F",[21,1173,1174],{},"type()"," function",[14,1177,1178],{},"Useful debugging checks:",[37,1180,1182],{"className":39,"code":1181,"language":41,"meta":42,"style":42},"name = \"Sam\"\nage = 12\n\nprint(name)\nprint(type(name))\nprint(age)\nprint(type(age))\n",[21,1183,1184,1196,1204,1208,1218,1235,1246],{"__ignoreMap":42},[46,1185,1186,1188,1190,1192,1194],{"class":48,"line":49},[46,1187,53],{"class":52},[46,1189,34],{"class":56},[46,1191,60],{"class":59},[46,1193,64],{"class":63},[46,1195,67],{"class":59},[46,1197,1198,1200,1202],{"class":48,"line":70},[46,1199,73],{"class":52},[46,1201,34],{"class":56},[46,1203,79],{"class":78},[46,1205,1206],{"class":48,"line":82},[46,1207,86],{"emptyLinePlaceholder":85},[46,1209,1210,1212,1214,1216],{"class":48,"line":89},[46,1211,93],{"class":92},[46,1213,97],{"class":96},[46,1215,101],{"class":100},[46,1217,104],{"class":96},[46,1219,1220,1222,1224,1228,1230,1232],{"class":48,"line":107},[46,1221,93],{"class":92},[46,1223,97],{"class":96},[46,1225,1227],{"class":1226},"sZMiF","type",[46,1229,97],{"class":96},[46,1231,101],{"class":100},[46,1233,1234],{"class":96},"))\n",[46,1236,1238,1240,1242,1244],{"class":48,"line":1237},6,[46,1239,93],{"class":92},[46,1241,97],{"class":96},[46,1243,114],{"class":100},[46,1245,104],{"class":96},[46,1247,1249,1251,1253,1255,1257,1259],{"class":48,"line":1248},7,[46,1250,93],{"class":92},[46,1252,97],{"class":96},[46,1254,1227],{"class":1226},[46,1256,97],{"class":96},[46,1258,114],{"class":100},[46,1260,1234],{"class":96},[14,1262,1263],{},"Possible output:",[37,1265,1267],{"className":39,"code":1266,"language":41,"meta":42,"style":42},"Sam\n\u003Cclass 'str'>\n12\n\u003Cclass 'int'>\n",[21,1268,1269,1273,1293,1297],{"__ignoreMap":42},[46,1270,1271],{"class":48,"line":49},[46,1272,129],{"class":52},[46,1274,1275,1278,1281,1284,1287,1290],{"class":48,"line":70},[46,1276,1277],{"class":56},"\u003C",[46,1279,682],{"class":1280},"sbsja",[46,1282,1283],{"class":59}," '",[46,1285,1286],{"class":63},"str",[46,1288,1289],{"class":59},"'",[46,1291,1292],{"class":56},">\n",[46,1294,1295],{"class":48,"line":82},[46,1296,134],{"class":78},[46,1298,1299,1301,1303,1305,1308,1310],{"class":48,"line":89},[46,1300,1277],{"class":56},[46,1302,682],{"class":1280},[46,1304,1283],{"class":59},[46,1306,1307],{"class":63},"int",[46,1309,1289],{"class":59},[46,1311,1292],{"class":56},[162,1313,1315],{"id":1314},"faq","FAQ",[432,1317,1319],{"id":1318},"do-i-need-to-declare-a-variable-type-in-python-first","Do I need to declare a variable type in Python first?",[14,1321,1322],{},"No. Python creates the variable when you assign a value to it.",[432,1324,1326],{"id":1325},"can-a-variable-change-from-one-type-to-another","Can a variable change from one type to another?",[14,1328,1329],{},"Yes. A variable can refer to a string first and a number later, though clear code usually avoids unnecessary changes.",[432,1331,1333],{"id":1332},"is-a-variable-the-same-as-a-value","Is a variable the same as a value?",[14,1335,1336],{},"No. The variable is the name. The value is the data stored under that name.",[432,1338,1340],{"id":1339},"why-does-python-say-a-name-is-not-defined","Why does Python say a name is not defined?",[14,1342,1343],{},"Usually because the variable was used before it was assigned, or the name was misspelled.",[162,1345,1347],{"id":1346},"see-also","See also",[139,1349,1350,1354,1358,1366,1370],{},[142,1351,1352],{},[247,1353,250],{"href":249},[142,1355,1356],{},[247,1357,568],{"href":567},[142,1359,1360],{},[247,1361,1362,1363,1365],{"href":1171},"Python ",[21,1364,1174],{}," function explained",[142,1367,1368],{},[247,1369,1155],{"href":1154},[142,1371,1372],{},[247,1373,1374],{"href":562},"What is a data type in Python?",[1376,1377,1378],"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 .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 .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--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 .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}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 .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sutJx, html code.shiki .sutJx{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}",{"title":42,"searchDepth":70,"depth":70,"links":1380},[1381,1382,1383,1384,1390,1391,1392,1393,1394,1402,1408],{"id":164,"depth":70,"text":165},{"id":253,"depth":70,"text":254},{"id":354,"depth":70,"text":355},{"id":426,"depth":70,"text":427,"children":1385},[1386,1387,1388,1389],{"id":434,"depth":82,"text":435},{"id":468,"depth":82,"text":469},{"id":498,"depth":82,"text":499},{"id":528,"depth":82,"text":529},{"id":571,"depth":70,"text":572},{"id":653,"depth":70,"text":654},{"id":773,"depth":70,"text":774},{"id":833,"depth":70,"text":834},{"id":967,"depth":70,"text":968,"children":1395},[1396,1398,1399,1400,1401],{"id":974,"depth":82,"text":1397},"Thinking = means “equals” in the math sense",{"id":1020,"depth":82,"text":1021},{"id":1087,"depth":82,"text":1088},{"id":1118,"depth":82,"text":1119},{"id":1158,"depth":82,"text":1159},{"id":1314,"depth":70,"text":1315,"children":1403},[1404,1405,1406,1407],{"id":1318,"depth":82,"text":1319},{"id":1325,"depth":82,"text":1326},{"id":1332,"depth":82,"text":1333},{"id":1339,"depth":82,"text":1340},{"id":1346,"depth":70,"text":1347},"Master what is a variable in python in our comprehensive Python beginner guide.","md",{},"\u002Fglossary\u002Fwhat-is-a-variable-in-python",{"title":5,"description":1409},"glossary\u002Fwhat-is-a-variable-in-python","g4BQJtVgmQzaryqL4kiimkkL36TFCEDzHf2tUz_GhZg",1777585494116]