Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the experience of using Python?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how the Python experience is, the quality of the article content is high, so Xiaobian shares it with you as a reference, I hope you have a certain understanding of related knowledge after reading this article.

Basics 1. Comment lines: 2. literal constants: a numbers: divided into integers and floats; b strings: can use single quotes (') double quotes ('') and triple quotes ('' or """) to define strings, note that you can also define strings with format, sometimes if the string contains ', python will be confused about the position of the beginning and end of the string, such as ('what's your name'), then you need to use escape sequences, become ('what's your name' or"what's your nanme'); c variables: variable definitions can only be composed of upper and lower case letters, underscores (_) and numbers.

Operator and Expression 1 Operator: Add (+) Subtract (-) Multiply (*) Multiply (**) Divide (/) Divide (//) Modulo ( %) Shift Left () Bitwise and (&) Bitwise or (||(== Boolean not Boolean and Boolean or Boolean 2 Evaluation order: lambda: Lambda expression if - else: conditional expression or: Boolean "or" and: Boolean "and" not x: Boolean "not" in, not in, is, is not, =, !=, ==: Comparison, including Membership Tests and Identity Tests. | : bitwise or ^: bitwise XOR &: By Position and: Move +, -: Add and subtract *, /, //, %: multiply, divide, divide, remainder +x, -x, ~x: positive, negative, bitwise negation **: exponentiation x[index], x[index:index], x(arguments…), x.attribute: subscript, slice, call, attribute quote (expressions…), [expressions…], {key: value…}, {expressions…}: display bindings or arrays, display lists, display dictionaries, display settings 3; change evaluation order parenthesis ()

Control flow 1 If the condition is true execute, if flase execute the statement in else-block

number = 23guess = int(input ('Enter an integer:'))if guess == number:#New block starts here print ('Congratulations, you guessed it. ')print('(but you do not win any prizes!) ')#new block ends here elif guess

< number:# 另一代码块print('No, it is a little higher than that')# 你可以在此做任何你希望在该代码块内进行的事情else:print('No, it is a little lower than that')# 你必须通过猜测一个大于(>

Set the number of numbers to get here. print ('Done ')#This last statement is executed after the # if statement has been executed.

2 while If the condition is true, repeat the statement in while; if the while condition is flase, it does not hold, jumping out of the while loop

i=0while(i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report