![]() |
Python Tutorial Chapter 1 - Beginning - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Python (https://sinister.ly/Forum-Python) +--- Thread: Python Tutorial Chapter 1 - Beginning (/Thread-Python-Tutorial-Chapter-1-Beginning) Pages:
1
2
|
Python Tutorial Chapter 1 - Beginning - MrGeek - 05-09-2013 Chapter -1 Introduction to Python Absolute Beginning :-> Intro Welcome here! This is my first guide on HC family. If I make any mistakes feel free to point me ![]() This work is 100% by me. (0x00)Python Installation To install python, you need to download latest version of python from Code: www.python.org The download list contains respective installer for cross platforms. Quote:Windows -> .msiAfter installation, if your box is windows, the installation directory would be c:\pythonx where x represent the python version number. But if your box is *nix (either Unix based or Linux based) it’ll be under /usr/bin/python For calling python shell anytime -> Goto Control Panel > System > Advanced > Environment Variables Then edit PATH, copy this sentence Code: “;C:\Python33” If it’s in *nix box it probably pre-installed You can know if your box has python or not by typing “python –v” in your shell. If the terminal or shell shows the python version, It means that your box has python pre-installed. Or if shell shows “python command not found” then you don’t have python yet. I'll will explain *nix installation later. You can see your python version in Start Menu -> All programs (win7) Inside python folder, you will see five files : IDLE (Python GUI), Module doc, Python (Command line), Python Manual, Uninstall python. There are two relatively important thing for python: Python shell aka Python Interpreter (Python command line) IDLE (Integrated Development Environment) (IDLE Python GUI) (0x01)Choosing your Editor You need to choose a good editor. A good editor has syntax highlighting, which is a great advantage in coding. Python has a special editor -> Pyscripter, which is used by many fellow python programmers. Unfortunately it has only Windows version. You can use other open source editors such as gedit and Notepad++. As a piece of advice, don’t ever use the window’s built-in notepad as an editor for newbies, because it doesn’t have syntax highlighting. So here comes the question. Why would you need syntax highlighting? If there’s no syntax highlighting, your coding are more prone to “error” or so called “bugs”. IDLE and Notepad++ has syntax highlighting. And in windows, Pyscripter is highly recommended. Python script file can be run directly or inside built-in python shell. Python shell also known as Python interpreter is vital to python programming language, because python is an interpreted language, so interpreter is necessary. One distinct feature of python language is that you don’t have to wait to finish the whole program to know what the codes does, you can input the codes directly into python shell to see what it does. On the other hand, in cases such as in C language and Java, you need to finish the whole program then compile and then only run, to see what the code does. So isn’t python convenient? (0x02)Writing your first program -> The helloworld.py Every new comers to programming language, starts with legendary “hello world” program. Ok let’s try it! Open your editor. Type in the following codes Code: #!/usr/bin/env python Then save it as helloworld.py then run it. In *nix box you need to first give the script execute permission with chmod a+x hello.py Then run the program. You’ll see Quote:QuoteAbove sentence. #!/usr… line is called shebang line. It is used to tell the system, from which interpreter we will use to run this script/program. Print syntax will show the sentence as an output on the screen. You can type help(syntax) to know what the syntax does. In other words, it’s sort of like man page. (0x03)Summary [video] Code: https://www.youtube.com/watch?v=Gp60Qp3GUBU After this Chapter – 1 -> You should know briefly about python You should understand that algorithms is the sequence of steps to write your program. Algorithms has expressions and statements too. Expressions are values, for instance 9 + 1 is an expression. It’ll show you the value 10. Variable is, technically taking space in memory. Variable can also be like x, unknown. Remember what the “print” syntax does. --------------------------------------------------------------------------------------------------- New Functions in this Chapter ===== ======= Function Description ===== ======= print Shows the standard output ----------------------------------------------------------------------------------------------------------- This is the end of the chapter-1:bye: Thanks for reading, If you find any mistakes feel free to tell me to fix ![]() MrGeek@HC:~>logout To be Continued Python Tutorial Chapter 1 - Beginning - MrGeek - 05-09-2013 Chapter -1 Introduction to Python Absolute Beginning :-> Intro Welcome here! This is my first guide on HC family. If I make any mistakes feel free to point me ![]() This work is 100% by me. (0x00)Python Installation To install python, you need to download latest version of python from Code: www.python.org The download list contains respective installer for cross platforms. Quote:Windows -> .msiAfter installation, if your box is windows, the installation directory would be c:\pythonx where x represent the python version number. But if your box is *nix (either Unix based or Linux based) it’ll be under /usr/bin/python For calling python shell anytime -> Goto Control Panel > System > Advanced > Environment Variables Then edit PATH, copy this sentence Code: “;C:\Python33” If it’s in *nix box it probably pre-installed You can know if your box has python or not by typing “python –v” in your shell. If the terminal or shell shows the python version, It means that your box has python pre-installed. Or if shell shows “python command not found” then you don’t have python yet. I'll will explain *nix installation later. You can see your python version in Start Menu -> All programs (win7) Inside python folder, you will see five files : IDLE (Python GUI), Module doc, Python (Command line), Python Manual, Uninstall python. There are two relatively important thing for python: Python shell aka Python Interpreter (Python command line) IDLE (Integrated Development Environment) (IDLE Python GUI) (0x01)Choosing your Editor You need to choose a good editor. A good editor has syntax highlighting, which is a great advantage in coding. Python has a special editor -> Pyscripter, which is used by many fellow python programmers. Unfortunately it has only Windows version. You can use other open source editors such as gedit and Notepad++. As a piece of advice, don’t ever use the window’s built-in notepad as an editor for newbies, because it doesn’t have syntax highlighting. So here comes the question. Why would you need syntax highlighting? If there’s no syntax highlighting, your coding are more prone to “error” or so called “bugs”. IDLE and Notepad++ has syntax highlighting. And in windows, Pyscripter is highly recommended. Python script file can be run directly or inside built-in python shell. Python shell also known as Python interpreter is vital to python programming language, because python is an interpreted language, so interpreter is necessary. One distinct feature of python language is that you don’t have to wait to finish the whole program to know what the codes does, you can input the codes directly into python shell to see what it does. On the other hand, in cases such as in C language and Java, you need to finish the whole program then compile and then only run, to see what the code does. So isn’t python convenient? (0x02)Writing your first program -> The helloworld.py Every new comers to programming language, starts with legendary “hello world” program. Ok let’s try it! Open your editor. Type in the following codes Code: #!/usr/bin/env python Then save it as helloworld.py then run it. In *nix box you need to first give the script execute permission with chmod a+x hello.py Then run the program. You’ll see Quote:QuoteAbove sentence. #!/usr… line is called shebang line. It is used to tell the system, from which interpreter we will use to run this script/program. Print syntax will show the sentence as an output on the screen. You can type help(syntax) to know what the syntax does. In other words, it’s sort of like man page. (0x03)Summary [video] Code: https://www.youtube.com/watch?v=Gp60Qp3GUBU After this Chapter – 1 -> You should know briefly about python You should understand that algorithms is the sequence of steps to write your program. Algorithms has expressions and statements too. Expressions are values, for instance 9 + 1 is an expression. It’ll show you the value 10. Variable is, technically taking space in memory. Variable can also be like x, unknown. Remember what the “print” syntax does. --------------------------------------------------------------------------------------------------- New Functions in this Chapter ===== ======= Function Description ===== ======= print Shows the standard output ----------------------------------------------------------------------------------------------------------- This is the end of the chapter-1:bye: Thanks for reading, If you find any mistakes feel free to tell me to fix ![]() MrGeek@HC:~>logout To be Continued RE: Chp:->1 Python <-> Absolute Beginning - Deque - 05-10-2013 Your "hello world" code has three mistakes that makes it not working. Print (starting with uppercase) doesn't exist. ” as well as “ are not the same as " and not recognized as such. Quote:In *nix box you need to first give the script execute permission with chmod a+x hello.py No you don't. Just type in python file and it works too. Quote:#!/usr… line is called shebang line. It is used to tell the system, from which interpreter we will use to run this script/program. But only for *nix. Windows doesn't use that at all. Nevertheless it is adviceable to put it in even if you are on Windows. RE: Chp:->1 Python <-> Absolute Beginning - Deque - 05-10-2013 Your "hello world" code has three mistakes that makes it not working. Print (starting with uppercase) doesn't exist. ” as well as “ are not the same as " and not recognized as such. Quote:In *nix box you need to first give the script execute permission with chmod a+x hello.py No you don't. Just type in python file and it works too. Quote:#!/usr… line is called shebang line. It is used to tell the system, from which interpreter we will use to run this script/program. But only for *nix. Windows doesn't use that at all. Nevertheless it is adviceable to put it in even if you are on Windows. RE: Chp:->1 Python <-> Absolute Beginning - Psycho_Coder - 05-10-2013 Please provide the download links to the python interpreter. Make it easier for others. Your video links is not valid as it is dotted and you must use the video tag properly. Use code tags for posting programming source codes else use quote tags. Please format your thread 00x0, 00x1 --> does not looks good use 1, 2 or A) or B) likewise. After you made a title leave two lines gap. I makes the post looks better and more readable. Thank You, Sincerely, Feurex RE: Chp:->1 Python <-> Absolute Beginning - Psycho_Coder - 05-10-2013 Please provide the download links to the python interpreter. Make it easier for others. Your video links is not valid as it is dotted and you must use the video tag properly. Use code tags for posting programming source codes else use quote tags. Please format your thread 00x0, 00x1 --> does not looks good use 1, 2 or A) or B) likewise. After you made a title leave two lines gap. I makes the post looks better and more readable. Thank You, Sincerely, Feurex RE: Chp:->1 Python <-> Absolute Beginning - MrGeek - 05-10-2013 (05-10-2013, 12:51 PM)Deque Wrote: Your "hello world" code has three mistakes that makes it not working. Sorry for my errors. Actually , this is because we have a facebook group for talking python stuffs. We posted with our mother language & translated into English. In our Zawgyi-font like you said . single quotes & double quotes are not the same as others.. here Code: ' " ‘’ “” That depends on how you target your contribution ![]() I said for linux guys Much appreciate for your reply ![]() (05-10-2013, 01:29 PM)Feurex Wrote: Please provide the download links to the python interpreter. Make it easier for others. Thanks a lot for your effort bro ![]() Fix the errors , I'm sorry. I would take care next time ![]() RE: Chp:->1 Python <-> Absolute Beginning - MrGeek - 05-10-2013 (05-10-2013, 12:51 PM)Deque Wrote: Your "hello world" code has three mistakes that makes it not working. Sorry for my errors. Actually , this is because we have a facebook group for talking python stuffs. We posted with our mother language & translated into English. In our Zawgyi-font like you said . single quotes & double quotes are not the same as others.. here Code: ' " ‘’ “” That depends on how you target your contribution ![]() I said for linux guys Much appreciate for your reply ![]() (05-10-2013, 01:29 PM)Feurex Wrote: Please provide the download links to the python interpreter. Make it easier for others. Thanks a lot for your effort bro ![]() Fix the errors , I'm sorry. I would take care next time ![]() RE: Chp:->1 Python <-> Absolute Beginning - Psycho_Coder - 05-10-2013 (05-10-2013, 03:37 PM)MrGeek Wrote: Thanks for your advices bro Usually a guy addresses every other member on forums as bro or brother. But :lol: Call @Deque as SIS as its not "HIM" its "HER". Deque is a woman. You better address her as teacher or mam or just plainly Deque. There is not fault of yours. You just didn't knew. :lol: Seeing this "Thanks for your advices bro" made me :lol: first day when I came to know that its not "HIS" its "HER" , I was shocked :wacko: She's an awesome programmer. Her programming concepts are "JUST AWESOME" Spoiler: Just see this Too much emoticons make your post look spam, Reduced em ![]() RE: Chp:->1 Python <-> Absolute Beginning - Psycho_Coder - 05-10-2013 (05-10-2013, 03:37 PM)MrGeek Wrote: Thanks for your advices bro Usually a guy addresses every other member on forums as bro or brother. But :lol: Call @Deque as SIS as its not "HIM" its "HER". Deque is a woman. You better address her as teacher or mam or just plainly Deque. There is not fault of yours. You just didn't knew. :lol: Seeing this "Thanks for your advices bro" made me :lol: first day when I came to know that its not "HIS" its "HER" , I was shocked :wacko: She's an awesome programmer. Her programming concepts are "JUST AWESOME" Spoiler: Just see this Too much emoticons make your post look spam, Reduced em ![]() |