Introduction to programming in Python and JavaScript - Issue#1

in #utopian-io7 years ago

Python-JavaScript.jpg
Image Source

1. Introduction


About Python

Python is a portable, dynamic, extensible, free language that allows (without impose it) a modular and object-oriented approach to programming. Python is developed since 1989 by Guido van Rossum and many volunteer contributors.

Here is an overview of some features of the Python language.

  1. Python is free and portable: it exists on Linux, Unix, Mac and Windows.
  2. The Python syntax allows you to write compact and readable programs.
  3. Python is a language that continues to evolve, supported by a community of users
    most of whom are supporters of free software.
  4. Python is a language of choice for processing XML.

About JavaScript

JavaScript is used in millions of web pages to improve their design. This is an additional programming layer that adds to the language HTML 1. HTML is the basic language that any web page should use:
in addition to its role as a word processor, this language allows you to surf through hypertext links. As for JavaScript, it was designed to give more interactivity to HTML pages. The script word indicates that it is a simplified programming language which runs locally on the computer that is reading the web page. This language, like HTML, does not require the purchase of any license to use it. Initially, JavaScript was developed by Netscape, but now most browsers for browsing the Internet are compatible with JavaScript.

Here is an overview of some features of the JavaScript language.

  1. JavaScript is already installed on the vast majority of Internet browsers.
  2. JavaScript is free and portable: it exists on Linux, Unix, Mac and Windows.
  3. JavaScript delivers to web designers a programming tool with a elementary syntax.
  4. JavaScript allows the use of dynamic texts in a web page: you can for example, show today's date.
  5. JavaScript can react to a particular event. For example when a page has finished loading or when a user clicks on an HTML element.

JavaScript and Java are two different languages

It is important to make it clear that even though the names are very close, Java and JavaScript are two very different languages. Java is developed by Sun Microsystems and is a much more powerful and complex programming language than JavaScript. Java can be compared to the C ++ language


2. The program "Hello World!"


This is the first program a user creates when making a contact withan unknown programming language. It consists of displaying the text "Hello World!".


JavaScript version

Here are the steps to follow, under Windows, in order to operate this program.

  1. Open a text editor such as Notepad or Notepad ++. It is important to not use advanced features of the layout and always save the document in text mode.
  2. Create the following two files in the same directory. The first will be an HTML file, the second will be the JavaScript code.
    I) File page.html
 <html>
<body>
<script src="hello.js"></script>
</body>
</html>

II) File Hello.js
document.write("Hello World!")

3 . Double-click the page.html file icon to run the Internet Explorer by default. The hello.js script will be automatically interpreted.

The <html> ... </ html>tag tells the Internet Explorer that the file is written in HTML. As for the <body> ... </ body> tag, it indicates that it is the body of the HTML document. Finally, the <script src = 'hello.js'> </ script> tag tells the Internet Explorer that we will have to interpret in JavaScript the contents of the file hello.js.
In the hello.js file, the JavaScript document.write command allows you to write on the page.HTML displayed by the Internet Explorer.


Comments in JavaScript and HTML

When planning, always comment on what the program does it is quickly understandable. Companies like Google engage only programmers who have a clear and readable code (so well documented). Now, a comment is easy to put: any text that follows // is not interpreted by JavaScript.
Nevertheless, // only works for one line. If you want to write a comment several lines, we can also use / * to start the comment and* / for finish it. Here are two ways to write a comment on multiple lines.

Sample1Sample2
// This is a comment/ * This is a comment on several lines * /
// on multiple lines

Not to be confused with the language comment tags that are the following and operate independently of the number of lines.
<! - This is a comment in HTML ->


The Python version

Here are the steps to follow, under Windows, in order to operate this program.

  1. Install Python. On Windows, we will use PortablePython. We can also use
    MovableIDLE. These two environments have the enormous advantage of being portable,
    that is, they can be installed on a USB stick and thus allow their run on any PC.
  2. Open the PyScripter-Portable.exe editor.
  3. Type the following text in the main window.
    print ("Hello World!")
  4. Save the document as hello.py and click on the green iconplay button (all right on the image below).
    pyt1.png
    The print command is used to write Hello World !, below the symbols >>>
    which signal the interpretation of the script (program), in the window called Python Interpreter at the bottom of the screen.
    pyt2.png

Alternative. When you want to test a command in Python, you can directly type it in the Python Interpreter window. The result is instantaneous.

In Python, a comment is easy to put: all the text that follows is not interpreter.
The PyScripter program allows to put several lines in comments. For this, just select them and use the keyboard shortcut CTRL- '(the key next from 0). This shortcut acts as a switch and comments / uncommitted lines selected. It is set to add or remove a ## pair and does not interfere with simple comments #.

Sample1Sample2
# This is a comment## This is a comment
# on multiple lines## on multiple lines

The advantage of the second version is that pressing CTRL- 'will remove the comment and a second press allows to put it back.

Tutorial Continued in next post.

Thanks For Reading.....................................



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thanks Sir, for the approval. I post the next post of this tutorial https://utopian.io/u/23185335. Please go through it. Thanks Again.

Hey @meblogger I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • This is your first accepted contribution here in Utopian. Welcome!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x