Python basic OUTPUT statement/INPUT statement/variable parsing

Source: Internet
Author: User

Print formatted output

#-*-coding:utf-8-*-#Print (Format (val, ' M,n '))#val: Value format_modifier: Output placeholder m, accuracy nPrint(Format (12.3456,'6.2f' )) 12.35Print(Format (12.3456,'6.3f' ))12.346Print(Format (12.3456,'6.6f' ))12.345600Print(Format (12.3456,'6.0f' ))    12

Print input statement

The value received by input is converted to a character type, and int () converts the value to integer data, and float () converts the value to floating-point data

#-*-coding:utf-8-*-name= Raw_input ('Please enter your name:')PrintnamePrinttype (name) age= Raw_input ('Please enter your age:') Age=Int (age)Printtype (age) age= age + 1PrintAgeweight= Float (Raw_input ('Please enter your weight:'))PrintWeightPrinttype (weight)"""Run Results"""Please enter your name: Leelee<type'Str'>Please enter your age:13<type'int'>14Please enter your weight:40.2240.22<type'float'>

Variable resolution

Variable change only point to address does not change point to content

# -*-coding:utf-8-*-   = print = Print = y print = Print  Z, id (z)""" run result """ 13 7349606412 7349607612 7349607613 73496064

Python basic OUTPUT statement/INPUT statement/variable parsing

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.