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
mylst = [10,20,30] | |
a,b,c = mylst | |
print(c, a, b ) | |
print(a, c, b ) |
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
sum(i for i in range(5) ) |
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
str ="Python" | |
print(str * 4) |
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
matrix=[(1,2,3),(4,5,6),(7,8,9),(10,11,12)] | |
t_matrix = zip(*matrix) | |
for row in t_matrix: | |
print(row) |
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
text = "Learning python"[::-1] | |
print(text) |
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
import sys | |
mylst = ['India', 'Paris', 'London', 'Italy', 'Rome'] | |
print("size of list = ",sys.getsizeof(mylst)) |
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
i = 50 | |
j = 100 | |
i, j = j, i | |
print("i =", i) | |
print("j =", j) |
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
i = 50 | |
j = 100 | |
temp = i | |
i = j | |
j = temp | |
print('The value of i after swapping: {}'.format(i)) | |
print('The value of j after swapping: {}'.format(j)) |
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
arr1 = ['T', 'r', 'i', 'c', 'k', 's'] | |
res = "".join(arr1) | |
print (res) |
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
Numbers = [30, 32, 14, 26, 18, 18, 20, 30, 28] | |
print("Original= ", Numbers) | |
Numbers = list(set(Numbers)) | |
print("After removing duplicate= ", Numbers) |
NewerOlder