1. Trang chủ
  2. » Công Nghệ Thông Tin

Python 3 Beginners Reference

2 2 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

PowerPoint Presentation Python 3 Beginners Reference Cheat Sheet Special characters coment new line scape char Numeric operators + addition subtraction multiplication division exp.PowerPoint Presentation Python 3 Beginners Reference Cheat Sheet Special characters coment new line scape char Numeric operators + addition subtraction multiplication division exp.

Alvaro Sebastian http://www.sixthresearcher.com Python Beginner's Reference Cheat Sheet Main data types List operations boolean = True / False integer = 10 float = 10.01 string = “123abc” list = [ value1, value2, … ] dictionary = { key1:value1, key2:value2, …} Numeric operators + * / ** % // addition subtraction multiplication division exponent modulus floor division Boolean operators and or not logical AND logical OR logical NOT list = [] list[i] = x list[i] list[-1] list[i:j] del list[i] Comparison operators defines an empty list stores x with index i retrieves the item with index I retrieves last item retrieves items in the range i to j removes the item with index i Dictionary operations List methods list.append(x) adds x to the end of the list list.extend(L) appends L to the end of the list list.insert(i,x) inserts x at i position list.remove(x) removes the first list item whose value is x removes the item at position i and returns its value removes all items from the list list.pop(i) list.clear() == equal dict = {} defines an empty dictionary != different dict[k] = x stores x associated to key k > higher dict[k] retrieves the item with key k < lower list.sort() returns a list of values delimited by x returns a string with list values joined by S sorts list items del dict[k] removes the item with key k >= higher or equal list.reverse() reverses list elements

Ngày đăng: 09/09/2022, 20:10

w