An Introduction to Interactive Programming in Python - Week zero

Comments — CodeSkulptor
  • Non-computational parts of the program that textually describe the behavior of the program.
  • Comments begin with #, everything to right of the hash is ignored by Python.
  • Comments should be frequent so you and others can understand the code.
  • Lecture examples - CodeSkulptor
  • More examples - Comments, Strings, and Print
Strings — CodeSkulptor
  • Sequence of characters enclosed by a pair of single or double quotes
  • Examples are "cats hate dogs" and 'Strings are fun!'.
  • Strings are one kind of data in Python. Their data type is denoted str.
  • Lecture examples - Hello World
  • More examples - Comments, Strings, and Print
Numbers — Arithmetic Expressions
  • There are two kinds of numerical data in Python: integers and decimal numbers.
  • Integers correspond to the data type int. Decimal numbers are represented by floating-point numbers corresponding to the data type float.
  • Floating-point numbers have around 15 decimal digits of accuracy.
  • In CodeSkulptor, all numbers (even integers) are represented internally as floating-point numbers.
  • Lecture examples - Arithmetic Expressions
  • More examples - Floats and Ints
Arithmetic Operators — Arithmetic Expressions
  • Five basic arithmetic operators; addition (+), subtraction (-), multiplication (*), division (/) and exponentiation (**)
  • CodeSkulptor implements a subset of Python 2. In Python 2, the division operator (/) returns a float approximation to the exact answer if either of the operands is a  float.  If both operands are integers, division returns the exact answer round down to the nearest integer.
  • The integer division operator // returns the quotient of two numbers..
  • Lecture examples - Arithmetic Expressions
  • More examples - Arithmetic OperationsDivision
Arithmetic Expressions — Arithmetic Expressions
Variables — Variables
  • Variable names consist of a sequence of letters, number and underscores (_).
  • Variable names start with a letter or underscore and are case sensitive.
  • Single equals (=) is used for assignment to variables. Double equals (==) is used for testing equality.
  • Lecture examples - Variables
  • More examples - Variable NamingVabiable AssignmentVariable OperationsFormulas
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值