Skip to content

Instantly share code, notes, and snippets.

@enseitankad0
Created February 28, 2018 21:33
Show Gist options
  • Save enseitankad0/01611d33628c3888974f737faf483e91 to your computer and use it in GitHub Desktop.
Save enseitankad0/01611d33628c3888974f737faf483e91 to your computer and use it in GitHub Desktop.
#my very basics in python
print("Hello world for first time");
type(2) # return data type
####### setting value for variables #######
a = b = c = 1.5
print(a)
print(b)
print(c)
#different method
one, two, three = 1, 'two', 3.0
print(one)
# type(one) = <int>
import keyword
print(keyword.kwlist)
#['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif',
#['else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or',
# 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
####### cleaning screen working in console #######
#
# import os
# clear = lambda: os.system('cls')
# clear()
#creating multiline comment ctrl and /
# asdasdsad
# asdas
# asdasd
# asdasdasdas
####### manipuilating numbers in python #######
a=5/2
print(a) # 2.5
a=5//2
print(a) # 2
b = 2.0 + 5
print(b) #result will be 7.0
b = 2 + 5 #result will be 7 without .0
print(b)
c=3**3 #=27
print(c)
d=(25.0 % 4)
print(d) # result is 1.0
####### binary number manipulation #######
print(1<<3)
#we have 00001
#switch 3 times to left side
#01000 - we have 8 as a final result
print(32>>5)
#we have 0100000
#switch 5 times to right
#we've got 000001 = 1
print(256 & 255)
# compare numbers
# 1000000000
# 0111111111
print(256 | 255)
# compare numbers
# 1000000000
# 0111111111
# 1111111111
print(60 ^ 13)
# compare numbers
#
# 111100
# 001101
# 110001 = 49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment