Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. '''core python'''
  2.  
  3. '''#type()
  4. a="parthiduce"
  5. b=6
  6. c=5.0
  7. d=5+1j
  8. type(a)
  9. type(b)
  10. type(c)
  11. type(d)
  12.  
  13.  
  14.  
  15. #variables
  16. a=int(input("enter the number"))
  17. b=input("enter name")
  18.  
  19.  
  20.  
  21. ##operators
  22. #arithmatic(+,-,*,/,**,//)
  23. #assignment(a+=10,a-=2)
  24. #logic(a==10&&b==6)(a or b)(a not b)
  25. #bitwise(&,|,^,>>,<<,~)
  26. #membership(in,not in)
  27. #identify(is,is not)
  28.  
  29.  
  30. ##conditional statements
  31. #if
  32. a=6
  33. if a==6:
  34. print("parthi duce")
  35.  
  36.  
  37. #if else
  38.  
  39. a=6
  40. if a==5:
  41. print("parthi")
  42. else:
  43. print("duce")
  44.  
  45.  
  46. ##elif
  47.  
  48. a=6
  49. b=7
  50. if a==5:
  51. print("done")
  52. elif b==6:
  53. print("success")
  54. elif a==6:
  55. print("bravo")
  56. else:
  57. print("good")
  58.  
  59. ##nested if
  60.  
  61. a=5
  62. b=6
  63. if a==5:
  64. if b==6:
  65. print("parthi duce")
  66. else:
  67. print("ranaa")
  68. else:
  69. print("musoo")
  70.  
  71.  
  72.  
  73. ##looping
  74. #while
  75. a=1
  76. while a<10:
  77. print(a)
  78. a=a+1
  79.  
  80.  
  81. #for
  82. a=10
  83. for i in a:
  84. print(i)
  85.  
  86.  
  87. #nested while
  88. a=1
  89. b=10
  90. while(a<10):
  91. print(a)
  92. b=10
  93. while b<20:
  94. print(b)
  95. b=b+1
  96. a=a+1
  97.  
  98.  
  99. ##collection
  100.  
  101. #list
  102. list1=[1,2,3,4,"duce","musoo"]
  103. list2=[5,6,7,8]
  104. len(list1)
  105. max(list2)
  106. min(list2)
  107. list2.append(40)
  108. list2.insert(20)
  109. list2.pop(2)
  110. list2.remove(1)
  111. list2.sort()
  112. list2.reverse()
  113. list2.extend(list1)
  114.  
  115. #tuples
  116. t1=(1,2,3,4)
  117. len(t1)
  118. max(t1)
  119. min(t1)
  120. t1.count()
  121. t1.index(2)
  122.  
  123. #set
  124. s1={1,2,3,4,"parthi","ranaa","musoo"}
  125. s2=set()
  126. s1.add(5)
  127. s1.remove(5)
  128. s1.union(s2)
  129. s1.intersection(s2)
  130. s1.difference(s2)
  131. s1.pop(2)
  132.  
  133. #dict
  134. d={"a":1,"b":2,"c":3}
  135. for i in d.keys():
  136. print(i)
  137. for i in d.values():
  138. print(i)
  139. for i in d.items():
  140. print(i)
  141. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement