{"id":16671,"date":"2022-05-24T15:00:00","date_gmt":"2022-05-24T14:00:00","guid":{"rendered":"https:\/\/www.microsoft.com\/en-gb\/industry\/blog\/?p=16671"},"modified":"2022-06-13T13:02:01","modified_gmt":"2022-06-13T12:02:01","slug":"getting-started-with-python","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-gb\/industry\/blog\/technetuk\/2022\/05\/24\/getting-started-with-python\/","title":{"rendered":"An Introduction to Python"},"content":{"rendered":"
<\/p>\n
Since its creation in 1991, Python has become one of the most popular programming languages in the world. And, because it\u2019s incredibly versatile and easily accessible, it\u2019s used for everything from making web apps to analysing data. But recently, it\u2019s become the code du jour<\/em> for coding machine learning applications.<\/p>\n The code itself is simple to use, emphasising readability on the screen (so, expect to see plenty of whitespace when you\u2019re using it). We\u2019ll show you exactly how to master Python in our Microsoft Learn course \u2018Introduction to Python<\/a>.\u2019<\/p>\n Python executes code in a runtime environment or interpreter in two different ways.<\/p>\n Script mode is exactly as it suggests \u2013 it sees you create a set of commands in a text file (don\u2019t forget to save it with the .py file format). You can then direct the Python interpreter to execute the code line by line, which is then displayed on your screen. Interactive mode, on the other hand, is ideal for testing and debugging. Every command you type is instantly executed, giving you the chance to test out each line of code you write.<\/p>\n Variables are key to success with Python. Without them, you wouldn\u2019t be able to build anything \u2013 they\u2019re that important to the language, letting you create \u2018containers\u2019 where different data values can be stored. The most common data types used, and best for those starting out, are numbers and strings.<\/p>\n Let\u2019s break down the example x = 1<\/em>.<\/p>\n The variable in this instance is X. The equal sign plays the role of \u2018assignment operator\u2019, which assigns the numeric value of 1.<\/p>\n Another data type you may come across is Boolean Type, which displays values are either \u2018True\u2019 or \u2018False\u2019. But now we\u2019re lumbering into a shadowy grey area; technically, Boolean types are examples of numeric integers, with True and False representing the numbers 1 and 0.<\/p>\n Strings are slightly different, relying on alpha values. As such, you can recognise a string data type because it\u2019ll look something like this: x = ‘This is a string’<\/em><\/p>\n This is a very typical example of a string. But it also has the power to combine other strings using the + symbol, in a process known as \u2018concatenation.\u2019<\/p>\n Or, to put it another way\u2026<\/p>\n Python = \u2018Real\u2019 + \u2018Versatility\u2019<\/em><\/p>\n Many times, particularly in apps and websites, your users are going to need to use the keyboard. To make sure this can happen, you need to use the \u2018input\u2019 code.<\/p>\n Let\u2019s say that your user needs to enter their name \u2013 you\u2019d program the following:<\/p>\n name = input(‘Enter your name:’)<\/em><\/p>\n This also works when, say, your user needs to add a telephone number, which would look like x = input(‘Enter a number: ‘)<\/em><\/p>\n You\u2019ll notice something here \u2013 this arrangement is, again, using variables. But where you\u2019d typically assign a value to \u2018x\u2019, but adding the \u2018input\u2019 command, you\u2019re allowing users to assign their own value \u2013 in this case, a phone number.<\/p>\n To then display this keyboard input on screen, you\u2019d add the following beneath the \u2018input\u2019 command print(name)<\/em>.<\/p>\n This lets you build a command that looks something like\u2026<\/p>\n And that\u2019s the Python overview. You\u2019re now ready to embark upon Microsoft Learn\u2019s Introduction to Python course<\/a> and start creating your very own apps.<\/p>\n Since its creation in 1991, Python has become one of the most popular programming languages in the world.<\/p>\n","protected":false},"author":430,"featured_media":36918,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"_classifai_error":"","footnotes":""},"categories":[594],"post_tag":[681,519],"content-type":[],"coauthors":[525],"class_list":["post-16671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technetuk","tag-coding","tag-technet-uk"],"yoast_head":"\nRunning the code<\/h2>\n
Python\u2019s Variables and basic data types<\/h2>\n
Keyboard inputs<\/h2>\n
<eprint('What is your name?')\nname = input()\nprint(name)\nprint('What is your number?')\nx = input()\nprint(number)<\/pre>\n
Start creating<\/h2>\n
Learn more<\/h2>\n
\n