Tariqul_Islam

CSE-412 Python lab 2

Jun 19th, 2021
778
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sat Jun 19 01:39:44 2021
  4.  
  5. @author: User Pc
  6. """
  7.  
  8. #list
  9.  
  10. name = ["diu","uiu","10145",123]
  11.  
  12. print(name)
  13. print(name[1])
  14. print(name[-1])
  15. print(name[2:])
  16. print(name+["csei",1123])
  17.  
  18. #functions
  19.  
  20. diu=[10,20,30,40,50,60,123]
  21.  
  22. print(len(diu))
  23.  
  24. diu.append(23)
  25. print(diu)
  26.  
  27. diu.insert(2,55)
  28. print(diu)
  29.  
  30. diu.remove(30)
  31. print(diu)
  32.  
  33. diu.sort()
  34. print(diu)
  35.  
  36. diu.reverse()
  37. print(diu)
  38.  
  39. print(99 in diu)
  40.  
  41. #dictionary
  42.  
  43. csediu = {
  44.     "198345":"Fatema" "diu" "cse" "3.56",
  45.     "12345":"Jahir",
  46.     "998456":"rana"
  47.     }
  48. print(csediu["198345"])
  49.  
  50. #tuples
  51.  
  52. cseclub = (
  53.     ("diu","uiu","10145",123),
  54.     "Bangladesh",
  55.     "India",
  56.     "China"
  57.     )
  58. print(cseclub[0])
  59.  
  60.  
  61. #mini program
  62.  
  63. from random import randint
  64.  
  65. for i in range(0,20):
  66.     guenum=int(input("Enter Your Guess Number"))
  67.     randomnum = randint(1,50)
  68.     if guenum==randomnum:
  69.         print("You have won.")
  70.     else:
  71.         print("Sorry! Try again.")
  72.         print("Random number ",randomnum)
RAW Paste Data