Python Basic Grammar Rookie Tutorial, Basic Grammar for Getting Started with Python

This article will talk about the basic python syntax for beginners, as well as the basic syntax for getting started with python. I hope it will be helpful to you. Don’t forget to bookmark this site.

Preface

1. Understand python

python is a scripting language. Python is an object-oriented interpreted computer programming language . The syntax is concise and clear, and one of the features is to force the use of blanks as statement indentation.

advantage:

Cross-platform, glue language, open source and free, rich library.

shortcoming:

Slow running speed, code cannot be encrypted, scenarios, data analysis, network applications, and writing simple crawlers.

1、IDLE

IDLE is python shell, and shell means "shell". It is a way to interact with programs by typing text, just like the cmd window of Windows. They are both shells. You can use them to issue commands to the operating system. Use the IDLE shell to interact with python.

2. What is the function of print()?

print() will display some text in the output window.

3、BIF

BIF is Built-in Functions, built-in functions. In order to facilitate programmers to quickly write script programs, python provides a wealth of built-in functions that can be called directly.

For example, the function of print() is to "print to the screen", and the function of input() is to receive user input. python3 provides 68 BIFs.

Enter dir ( builtns ) in python or IDLE to see the list of built-in methods provided by python (note that there are two underscores before and after builtins).

2. python common syntax

1. The title in python is * (asterisk)

2. Embed a double quote in a string: use backslash (\) to escape the double quote: ", or use single quotes to enclose the string.
Insert image description here
3. You cannot add two completely different things in python together, like numbers and text.

4. Add \n to the statement to wrap the line.

Insert image description here
You cannot add \ at the end of the original string, just add r in front.
Insert image description here
5. The print statement uses the print() function.

6. Comparison operators:

Insert image description here
Insert image description here
Insert image description here
A statement that is too long can be broken into several lines using backslashes or parentheses.
Insert image description here
Just use semicolons to separate statements.
Insert image description here
7. Loop statement:
Insert image description here
Insert image description here
8. Conditional branch:
Insert image description here
Insert image description here
9. Introduction of foreign aid:
Insert image description here
Insert image description here
10. Splicing

In some programming languages, you can "add" two strings together, such as: 'I' + 'Love' + 'You' will get 'I LoveYou'. In python, this method is called concatenating strings.

11. Do you think 'love' is the same as 'Love'?

No, love and Love are completely different names, so be careful when programming.

If an identifier can only be used in code after it has been assigned a value (python variables do not need to be declared first), using the unassigned identifier directly will cause a runtime error.

12. "=" and "==" represent different meanings.

= Indicates assignment. Before using a variable, it must be assigned a value. The variable name cannot start with a number, and the variable name can include letters, numbers, and underscores.

== is used to determine whether the values ​​of two objects are equal.

Python does not allow assignment in the if condition, so if c=1: will report an error!
Insert image description here
Note: Indentation is the soul of python. The strict requirement of indentation makes the python code appear very streamlined and layered. If you enter a colon ":" at the correct position, IDLE will automatically indent the next line.

"The indentation is four spaces."

"Python experience sharing"

It is good to learn Python whether it is employment or sideline business to make money, but to learn Python, you still need a study plan. Finally, I will share with you a full set of Python learning materials for free, and give some help to those who want to learn Python!

1. Learning routes in all directions of Python

The Python all-direction route is to organize the commonly used technical points of Python to form a summary of knowledge points in various fields. Its usefulness is that you can find corresponding learning resources according to the above knowledge points to ensure that you learn more comprehensively.
9f49b566129f47b8a67243c1008edf79.png

2. Learning software

If a worker wants to do his job well, he must first sharpen his tools. The commonly used development software for learning Python is here, which saves you a lot of time.

8c4513c1a906b72cbf93031e6781512b.png

3. Introductory learning video

When we watch videos to learn, we cannot just move our eyes and brains but not our hands. The more scientific learning method is to use them after understanding. At this time, hands-on projects are very suitable.

afc935d834c5452090670f48eda180e0.png

4. Practical cases

Optical theory is useless. You must learn to follow along and practice it in order to apply what you have learned to practice. At this time, you can learn from some practical cases.

252731a671c1fb70aad5355a2c5eeff0.png

5. Interview materials

We must learn Python to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and Alibaba bosses have given authoritative answers. After finishing this set The interview materials believe that everyone can find a satisfactory job.

6c361282296f86381401c05e862fe4e9.png

d2d978bb523c810abca3abe69e09bc1a.png

This complete version of the complete set of Python learning materials has been uploaded to CSDN.
If you need it, you can scan the CSDN official certification QR code below on WeChat to get it for free [100% free guaranteed].

Resource collection

Insert image description here

The lowest cost of making money in the world is: invest in the brain with knowledge

It is never too late to learn in life, what is late is that you have always wanted to learn but have not acted, which leads to a lot of internal friction

Finally, I wish you a happy study

Good article recommendation

Understand the prospects of python: python's future prospects, this is the most complete information I have ever seen - Programmer's Blog - CSDN Blog

What is the use of python: Introduction to python side jobs and channel recommendations, precautions for taking orders, super detailed_crawler order taking website_python-programmer's blog-CSDN blog

Guess you like

Origin blog.csdn.net/mynote/article/details/132810604