adiee

53_Assign1-7

Dec 2nd, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.06 KB | None | 0 0
  1. '''
  2. Name:- Aditya Gangurde
  3. Roll No.:- 53
  4.  
  5. Assignment No. 1
  6.  
  7. To calculate salary of employee given his Basic Pay to take as input from user. calculate grass pay. salary of employee let HRA be 10% of Basic Pay TA be 5% of Basic pay let employee pay professional Tax as 2% of total salary. Calculate Net salary payable after deduction
  8.  
  9. '''
  10.  
  11. Basic_pay = int(input("Enter basic pay: "))
  12.  
  13. HRA = Basic_pay*0.1
  14. TA = Basic_pay*0.05
  15. Total_salary = Basic_pay + HRA + TA
  16. P_Tax = Total_salary*0.02
  17. Net_salary = Total_salary - P_Tax
  18.  
  19. print("HRA is = ",HRA)
  20. print("TA is = ",TA)
  21. print("Total salary is = ",Total_salary)
  22. print("Professional tax = ",P_Tax)
  23. print("Net salary is = ",Net_salary)
  24.  
  25. '''
  26. output:-
  27.  
  28. Enter basic pay: 50000
  29. HRA is =  5000.0
  30. TA is =  2500.0
  31. Total salary is =  57500.0
  32. Professional tax =  1150.0
  33. Net salary is =  56350.0
  34.  
  35. '''
  36. '''
  37. Name:- Aditya Gangurde
  38. Roll no.:- 53
  39.  
  40. Assignment No. 2
  41.  
  42. To accept N number from user. Compute and display maximum & minimum list, sum and average of numbers.
  43. '''
  44.  
  45. sum = 0
  46. list = [1,2,3,4,5,6,7,8,9,10]
  47. for num in list:
  48.     sum = sum +num
  49.  
  50. average  = sum / len(list)
  51. print ("sum of list element is : ", sum)
  52. print ("Average of list element is ", average )
  53. print ("Maximum is = ",min(list))
  54. print ("Minimum is = ",max(list))
  55.  
  56.  
  57.  
  58. '''
  59. output:-
  60.  
  61. sum of list element is :  55
  62. Average of list element is  5.5
  63. Maximum is =  1
  64. Minimum is =  10
  65.  
  66. '''
  67.  
  68. '''
  69. Name :- Aditya Gangurde
  70. Roll No. :53
  71.  
  72. Assignment No. 3
  73.  
  74. To Accept Student's five courses marks and compute his/her result. Student is passing if he/she scores
  75. marks equal to and above 40 in each course. If student scores aggregate greater than 75%,
  76. then the Grade is Distinction. If aggregate is 60>= and <75, then the Grade is First Division.
  77. If aggregate is 50>= and <60, then the Grade is Second Division. If aggregate is 40>= and
  78. <50, then the Grade is Third Division.
  79.  
  80. '''
  81.  
  82.  
  83. List1 = [ ]
  84.  
  85. for i in range (5):
  86.     a = int(input("Enter Subject Marks: "))
  87.     if (a<40):
  88.         print("Fail!!! ")
  89.         exit()
  90.     List1.append(a)
  91. print ("\n")
  92. print (List1)
  93. print ("\n")
  94.  
  95. sum = 0
  96. for i in range (5):
  97.     sum = sum + List1[i]
  98. print("Total Marks = ",sum)
  99.  
  100. percent = 0
  101. percent = float(percent)
  102. percent = sum/5
  103. print("Percentage of Student = ", percent, "%")
  104.  
  105. if(percent>75):
  106.     print("Grade: Distinction!!!")
  107. elif(percent>=60 and percent<75):
  108.     print("Grade: First Division")
  109. elif(percent>=50 and percent<60):
  110.     print("Grade: Second Division")
  111. elif(percent>=40 and percent<50):
  112.     print("Grade: Third Division")
  113. else:
  114.     print("Fail!!!")
  115.    
  116.  
  117. '''
  118. Output:-
  119.  
  120. Enter Subject Marks: 92
  121. Enter Subject Marks: 87
  122. Enter Subject Marks: 89
  123. Enter Subject Marks: 94
  124. Enter Subject Marks: 98
  125.  
  126.  
  127. [92, 87, 89, 94, 98]
  128.  
  129.  
  130. Total Marks =  460
  131. Percentage of Student =  92.0 %
  132. Grade: Distinction!!!
  133.  
  134. '''
  135.  
  136. '''
  137. Name:-Aditya Gangurde
  138. Roll no.:- 53
  139.  
  140. Assignment No. 4
  141.  
  142. To accept a number from user and print digits of a number in a reverse order
  143. '''
  144.  
  145.  
  146.  
  147.  
  148. def Reverse_Integer(Number):
  149.     Reverse = 0
  150.     while(Number > 0):
  151.         Reminder = Number %10
  152.         Reverse = (Reverse *10) + Reminder
  153.         Number = Number //10
  154.     return Reverse
  155.  
  156. Number = int(input("Please Enter any Number: "))
  157. Reverse = Reverse_Integer(Number)
  158. print("\n Reverse of entered number is = %d" %Reverse)
  159.  
  160.  
  161.  
  162. '''
  163. output:-
  164. Please Enter any Number: 7264842
  165.  
  166. Reverse of entered number is = 2484627
  167.  
  168. '''
  169.  
  170. '''
  171. Name :- Aditya Gangurde
  172. Rolll No. :- 53
  173.  
  174. Asssignment No. 5
  175.  
  176. Write a program in python that accepts a string from user and perform following operations
  177. 1. Calculate length of string
  178. 2. String reversal
  179. 3. Equality cheak of two strings
  180. 4. Cheak palindrome
  181. 5. Cheak substring
  182.  
  183. '''
  184. str = input("Enter a string: ")
  185.  
  186. counter = 0
  187. for s in str:
  188.       counter = counter+1
  189. print("Length of the input string is:", counter)
  190.  
  191.  
  192.  
  193.  
  194. def reverse(str):
  195.     s = ""
  196.     for ch in str:
  197.         s = ch + s
  198.     return s
  199.  
  200. print("Given String: ", str)
  201.  
  202. print("Reversed String: ", reverse(str))
  203.  
  204.  
  205.  
  206.  
  207. print("Enter 'x' for exit.")                  
  208. str = input("Enter first string: ")
  209. if str == 'x':
  210.     exit();
  211. else:
  212.     string2 = input("Enter second string: ")
  213.     if str == string2:
  214.         print("\nBoth strings are equal to each other.")
  215.         print(str,"==",string2);
  216.     else:
  217.         print("\nStrings are not equal.")
  218.         print(str,"!=",string2);
  219.        
  220.        
  221.        
  222.        
  223. def reverse(s):
  224.     return s[::-1]
  225.  
  226. def isPalindrome(s):
  227.     rev = reverse(s)
  228.  
  229.    
  230.     if (s == rev):
  231.         return True
  232.     return False
  233.  
  234. s = input("Enter the String : ")
  235. ans = isPalindrome(s)
  236.  
  237. if ans == 1:
  238.     print("Yes")
  239. else:
  240.     print("No")
  241.    
  242.    
  243.    
  244.    
  245.    
  246. def check(str, sub_str):
  247.     if (str.find(sub_str) == -1):
  248.         print("NO")
  249.     else:
  250.         print("YES")
  251.            
  252. sub_str = input("Enter Sub String Which we want to cheak : ")
  253. check(str, sub_str)
  254.  
  255. '''
  256. Output:-
  257. Enter a string: aditya gangurde
  258. Length of the input string is: 15
  259. Given String:  aditya gangurde
  260. Reversed String:  edrugnag aytida
  261. Enter 'x' for exit.
  262. Enter first string: aditya
  263. Enter second string: aditya
  264.  
  265. Both strings are equal to each other.
  266. aditya == aditya
  267.  
  268.  
  269. '''
  270.  
  271. '''
  272. Name:- Aditya Gangurde
  273. Roll no.:- 53
  274.  
  275.  
  276.  
  277. Assignment No. 6
  278.  
  279. To count total characters in file, total words in file, total lines of file and frequency of given word in the file.
  280. '''
  281.  
  282.  
  283. searchWord = input("Enter word  to search: ")
  284.  
  285. with open('File.txt') as infile:
  286.     words = 0
  287.     characters = 0
  288.     count = 0
  289.     for lineno,line  in enumerate(infile,1):
  290.         count = count + line.count(searchWord)
  291.         wordslist = line.split()
  292.         words += len(wordslist)
  293.         characters += sum(len(words) for words in wordslist)
  294.  
  295.  
  296. print("total lines are", lineno)
  297. print("total words",words)
  298. print("total characters",characters)
  299. print("frequency is ",searchWord,"is ",count)
  300.  
  301.  
  302. """ Output
  303.  
  304.  
  305. Enter word  to search: Hello
  306. total lines are 2
  307. total words 8
  308. total characters 35
  309. frequency is  Hello is  1
  310.          """
  311.  
  312. """
  313. Name : Aditya Gangurde
  314. Roll No. : 53
  315.  
  316. Assignment No. 7
  317.  
  318. Create class EMPLOYEE for storing details (Name,Designation gender, Date of joining and Salary).
  319. Define function members to compute
  320. a) total no of employees in organisation
  321. b) to count of male and female employee
  322. c) employee with salary more than 10000
  323. d) employee with designation 'asst manager
  324. """  
  325.  
  326.  
  327.  
  328. class emp():
  329.     count=0
  330.     f_count=0
  331.     m_count=0
  332.     salary_count=0
  333.     desig_count=0
  334.     def __init__(self,name,desig,gender,doj,salary):
  335.         self.name=name
  336.         self.desig=desig
  337.         self.gender=gender
  338.         self.doj=doj
  339.         self.salary=salary
  340.         emp.count+=1
  341.         if(self.gender=="F"):
  342.             emp.f_count+=1
  343.         else:
  344.             emp.m_count+=1
  345.         if(self.salary>10000):
  346.             emp.salary_count+=1
  347.         if(self.desig=="Asst_Manager"):
  348.             emp.desig_count+=1
  349.     def display_emp_count(self):
  350.         print("There are", emp.count,"Employees in office")
  351.     def count_gender(self):
  352.         print("There are", emp.f_count,"female in office")
  353.         print("There are", emp.m_count,"male in office")
  354.     def count_salary(self):
  355.         print("There are", emp.salary_count,"Employees in office having salary>10000")
  356.     def count_desig(self):
  357.         print("There are", emp.desig_count,"Employees in office with designation 'Assistant Manager'")
  358. e1=emp("Nimish","Asst_Manager","M","01-01-2019",10000)
  359. e2=emp("Aditya","Asst_Manager","M","02-02-2019",20000)
  360. e3=emp("Yash","Accountant","F","03-03-2019",30000)
  361. e4=emp("Ayushi","HR","F","04-04-2019",40000)
  362. e5=emp("Amey","Manager","M","05-05-2019",50000)
  363.  
  364. e5.display_emp_count()
  365. e5.count_gender()
  366. e5.count_salary()
  367. e5.count_desig()
  368.  
  369. """
  370. output:
  371.  
  372. There are 5 Employees in office
  373. There are 2 female in office
  374. There are 3 male in office
  375. There are 4 Employees in office having salary>10000
  376. There are 2 Employees in office with designation 'Assistant Manager'
  377.  
  378. """
Add Comment
Please, Sign In to add comment