新建一个test.py文件,右键选择“Edit with IDLE”,编辑完成后,Ctrl+S保存,然后按下F5就可以执行代码了。

注:IDLE是Python官方提供的一个IDE工具。

目录

[隐藏

[编辑]注释

#This is a comment
print"This will run."#comment
多行注释使用三个单引号(''')或三个双引号(""")。

[编辑]数字

print 25 + 30 / 6
print"Is it true that 3+2 < 5-7?"
print 3+2<5-7

输出:

30 Is it true that 3+2<5-7? False

[编辑]变量

cars =100
print"There are", cars,"cars available."

输出:

There are 100 cars available. 
my_name ="Lei Jun" your_name ="Jobs"
print"Let's talk about", my_name print"Let's talk about %s and %s." % (my_name, your_name)

输出:

Let's talk about Lei Jun Let's talk about Lei Jun and Jobs. 

[编辑]输入用法

print"How old are you?" age =raw_input()
print"You're %s old."% age

输出:

How old are you? 27 You're 27 old. 

age =raw_input("How old are you?")
print"You're %s old."% age

输出:

How old are you?38 You're 38 old.

循序渐进学Python2变量与输入的更多相关文章

  1. 循序渐进学.Net Core Web Api开发系列【7】:项目发布到CentOS7

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.概述 本篇讨论如 ...

  2. 学python2.7简单还是python3.0简单,两者区别

    学python2.7简单还是python3.0简单,谈谈两者区别 1. 使用__future__模块 Python 3.X 引入了一些与Python 2 不兼容的关键字和特性.在Python 2中,可 ...

  3. 循序渐进学.Net Core Web Api开发系列【14】:异常处理

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.概述 本篇介绍异 ...

  4. 循序渐进学.Net Core Web Api开发系列【13】:中间件(Middleware)

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.概述 本篇介绍如 ...

  5. 循序渐进学.Net Core Web Api开发系列【11】:依赖注入

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.概述 本篇介绍如 ...

  6. 循序渐进学.Net Core Web Api开发系列【9】:常用的数据库操作

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.概述 本篇描述一 ...

  7. 循序渐进学.Net Core Web Api开发系列【6】:配置文件appsettings.json

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.本篇概述 本篇描 ...

  8. 循序渐进学.Net Core Web Api开发系列【3】:WebApi开发概览

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.概述 目前我们已 ...

  9. 循序渐进学.Net Core Web Api开发系列【2】:利用Swagger调试WebApi

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.概述 既然前后端 ...

随机推荐

  1. phpMyAdmin操作之改管理员密码

    1.登录phpMyAdmin 默认地址:http://localhost/phpmyadmin 2.点击用户按钮 3.往下拉找到修改密码 点执行就修改了 注意: 如果再次登录时报错提示: #1045 ...

  2. hdu 3501 容斥原理或欧拉函数

    Calculation 2 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  3. 【BZOJ4945&&UOJ317】游戏(2-sat,拓扑序)

    题意: 思路: 输出方案时有一个优秀的性质可以利用: tarjan缩点之后点所属的分量编号是原图的反的拓扑序 所以只需要在两种方案内找到所属分量编号较小的那个就行了,用来满足(i,i')那个限制 #i ...

  4. FNV与FNV-1a Hash算法说明【转】

    转自:http://blog.csdn.net/jiayanhui2877/article/details/12090575 The core of the FNV hash The core of ...

  5. 23深入理解C指针之---数组的基础

    数组是c语言内置的数据结构,数组有一维数组.二维数组和多维数组.使用数组传递数组时,必须传入数组的大小. 一.数组的特征:阐明数组的特点 1.数组要素: 1).数组类型:数组中存储的数据的类型: 2) ...

  6. 使用 PHPMailer 发邮件

    /** * 发邮件 * * @param array $receiver 接收人信息 * @param array $attachment_info 附件信息 * @param string $is_ ...

  7. Lua开发环境搭建(Mac OS X)

    1. 安装Rudix Rudix: http://rudix.org curl -O https://raw.githubusercontent.com/rudix-mac/rpm/2015.4/ru ...

  8. java string中indexOf()常用用法

    Java中字符串中子串的查找共有四种方法,如下: 1.int indexOf(String str) :返回第一次出现的指定子字符串在此字符串中的索引. 2.int indexOf(String st ...

  9. HRBUST 2078:糖果(模拟,贪心)

    题不难,但作为一道恶心到了我的题,我还是记录一下的好. 题意:n个人围一圈,要求:相邻两人,分数高的要比分数低的得到更多的糖果,若分数相同则必须得到相同数量的糖果.问满足要求的最少需要分配的糖果数.( ...

  10. jquery小技巧:使用jquery.confirm和PNotify实现弹出提示和消息提示

    在从UIKIT前端换到BOOSTRAP前端时,一些转换的技巧. https://myclabs.github.io/jquery.confirm/ http://sciactive.github.io ...