Python basics Notiz

import math
Python is CASE SENSITIVE !!

methods:

  1. basic
    1. print()
    2. input()
    1. len() to calculate length of a string, list element numbers, …
    2. find() to return the index of a character or character sequence in the string(case sensitive)
    3. replace() to replace a certain pattern to another(case sensitive)
    4. upper()
    5. lower()
  2. typecast:
    1. int()
    2. float()
  3. mathematical
    1. round()
    2. abs()

‘’’ ‘’’ string in several lines, without any indent(despite in structural blocks with automatically indent)
compare:

"""
	this is a string
	this is a string
"""
"""
this is a string
this is a string
"""

usage of ’ ’ and “”
format string:
f’ {variables}’
using curly braces to dynamically insert values

" pattern " in string variable : returns the result as a boolean value(case sensitive)

String accessing and cutting:
index could be positive and negativ.
range using [a:b]
e.g.:
abcdefgh
[0:2] : ab
[-1] : h
[-10:-1] : abcdefg
[-1:-10] : no output, no error

exponentiation: **
operator precedence
logical operators: and, or, not
comparison operators:

structural:
if

if boolean_variable:
	statement
elif boolean_variable:
else:
	statement

while

while boolean_variable:
	statement
	...
	break
else:
	statement 	//while exited normally without been breaked.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值