Xiao Huangji learns python (c language foundation)

I finally finished writing my graduation project opening report, and there is a package of things that follow, so I can only go with the flow.

I wrote a 10-day postgraduate entrance examination plan, and I was so smug that I slept in the dormitory until 10 o'clock the next day and woke up. . . Then, I slept like this for two days, who told me that I didn't have the habit of setting an alarm clock! Who told me to play mahjong on the applet the night before. . .

During the two days in the dormitory, I did a good search for the existing python learning resources on the Internet, and planned to speed it up online. I searched on several online course platforms, including: MOOC, NetEase Cloud Classroom, Tencent Open Class, and a w3school? I can't remember the name

What I think is better is a class called "Let's Learn Python from Zero Basics" in NetEase Cloud Classroom

(Portal: http://study.163.com/course/courseLearn.htm?courseId=378003#/learn/video?lessonId=495049&courseId=378003)

Compared to the other direct and crude indoctrination, this course is soft and light-hearted. Moreover, it is very detailed, and some difficult points will be assigned classwork after class. The most important thing is to talk about python3! I only found out after listening to 2 of the courses on the Internet that teach python2! Can you write on the topic not to waste each other's time!

ok! There is a lot of nonsense. Let’s talk about some knowledge that Xiao Huangji has learned about python compared to c. I will update more later. I have only listened to 5 and 6 now (sorry, I will definitely stop playing mahjong!) :

Lecture 1:

1. Do not add ";" at the end of the statement

2. python3 is different from python2, print "I love u" can be used in python2, and "()" must be added in python3

3. Use "+" for splicing between strings, use + to add between numbers, and "+" cannot be used between strings and numbers


Second lecture:

1. If and else conditional sentences followed by ":" will be automatically indented, or you can press the tap key to indent. Indentation is the soul of python, indentation defines the format instead of parentheses in C language. Let the code specification have a hierarchy.

2.input() directly represents the input character, "()" fills in the literature to be displayed (the string should be enclosed in double quotation marks)

3. Enter dir(_builtins_) in idel to get bif (the lowercase ones), if you want to know the details of a bif, enter help (the name of the bif)


Lecture three:

1. The naming rules of variables are the same as those of C language. They cannot start with numbers, but letters, numbers, and underscores can be used. Different capitalization is not the same as two variables.

2.5+8 gets the sum 13, and '5'+'8' gets the concatenated string '58'

3. If you need to print single quotes and double quotes, you can use \ (escape character) to escape

You can also add r after str= to get the original string, and add the escape character \ before all characters

If you need to add the escape character \ at the end of the string, you need to turn the string into a concatenation of two strings

如:>>>str=r'c\program file\hhh''\\'


Fourth lecture:

1. Logical operators connect arbitrary expressions to get values ​​of type bool, such as true and false

2. The random module has a function randint that returns random integers

Code:

import random

s=random.randint(1,10)


Lecture five:

1.e notation means scientific notation, representing the power of 10, which is recorded as floating point type

2. true represents 1, false represents 0, not non-zero integer result is false (ie 0)

3.type() Add variables in parentheses to display the type of variables

4.isinstance() write the variable and the variable type to be compared in parentheses

Such as:

a = "good good"

isinstance(a,str)

will get a result of type bool


Lecture 6:

1.\ stands for ordinary division, \\ stands for rounding division, ** is followed by the power of the previous number

2. Priority! Can't carry it! ! ! ! !




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324394649&siteId=291194637