Nuances between Python tutorials and C #

Source: Internet
Author: User

When using the Python language tutorial, many people use it as a comparison with C. Let's take a look at the corresponding language differences. Only by understanding the differences between the two can we differentiate them. The first thing to note is that this is not a complete Python tutorial, because there are already too many such tutorials on the Internet and in bookstores.

The main purpose of this article is to provide C # users with a brief introduction to the Python language to save their learning time. As a C # programmer, you have enough programming knowledge. You know, Python and C # are very similar. The relationship between them is similar to that between dialects and Mandarin, rather than between English and Chinese. You just need to spend some time learning about the minor differences between Python and C #, and then compile a few small programs to get familiar with it. You will find that Python is simpler than you think.

  • Object-oriented language-Python
  • Introduction to the standard Python language
  • Exploring simple and powerful Python language
  • In-depth analysis of the mysteries of the Python language
  • Summary of Python experience

In addition, the purpose of writing this serialization is not to compete in two languages, not to encourage anyone to completely switch from C # To Python. My idea is simple: Take the Python tutorial as an interest and use it whenever appropriate.

Considering the popularity of the two languages, this article will mainly introduce C #2.0 and Python 2.6. Some features that already exist in Python 2.6 but are added in C #3.0 and 4.0 will also be mentioned as appropriate.

Finally, this serialization will mainly introduce the Python language tutorial. For the preliminary chapter arrangement, please refer to the article and welcome your comments or suggestions. I will adjust it as appropriate to meet your needs ). If you have the ability and time in the future, I will continue to write some GUI, Web development and other related content.

Install and configure the Python Development Environment

On the official Python website, you can download the installation package under Windows 2.6.4. Remember to add the directory of Python such as C: \ Python26) to the system PATH variable after installation.

The Python installation package comes with a simple integrated development environment-IDLE. You can also choose your favorite IDE. I personally recommend PythonWin. Its Syntax prompt function is very good and suitable for beginners. For details, see another article "Python IDE selection".)

First Program: Hello, world!

Now you can open IDLE or PythonWin, create a Python script file with the py extension, and enter the following content:

Code 1: The first Python Program

 
 
  1. print "Hello, world!" 

Save and run it. If the output is >>hello, world! , Indicating that you have successfully compiled the first Python program, congratulations!

The above "Hello World" is almost the only way to learn any new language, as Simon Cozens, who proposed this program, said: "It is a traditional spell of the god of programming, it helps you better learn languages ".

To compare the differences between Python and C # In encoding style, a slightly more complex "Hello, world" program and its C # version are provided below.

Code 2: The Hello, world Program of Tang Seng Edition

 
 
  1. #-*-Coding: UTF-8-*-"my 2nd Python programs are only compared with C,
    Decline to follow suit :)
  2. Import sys
  3. Def Main ():
  4. Sys. stdout. write ("Hello, world! \ N ") # The following statements look strange.
    Let's explain what it is.
  5. If _ name _ = "_ main _": 11 Main ()


 

Note that line 2 of code 1st #-*-coding: UTF-8-*-is required to allow Python to support Chinese characters. If you are too troublesome, you can create a template file in IDE that only contains this line of code. This template will be automatically opened every time you create a Python script. This saves you trouble.

Code 3: Comparison of C #

 
 
  1. /* My 1,001st C # programs may not be available yet. I have not written so many
  2. */Using System;
  3. Class Program {static void Main (){
  4. If (1 = 1) // What is it? What about SQL injection?
  5. Console. WriteLine ("Hello, world! ")
  6. }
  7. }
  8.  

The above are some basic Python language Tutorials that hope to help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.