Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the basic basic knowledge of Python programming

Shulou Source: shulou.com Published: 2022-06-02 12:46:22 09月28日 Update

This article mainly explains "what are the basic basic knowledge of Python programming". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the basic basic knowledge of Python programming"?

1. Variables in Python

2. Python capitalization uses title () method, all uppercase upper () method, all lowercase lower () method.

3. Use the + sign for string concatenation in Python

4. Delete the space in the Python delete the rstrip () of the space at the end of the string, delete the lstrip () of the space at the beginning, and delete the strip () of the space at both ends.

5. The difference of print between Python2 and python3:

6. Integer operation in Python, using two multiplicative signs to denote multiplier operation

7. Avoid type errors in Python by using the str () function to convert values of other types into strings

8. Comments in Python

1. Variables in Python

Variable name: uppercase and lowercase, a combination of numbers and underscores, cannot start with a number

2. Python capitalization uses title () method, all uppercase upper () method, all lowercase lower () method.

> name='ce shi python'

> > name.title ()

'Ce Shi Python'

> > print (name.upper ())

CE SHI PYTHON

> > name2= "CE SHI PYTHON"

> > print (name2.lower ())

Ce shi python

3. Use the + sign for string concatenation in Python

> first_name='ce'

> > last_name= "shi"

> > full_name=first_name + last_name

> print (full_name)

Ceshi

> print ("Hello" + "" + full_name+ "" + 'roomeholders')

Hello ceshi welcome! Wuxi to see where to http://www.xasgfk.cn/ gynaecology

4. Delete the space in the Python delete the rstrip () of the space at the end of the string, delete the lstrip () of the space at the beginning, and delete the strip () of the space at both ends.

> > best_language= "python"

> > best_language = best_language.rstrip ()

> best_language

'python'

> > best_language = best_language.lstrip ()

> best_language

'python'

> > best_language= "python"

> best_language

'python'

> > best_language.strip ()

'python'

5. The difference of print between Python2 and python3:

There is no need to put what you want to print in parentheses in python2. Print in python3 is a function, so parentheses are essential; some python2's print also contain parentheses.

6. Integer operation in Python, using two multiplicative signs to denote multiplier operation

>

nine

> 10 years old 3

one thousand

7. Avoid type errors in Python by using the str () function to convert values of other types into strings

> age = 25

> message = "Happy" + str (age) + "Birthday!"

> message

'Birthdaytime Happy 25'

> print (message)

Happy 25 Birthday!

8. Comments in Python

Start with #, followed by comments

Thank you for your reading, the above is the content of "what is the basic basic knowledge of Python programming". After the study of this article, I believe you have a deeper understanding of the basic basic knowledge of Python programming, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Spaces characters strings methods knowledge introductory knowledge basics programming capitalization beginnings types operations content functions variables parentheses comments learning two both ends Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia MariaDB MySQL Xiaomi