Name
Login
Password
Repeat password
Email
Log in via social networks:
or internal authorization:
Login
Remind me?
Password
Remind me?
Schedule
Prices
Tests
Forum
About us
Log In Registration
Basics of programming for dummies
“I have always dreamed that my computer could be used as easily as a phone; my dream has come true: I can no longer figure out how to use my phone.”
Bjorn Stroustrup
programmer, author of the C++programming language.
More and more people nowadays want to learn how to program.
I think no one needs to be convinced that in our age of information technology, every person with a technical education needs to know the basics of programming, even at the level of "for dummies".
Of course, this article does not pretend to be a comprehensive description of the various nuances of creating programs, but I think some generalization of "computer tricks" will be useful.
For those who are just going to learn programming, it is important to start with mastering the basics of programming for dummies - in the future this will help save time and effort.
A course for novice programmers
Fragment of the first lecture of the course of a young fighter
The principles that are used when writing programs are formulated in the form of short theses that explain the "whales" of modern programming languages.
The first and most basic principle of programming for dummies is the widest use of knowledge from various branches of mathematics for writing programs.
The first and most basic principle of programming for dummies is the widest use of knowledge from various branches of mathematics for writing programs.
Of course, you will most often not need to thoroughly understand all the subtleties of higher mathematics (unless you are programming complex mathematical calculations), but at least the basics of algebra and the ability to read mathematical formulas are necessary.
The key concept in programming is a variable a letter designation for a number that migrated to programming from mathematics.
Each of you once solved equations in algebra lessons or plotted a function graph.
Take, for example, the well known graph of a straight line: y = 2x + 1 Both in programming and in algebra, the result of an expression means the same thing: the expression 2x + 1 will be written in the variable y.
However, the value of the variable x will be determined differently by a mathematician and a programmer.
Remember how mathematical formulas differ from programmed ones.
The second main problem of programming for dummies is that in order to write a program, you need not only knowledge of mathematics, but also an understanding of how the recording of a mathematical formula in programming differs from that in classical algebra.
The answer that should be entered in the" Programming Bible for Dummies " is differences in practical work with variables.
A well known example illustrating the basic basis of programming for dummies:
x = x + 1
From the point of view of classical algebra, an equation is written here that has neither a solution nor a meaning: the unknown, denoted by the letter x, can in no way be greater than itself by one.
For a programmer, a variable has a certain value at each moment of time.
This expression will tell the programmer that its previous value, increased by one, is written to the variable.
Well, from the programmer's point of view, everything is correct and logical.
Teach the program to respond to external parameters
Even the most novice programmer who is just learning the basics of programming for dummies knows that mathematical expressions alone are not enough to write at least some serious program.
The program must be able to respond to external conditions and change its behavior depending on them.
Here the basic construction of any programming language comes to the rescue: IF THEN.
Not everyone knows that the condition is also used when compiling any algorithm, whether it is human behavior or machine operation.
An example of a condition from real life:
IF it's snowing outside, THEN you need to take an umbrella
After the word IF, there is always a condition, when fulfilled, an action occurs that stands after the word THEN.
This design is simply irreplaceable and is the basis of programming for everyone: dummies and hackers.
Let's give a more "programmer" example of the condition: let's make sure when calculating the expression c = a ÷ b that the divisor of b is not equal to 0 and calculate the quotient.
IF b is not equal to 0, THEN c = a ÷ b
If necessary, use loops to repeat the program code the desired number of times.
Another basic programming construct that the kettle should learn is loops.
A cycle is a repeated repetition of a certain program block.
They are used by programmers very widely and almost certainly you will find them in any program code.
Let's say the programmer was given the task to make a table of values of a mathematical function that is already familiar to us: y = 2x + 1 for integers x that are in the range from 1 to 10.
Such tasks, although due to their simplicity and are used to study the basics of programming by dummies, are nevertheless very useful for understanding when a cycle should be applied - when you need to repeat the same action N times.
Any cycle has three characteristics that determine its operation: the initial value, the condition for the end of the cycle, and the increment.
Let's consider our example of calculating the function value table and determine what these characteristics will be in our case.
The initial condition of the loop, this is the value that we start working with when we first start the loop.
Since we start calculating the values of the function with the minimum value, the initial value of the cycle x = 1 Increment is the number by which the value of x changes at each iteration of the cycle.
In our example, to plot the function by points 1, 2, 3, ...., 9, 10 we use an increment of 1.
However, changing the increment can seriously change the operation of the cycle.
If, for example, the increment is equal to 3, then the table will consist of the function values for points 1, 4, 7, 10.
The condition for the end of the cycle is the sign that tells when to stop performing repetitive actions.
You need to finish reading the value of the function when the value of x exceeds 10.
Thus, the condition for the end of the cycle in our case is x <=10
For example, let's give how this basic programming construct is written, in a free form understandable for dummies.
x = 1 (*initial condition of the loop *)
UNTIL x <=10 (*loop end condition *)
EXECUTE COMMANDS IN A LOOP
y = 2x + 1 (* the action performed in the loop *)
x = x + 1 (*cycle increment *)
END OF THE CYCLE
Basics of programming functions for dummies:
the principle of divide and conquer
Let's formulate the last basic principle of the basics of programming for dummies - the use of functions.
Functions are blocks of code that can be called repeatedly from anywhere in your program.
Programmers use functions very widely.
Any function consists of the following components:
The function name is a string that is used when calling (starting) and when the name is correctly set, it helps to understand what the function does.
The accepted parameters (function arguments) are values that are used for further calculations or to control the behavior of the function when called.
The return value is actually what the writing of the function was started for - the result of the work that can be obtained and used in the further work of the program.
The basic principles of creating functions for dummies programmers are as follows:
The function combines a logically separate section of code.
Ideally, each function should perform a well defined action: for example, calculate the value of the sine function, count the number of letters " e " in a line, or write text to a file.
Usually, those parts of the program that are repeatedly used during execution are designed as a function.
This technique reduces the number of lines of code (which makes it easier to understand the written program code) and makes it easier to edit and make changes to the program.
To control the behavior of a function from the call point, use the parameters (arguments) when calling the function.
It happens that a function is created without accepted parameters - this means that it will return the same value regardless of the place of execution of your program (especially for those who study only the basics of programming).
The return value is the result of the function.
There are functions that do not return any value, at the first stage it is better not to use such functions - most often this is an error when designing a program.
I have listed only the basic principles of programming for dummies, which, I hope, will help you take the first steps in this exciting lesson.
Have you decided to become a programmer, but you are not sure that you will be able to master all the" wisdom " of program development?
I invite you to sign up for our author's "Young Fighter Course".
From the course you will learn how to write your first program and which programming direction suits you the most
Vladimir Ivanov
2016-02-01
4.5 5 52
1 2 3 4 5 6 7 8 9 10
See also:
How to become a programmer?
How to Learn to Program from Scratch Programming from Scratch.
The best way to learn
Recruitment to groups:
The course of a young fighter
Teacher:
Denis Nikolaenko
Classes start: February 6
Mon-- Tue-- Wed-- Thu-- Fri-- Sat18: 00 Sun--
Course description
The course of a young fighter
Teacher:
Denis Nikolaenko
Classes start: February 16
Mon-- Tue 19: 00 Wed-- Cht19:00 Fri-- Sat-- Sun--
Course description
Contacts:
© 2014 progstudy.ru
+7 (495) 766-76-21
support@progstudy.ru
