Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'calculateNTetrahedralNumber' function below.
- #
- # The function is expected to return an INTEGER_ARRAY.
- # The function accepts following parameters:
- # 1. INTEGER startvalue
- # 2. INTEGER endvalue
- #
- def calculateNTetrahedralNumber(startvalue, endvalue):
- # Write your code here
- lis = []
- for i in range(startvalue,endvalue + 1):
- a=int((i*(i+1)*(i+2))/6)
- lis.append(a)
- return lis
- if __name__ == '__main__':
- =================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'sumOfNFibonacciNumbers' function below.
- #
- # The function is expected to return an INTEGER.
- # The function accepts INTEGER n as parameter.
- #
- def sumOfNFibonacciNumbers(n):
- # Write your code here
- if n == 0 or n == 1:
- return 0
- fib = [0,1]
- for i in range(n-2):
- a = fib[-1]
- b = fib[-2]
- c = a + b
- fib.append(c)
- sum = 0
- for i in fib:
- sum = sum + i
- return sum
- if __name__ == '__main__':
- ==========================================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'Integer_Math' function below.
- #
- # The function accepts following parameters:
- # 1. INTEGER Side
- # 2. INTEGER Radius
- #
- def Integer_Math(Side, Radius):
- # Write your code here
- s = Side
- r = Radius
- ars = s*s
- vc = s*s*s
- ac = 3.14*r*r
- vs = ((r*r*r)*4*(3.14))/3
- print("Area of Square is",ars)
- print("Volume of Cube is",vc)
- print("Area of Circle is",ac)
- print("Volume of Sphere is",vs)
- if __name__ == '__main__':
- =========================================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'Float_fun' function below.
- #
- # The function accepts following parameters:
- # 1. FLOAT f1
- # 2. FLOAT f2
- # 3. INTEGER Power
- #
- def Float_fun(f1, f2, Power):
- # Write your code here
- print("#Add")
- print(f1+f2)
- print("#Subtract")
- print(f1-f2)
- print("#Multiply")
- print(f1*f2)
- print("#Divide")
- print(f2/f1)
- print("#Remainder")
- print(f1%f2)
- print("#To_The_Power_Of")
- print(f1**Power)
- print("#Round")
- a = f1**Power
- print("%.4f"%a)
- if __name__ == '__main__':
- f1 = float(input().strip())
- f2 = float(input().strip())
- Power = int(input().strip())
- Float_fun(f1, f2, Power)
- ===================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'resume' function below.
- #
- # The function is expected to print a STRING.
- # The function accepts following parameters:
- # 1. STRING first
- # 2. STRING second
- # 3. STRING parent
- # 4. STRING city
- # 5. STRING phone
- # 6. STRING start
- # 7. STRING strfind
- # 8. STRING string1
- #
- def resume(first, second, parent, city, phone, start, strfind, string1):
- # Write your code here startswith
- f = first.strip()
- s = second.strip()
- p = parent.strip()
- c = city.strip()
- f = f.capitalize()
- s = s.capitalize()
- p = p.capitalize()
- print(f+" "+s+" "+p+" "+c)
- print(phone.isdecimal())
- print(phone.startswith(start))
- ss = first+second+parent+city
- print(ss.count(strfind))
- print(string1.split())
- print(city.index(strfind))
- if __name__ == '__main__':
- =============================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'sliceit' function below.
- #
- # The function accepts List mylist as parameter.
- #
- def sliceit(mylist):
- # Write your code here
- print(mylist[1:3])
- print(mylist[1::2])
- mylist1 = mylist.reverse()
- print(mylist[0:3])
- if __name__ == '__main__':
- ===================================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'generateList' function below.
- #
- # The function accepts following parameters:
- # 1. INTEGER startvalue
- # 2. INTEGER endvalue
- #
- def generateList(startvalue, endvalue):
- # Write your code here
- x = range(startvalue,endvalue+1)
- lis = []
- for n in x:
- lis.append(n)
- print(lis[:3])
- lis.reverse()
- print(lis[:5])
- lis.reverse()
- print(lis[::4])
- lis.reverse()
- print(lis[::2])
- if __name__ == '__main__':
- =========================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'calculateGrade' function below.
- #
- # The function is expected to return a STRING_ARRAY.
- # The function accepts 2D_INTEGER_ARRAY students_marks as parameter.
- #
- def calculateGrade(students_marks):
- # Write your code here
- sum1 = 0
- avgl = []
- avgl1 = []
- for i in students_marks :
- sum1 = 0
- for j in i:
- sum1 = sum1 + j
- len1 = len(i)
- avg = sum1/5
- avgl.append(avg)
- avgl1.append(str(avg))
- avgt = []
- for k in avgl:
- if k >= 90:
- avgt.append("A+")
- elif k >= 80 and k <90:
- avgt.append("A")
- elif k >= 70 and k <80:
- avgt.append("B")
- elif k >= 60 and k <70:
- avgt.append("C")
- elif k >= 50 and k <60:
- avgt.append("D")
- else :
- avgt.append("F")
- return avgt
- if __name__ == '__main__':
- ===============================================================================
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- #
- # Complete the 'setOperation' function below.
- #
- # The function is expected to return a union, intersection, difference(a,b), difference(b,a), symmetricdifference and frozen set.
- # The function accepts following parameters:
- # 1. List seta
- # 2. List setb symmetric_difference
- #
- def setOperation(seta, setb):
- # Write your code here
- a = set(seta)
- b = set(setb)
- uab = a.union(b)
- iab = a.intersection(b)
- dab = a.difference(b)
- dba = b.difference(a)
- sab = a.symmetric_difference(b)
- a = frozenset(a)
- return uab,iab,dab,dba,sab,a
- if __name__ == '__main__':
- =================================================================================
Add Comment
Please, Sign In to add comment