How do I get started?

Don’t worry, we need to know what Python is first. I don’t really like big words with no explanation. In short, Python is a way for you to tell your computer what to do. How, you may ask, can a computer understand English? Python has a compiler that reads your code at run time. And then translate that into computer operations, which I’ll talk about in a second about open source.

Hello World!

Writing Hello World is one of the first things you do when learning any programming language. Besides getting you excited about your first code run, it also helps you check that your current environment is working properly. The first program we run!

Focus on

Readability — We notice that the print instruction uses “print”. This may be obvious, but trust me, in other programming languages, it’s cumbersome. The command structure “system.out.println” is important, print is a function, A function that takes input in the computer world, and it also generates output, and it doesn’t return anything, but it prints whatever you want on the screen.

variable

Variables are the bricks and mortar of programming, some are standard variables built into the system, such as numbers, strings, and list values, and some are custom variables, which we will create together at the end of this article. A variable, like a container, is a name that represents one or more values. The point is, it’s really just a container!

digital

Now the meaning of variables should be self-explanatory, declare a variable is to assign a value to the variable, if you want to power (power) just use “*”. The order of operations is like junior high school math, written from left to right, parentheses first. Multiply and divide first, then add and subtract, pay attention to the order, this is very important!

string

Now strings should be a broader topic, the number of functions is infinite, but the basics are there, adding strings is just merging them together, and you can look at the substrings in string variables, slicing, and positioning them (from 0 to 2 or whatever you like). The “len” function displays the length of an object, and in this way we can extract the “Hello World” substring from the initial string. Please think about it. I don’t want to spoil the learning experience by spoon-feeding you.

Lists, tuples, dictionaries, and collection lists are fast and good at storing and manipulating large amounts of data, and are one of the most commonly used objects in Python.

Remember that the vast majority of cases, for a list of operational change itself, is the simple copy list (shallow copy) is not a real copy (deep), it’s a little ahead, but if you want to copy a list, please do so: (the above operating the second line is, in fact, store address copied lst3 and LST is essentially an object; The third line copies the value, not the storage address.) Trust me, you’ll thank me later! Tuples, sets, and dictionaries have a lot to offer, but space is limited, so I’ll cover some basic uses. Counting with a dictionary; Tuples prevent tampering with values; Collections do not allow duplicate values and process data quickly. Here are some neat tips! Python’s Collections module is an underrated library that can help you take your programming to the next level

reference

If you haven’t done any big development apps, code efficiency shouldn’t scare you, and lists are a good place to start.

Process control

Flow control is just a fancy name for an if-else statement

Elif- Executed only if the if statement is false. Indent, indent, indent! I can’t emphasize enough how many mistakes new developers in Python make for this reason alone. These four Spaces determine the block of statements. Note the position of the print statement in the if block, which does nothing if it is removed from the if block. Another important point is that == does not assign a value; it can only evaluate True and False. “Elif” occurs only when an if statement fails, to avoid testing when the number is greater than 5 and then testing again when the number is greater than 8(just an example). Combining and and or is a way to examine multiple statements.

Loops and iterations

You can iterate over lists, primitives, dictionaries, and even strings. Here’s how it works:

Loops allow you to rewrite as many times as you want. You just write once and let the code stop as many times as you want (for example, while loop) or if you want to process one data at a time iteratively, you can use animel’s method shown above.

function

As we come to the end of today’s podcast, please pay attention. The function takes input, does something with the input, and then gives feedback back to the user — the output. If you can remember those words, that’s most of what you’ll be doing.

Functions allow us to perform multiple operations over and over without having to repeat them. And it makes the code a little bit more readable, when you get to this line of code — if test_even, which is a function that checks if a number is even. This way the reader can better understand your code. Readability is important.

class

Now that a class is a component of a custom object, think of it as an architectural blueprint that will teach you how to build a building. You can build two buildings from this blueprint, they’re both one building, but not the same building, and that’s important, a class describes a thing, an object, but it’s not the object itself. OOP (Object Oriented Programming) is a deep and advanced topic, and the first paragraph represents its basic concepts, but it is an issue worth exploring in a series of articles, not one. Now an object has two main characteristics, they are properties and functions (methods), “what it is and what it can do. “

The last thing, the blueprint is the Cat class, with which I can create objects (cats), as shown below. The self property refers to the object, not the class, basically, the age of the cat, or the sex of the cat, so it’s called self, it refers to the object. We can create custom functions like play, which won’t do much in this case, but we can also override built-in Python functions like add (in this case, I made them produce a new cat object) or __repr__ to replace print. This explanation is just the tip of the iceberg, but you have to start somewhere.

conclusion

Although I know there’s a lot more to this article, I mean – a lot more, but if you pay enough attention to it, it can teach you the fundamentals of Python in a short time so that you can dive into more advanced topics. This article may be a small step towards completely changing your career and automating everything you do, but it’s a much needed step! I hope you like it! This article was adapted from: Lebyte