Step-python-02

Source: Internet
Author: User

keywords and identifiers

The following identifiers are keywords of Python3 and cannot be used for the usual identifiers. Keywords must be spelled exactly as follows:

>>> help () welcome to python 3.5 ' s help utility! if this is your first time using python, you should  definitely check outthe tutorial on the internet at http:// docs.python.org/3.5/tutorial/. enter the name of any module, keyword, or topic to get  Help on writingpython programs and using python modules.  to  quit this help utility andreturn to the interpreter, just  type  "Quit". to get a list of available modules, keywords, symbols, or  Topics, type "modules",  "keywords",  "symbols", or  "topics" .  each  Module also comeswith a one-line summary of what it does; to  list the modules whose nameor summary contain a given string such as   "spam", type  "modules spam". Help> keywordshere is a list of  the Python keywords.  Enter any keyword to get more  Help. false               def                  if                   raiseNone                 del                  import               returnTrue                 elif                 in                   tryand                  else                 is                   whileas                   except               lambda               withassert              finally              nonlocal             yieldbreak                for                  not                  class                from                or                    continue            global               pass


We don't need to specify a data type for a variable in Python. So you can write NUM1 directly . = 1, such variablesabcis an integer type. If you write num2= 1.0, then the variableabcis a floating-point type.

>>> num1=1>>> num2=1.0>>> name= "Wuxinglai" >>> print (Type (NUM1)) <class ' int '  >>>> print (Type (numnum1 num2 >>> print (Type (numnum1 num2 >>> print (Type (num2)) <class ' Float ' >>>> print (type (name)) <class ' str ' >>>>


from the example above you should understand how to define variables in Python, That is, you just need to enter the variable name and value. . Python can also manipulate strings, which are enclosed in single or double quotation marks.


reading input from the keyboard
[Email protected]:~/file/1# vim input_age.py
#!/usr/bin/python3#coding:utf8number=int (Input ("Please Input  Your age: ")) if number >= 18:        print  ("You are already an adult  your  age is %s and you are already an adult"  %number) else:        print  ("You are underage  Your age  Is %s you are a minor " %number) 

Please Input your age:18
You're already an adult. Your age was already an adult

Please Input your age:12
You're a minor Your age is a minor






















This article from "The people who are interested, things unexpectedly into" blog, declined to reprint!

Step-python-02

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.