Instantly share code, notes, and snippets.

# pknowledge

Created August 31, 2018 20:54
Python Tutorial for Beginners - If Else statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Python Tutorial for Beginners - If Else statements x = -100 if x != 100 and x > 0: print("x is = ") print(x) if x > 0: print("x is positive") else: print("x is negative")
Created September 1, 2018 18:50
Python Tutorial for Beginners-if..elif..else statements + nested IF statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Python Tutorial for Beginners-if..elif..else statements + nested IF statements #------------nested IF statements-------- x = 10 if x >= 0: print("x is positive ") if (x%2) == 0: print("x is even") else: print("x is odd")
Last active September 1, 2018 19:00
Boolean, Comparison Operators and Logical Operators in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Python Tutorial for Beginners 10 - Boolean, Comparison Operators and Logical Operators in Python https://www.youtube.com/watch?v=0MBLkNlffT0 >>> True True >>> False False >>> true Traceback (most recent call last): File "", line 1, in
Created September 2, 2018 16:25
Python Lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 >>> x = [3, 5, 4, 9, 7, 10] >>> x [3, 5, 4, 9, 7, 10] >>> x[0] 3 >>> x[4] 7 >>> y = ['max', 1, 15.5, [3, 2]] >>> y[0] 'max'
Created September 2, 2018 19:20
Python Tuples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 >>> x = (1,5,3,4,8) >>> >>> x (1, 5, 3, 4, 8) >>> x[0] 1 >>> x[4] 8 >>> x[100] Traceback (most recent call last):
Last active September 3, 2018 13:19
Python Sets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 >>> A = {1, 2, 5, 4, 7, 9, 2} >>> A {1, 2, 4, 5, 7, 9} >>> len(A) 6 >>> A.add(10) >>> A {1, 2, 4, 5, 7, 9, 10} >>> A.add(10) >>> A
Created September 3, 2018 16:39
Python Dictionaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 >>> D = {'name': 'max', 'age': 14, 'year': 2004} >>> D {'name': 'max', 'year': 2004, 'age': 14} >>> D['name'] 'max' >>> D['age'] 14 >>> E = {'name':'Tom', 15: 15, 15.1:15.1, True: True, (2,3): 5} >>> E[(2,3)] 5
Created September 6, 2018 13:14
while Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Python Tutorial for Beginners - while Loop #--------- Example 1 --------------- i = 0 while True: print("the value of i is : ", i) i += 1 # i = i + 1 else: print("Finished while loop") #--------- Example 2 ---------------
Created September 6, 2018 14:25
Python For Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Python Tutorial for Beginners - For Loop print("For loop with Lists") A = [0, 1, 2, 3, 4, 5] # list for x in A: print(x) print("For loop with Tuples") B = (0, 1, 2, 3, 4, 5) # tuple for x in B: print(x)
Created September 7, 2018 01:10
Python Tutorial for Beginners - break and continue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Python Tutorial for Beginners - break and continue a = [0, 1, 2, 3, 4, 5] print('-----------break for loop---------------------') for x in a: if x == 2: break print(x) print('-----------continue for loop---------------------') for x in a: