美文网首页
python学习笔记

python学习笔记

作者: Imshfer | 来源:发表于2019-10-31 21:26 被阅读0次

python学习笔记

python’s syntactical instructions are easier to write rather than C language or others. This is the summary of what I learn so far and I will continuously update it. Meanwhile, there will be some comparisons with C language.

At the beginning, let’s say hello to the python.

Print() can print anything you want to show. It can be a string with single quotes or double quotes no matter how many characters it has, or a number.

Input() can help you input anything you want. But they are all in the type of string. So, if you want it to be a integer or floating-point data type, you need to convert the type by using int() or float().  Or sometimes you want to change a non-string data to a string, you can use the str()

Python don’t have a strict data type definition like C. So the value definition can easily access like name = “Noki”, age = 21. If you want it to be a string, just add the quotes. Note that there is a white space between the operation, even the comma. Python has a strange syntax instruction that you will get a hint when there are too many lines between two statements or a error when there is a indent of the statement.

String has much syntax. ‘+’ connect two strings; ‘*’replicate the string a number of times; .upper() change the character in all caps, and the .lower() inverse;  .index() evaluate the location demanded; .replace() replace the words. ; len() evaluate the length; xxx[location] to display the pointed letter......

You can also use many operations and mathematics.For more sophisticated math, give a statement at the top of the interactive shell: from math import *

Know some math operation: abs, pow, sqrt, ceil, floor, round.

相关文章

网友评论

      本文标题:python学习笔记

      本文链接:https://www.haomeiwen.com/subject/sykxbctx.html