Python

Basics

def main():
    x = [1, 2, 3, 4]
    for i in range(len(x)):
        print("The %dth number of List x is %d".format(i, x[i]))

if __name__ == "__main__":
    main()

print

python3: {} python2: %d

delivering function parameters

for loop

range is removed in python3 xrange is replaced with range for i in range(end, start-1, -1): print(i)

devide

1/2=0.5 in python3 1//2 = 0 in python3

File Input and Output

file = open("input.txt")
x = file.readline()
print(x)

String Format

Python2 vs Python3 https://pyformat.info/

results matching ""

    No results matching ""