How to Learn programming? -- Thoughts on Programming Language Learning for beginners (2)
Write by nine days Yan Ling (jtianling) -- blog.csdn.net/vagrxie
Discuss newsgroups and documents
As a person who has been studying programming for several years and is still living in the world with C ++, I can also find the fun of programming in these simple graphics, which is the pleasure of Turtle. I think beginners will have more fun than me.
In fact, for preliminary programming, the most important thing is the process control, and the process control is also in several forms. Here is a process control table I previously wrote for python, in fact, all types of languages are similar:
Basic Computer and program model:
Basic Program Execution Process
- Sequential execution:
Python statement.
- Branch:
Python: If-Else
Python syntax format: If-Elif-
3. Loop:
Python syntax format: For-in
In addition to slightly different syntaxes, different languages are basically the same. These are the foundation for cultivating the logic of computer thinking and can also be considered as the preliminary knowledge of programming, at least small basic is useful for mastering this knowledge, although its design was originally intended for children. Do not think that small basic is designed for children because it is not functional enough to learn it. In fact, because Sb attaches great importance to graphics, it makes it easy to control graphics, instead, you can easily do some interesting things.
For example, the following example (the brilliant text display comes from the http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/b1b383c1-6b13-49c0-bf29-00de86103ac6)
Just a few lines of code:
Graphicswindow. backgroundcolor = "Midnight"
GW = graphicswindow. Width
GH = graphicswindow. Height
Graphicswindow. fontsize = 100
Turtle. Move (100)
Turtle. Turn (1*1)
While ("true ")
For I = 1 to 50
Graphicswindow. setpixel (math. getrandomnumber (GW), math. getrandomnumber (GH), graphicswindow. getrandomcolor ())
Endfor
Turtle. Move (1)
Graphicswindow. brushcolor = "black"
Graphicswindow. drawboundtext (30,110, gw-20, "small basic ")
Endwhile
This is a program that almost everyone will say "impressive" after execution.
Here are some more Sb program diagrams:
Everybody can go to (http://social.msdn.microsoft.com/Forums/en-US/smallbasic/threads)
There are many interesting examples.
As a matter of fact, I did not encourage everyone to learn small basic. I just pointed out a path for beginners. I think the complexity of programming comes from mathematics, thinking, and logic, it is not the programming language. Even a kids language such as Sb has the same powerful effect under a reasonable thinking logic, and the nature of the programming language has not changed.
"Small basic is a project that's aimed at bringing" fun "back to programming." Ms says, indeed, when did we lose the fun of programming? Why are we using such a huge and incomprehensible language? Because of commercial needs, a modern software is so huge that it is like a collection of new features and a large number of databases .... It makes us lose so much fun.
Of course, if it is only limited to sb language, its usage is still limited, and the educational significance is not that great .... Although I feel I can have fun from SB,... People still want to eat, so for people who want to use programming as a profession, it is also a good idea to start from Python (just from the perspective of learning, at present, the domestic demand for python is still relatively limited ). At that time, I was thinking about using pyqt to implement a turtle library exactly the same as sb. After reading the results, I found that the python standard library was included, the richness and compatibility of the python standard library is simply unimaginable ........ Can you imagine the day when a library named C ++ was added to the library? -_-!
The turtle library is included in the python standard library, so we can use the python syntax to implement the above functions, at the same time, some Python functions are more powerful than Sb (the turtle library of Python has more functions), and the functions of Python syntax are also familiar. If python is the first step for beginners to step into programming, I think the use of the python turtle library can be the first step for learning python. First of all, I am familiar with the thinking and logic of the program. The other is just the extension of the program. (Even up to the DP and OO layers, these are indispensable foundations)
Here is an example of the most complex ring structure implemented by sb. The rest is omitted. It should be said that although python can be used with more familiar syntaxes, but after returning to the python editor, I found that the IDE of Sb is really 'impressive...
Source code:
Import turtle
Tr = turtle. getturtle ()
Tr. shape ("Turtle ")
Tr. Speed ('fast ')
In_times = 40
Times = 20
For I in range (times ):
Tr. Right (360/times)
Tr. Forward (200/times)
For J in range (in_times ):
Tr. Right (360/in_times)
Tr. Forward (400/in_times)
# Tr. Write ("Click me to exit", font = ("Courier", 12, "bold "))
Screen = turtle. Screen ()
Screen. exitonclick ()
Let's take a look at the example code in the python turtle library. The complicated operations make you mistakenly think that this is the result of flash. In fact, this is just a crawling of turtles. Well, to do a lot of things with a tortoise, in addition to a good mathematical foundation, you also need a bit of imagination ....... Of course, there is beauty. Gregor lingl obviously does not lack this, so he completed a very interesting turtle library and a very interesting example.
It is estimated that the basic syntax familiar with Python with Turtle is no problem and fun. Fun is the most important thing for beginners. In addition, when you want to use it to implement more complex logic, you also have to use more Python features. This natural process will promote/consolidate Python learning. In addition to learning a language, another beginner may be able to get started on a journey of fun.
Write by nine days Yan Ling (jtianling) -- blog.csdn.net/vagrxie