Sorry For Inconvenience, Site is Under Maintenance. Please Goto HomePage

Python 3 Programming FP Handson Solutions

Python 3 Programming FP Handson Solutions
Notes Bureau

Python 3 Programming FP Handson Solutions

Disclaimer: The main motive to provide this solution is to help and support those who are unable to do these courses due to facing some issue and having a little bit lack of knowledge. All of the material and information contained on this website is for knowledge and education purposes only.


Try to understand these solutions and solve your Hands-On problems. (Not encourage copy and paste these solutions)

Python 3 Programming FP Handson Solutions


Course Path: Data Science/DATA SCIENCE BASICS/Python 3 Programming


1. Print (Hands-on - Print)


#!/bin/python3


import math

import os

import random

import re

import sys

#

# Complete the 'Greet' function below.

#

# The function accepts STRING Name as parameter.

#


def Greet(Name):

    # Write your code here

    print("Welcome " + Name + ".")

    print("It is our pleasure inviting you.")

    print("Have a wonderful day.")



if __name__ == '__main__':

    Name = input()


    Greet(Name)



Print (Hands-on - Print)


  • List of Fresco Play Courses without Hands-On | Fresco Play
  • HMTL5 Semantics Elements MCQs Answers | Fresco Play
  • HMTL5 Semantics Elements Hands-On Solutions | Fresco Play
  • Styling with CSS3 Hands-On Solutions | Fresco Play
  • Blockchain Intermedio MCQs Answers | Fresco Play
  • Blockchain - Potentes Nexus MCQs Answers | Fresco Play
  • Azure Essentials MCQs Answers | Fresco Play
  • AWS Essentials MCQs Answers | Fresco Play

  • 2.Namespaces 1 (Hands-on – Namespaces)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys

    #

    # Complete the 'Assign' function below.

    #

    # The function accepts following parameters:

    #  1. INTEGER i

    #  2. FLOAT f

    #  3. STRING s

    #  4. BOOLEAN b

    #


    def Assign(i, f, s, b):

        # Write your code here

        w = i 

        x = f

        y = s

        z = b 

        print(w)

        print(x)

        print(y)

        print(z)

        print(dir())

    if __name__ == '__main__':


        i = int(input().strip())


        f = float(input().strip())


        s = input()


        b = input().strip()

        

        Assign(i, f, s, b)


    Namespaces 1 (Hands-on – Namespaces)


    3.Handson - Python - Get Additional Info (Hands-on - Get Additional Info)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys

    #

    # Complete the 'docstring' function below.

    #

    # The function is expected to output a STRING.

    # The function accepts STRING x as parameter.

    #


    def docstring(functionname):

        # Write your code here

        help(functionname)


    if __name__ == '__main__':


        x = input()

        docstring(x)



    Handson - Python - Get Additional Info (Hands-on - Get Additional Info)

    4.Namespaces 2 (Hands-on – Namespaces)


    If not working and getting server error then Change Prompt() to Promp() at both places

    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    def Promp():

        # Write your code here

        x = input('Enter a STRING:\n')

        print(x)

        print(type(x))

    if __name__ == '__main__':


        Promp()




    Namespaces 2 (Hands-on – Namespaces)

    5.Handson - Python - Usage imports (Hands-on - Usage Imports)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'calc' function below.

    #

    # The function is expected to return an INTEGER.

    # The function accepts INTEGER c as parameter.

    #


    def calc(c):

        # Write your code here

        r = c/(2*math.pi)

        a = r*r*math.pi

        x = round(r,2)

        y = round(a,2)

        return(x,y)


    if __name__ == '__main__':

        fptr = open(os.environ['OUTPUT_PATH'], 'w')


        c = int(input().strip())


        result = calc(c)


        fptr.write(str(result) + '\n')


        fptr.close()


    Handson - Python - Usage imports (Hands-on - Usage Imports)


    6.Handson - Python - Range1 (Hands-on – Range)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys




    #

    # Complete the 'func' function below.

    #

    # The function is expected to print an INTEGER.

    # The function accepts following parameters:

    #  1. INTEGER startvalue

    #  2. INTEGER endvalue

    #  3. INTEGER stepvalue

    #


    def rangefunction(startvalue, endvalue, stepvalue):

        # Write your code here

        for i in range(startvalue,endvalue,stepvalue):

            print(i*i,end = "\t")


    if __name__ == '__main__':


        x = int(input().strip())


        y = int(input().strip())


        z = int(input().strip())


        rangefunction(x, y, z)


    Handson - Python - Range1 (Hands-on – Range)


    7.Using int (Hands-on - Using int)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'Integer_fun' function below.

    #

    # The function is expected to return an INTEGER.

    # The function accepts following parameters:

    #  1. FLOAT a

    #  2. STRING b

    #


    def Integer_fun(a, b):

        # Write your code here

        c = int(a)

        d = int(b)

        print(type(a))

        print(type(b))

        print(c)

        print(d)

        print(type(c))

        print(type(d))


    if __name__ == '__main__':

        a = float(input().strip())


        b = input()


        Integer_fun(a, b)


    Using int (Hands-on - Using int)


  • List of Fresco Play Courses without Hands-On | Fresco Play
  • HMTL5 Semantics Elements MCQs Answers | Fresco Play
  • HMTL5 Semantics Elements Hands-On Solutions | Fresco Play
  • Styling with CSS3 Hands-On Solutions | Fresco Play
  • Blockchain Intermedio MCQs Answers | Fresco Play
  • Blockchain - Potentes Nexus MCQs Answers | Fresco Play
  • Azure Essentials MCQs Answers | Fresco Play
  • AWS Essentials MCQs Answers | Fresco Play

  • 8.Handson - Python - Using Int operations (Hands-on - Using int – Operations)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'find' function below.

    #

    # The function is expected to return an INTEGER.

    # The function accepts following parameters:

    #  1. INTEGER num1

    #  2. INTEGER num2

    #  3. INTEGER num3

    #


    def find(num1, num2, num3):

        # Write your code here

        print(num1<num2 and num2 >= num3,end=" ")

        print(num1>num2 and num2 <= num3,end=" ")

        print(num3 == num1 and num1!=num2,end=" ")


    if __name__ == '__main__':


        num1 = int(input().strip())


        num2 = int(input().strip())


        num3 = int(input().strip())


        find(num1, num2, num3)


    Handson - Python - Using Int operations (Hands-on - Using int – Operations)


    9.Using intMath Operations (Hands-on - Using int - Math Operations)


    #!/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

        a = Side * Side

        b = Side * Side * Side

        c = 3.14 * Radius * Radius

        x = round(c,2)

        d = (4/3)*3.14*Radius*Radius*Radius

        y = round(d,2

        print("Area of Square is "str(a))

        print("Volume of Cube is "str(b))

        print("Area of Circle is "str(x))

        print("Volume of Sphere is "str(y))


    if __name__ == '__main__':

        Side = int(input().strip())


        Radius = int(input().strip())


        Integer_Math(Side, Radius)


    Using intMath Operations (Hands-on - Using int - Math Operations)


    10.Using Float 1 (Hands-on - Using float)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'tria' function below.

    #

    # The function is expected to return an INTEGER.

    # The function accepts following parameters:

    #  1. FLOAT n1

    #  2. FLOAT n2

    #  3. INTEGER n3

    #


    def triangle(n1, n2, n3):

        # Write your code here

        x = round((n1 * n2)/2,n3)

        y = round(math.pi,n3)

        return x,y


    if __name__ == '__main__':

        fptr = open(os.environ['OUTPUT_PATH'], 'w')


        n1 = float(input().strip())


        n2 = float(input().strip())


        n3 = int(input().strip())


        result = triangle(n1, n2, n3)


        fptr.write(str(result) + '\n')


        fptr.close()


    Using Float 1 (Hands-on - Using float)


    11.Using Float 2 (Hands-on - Using float)


    #!/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")

        a = f1 ** Power

        print(a)

        print("#Round")

        print(round(a,4))



    if __name__ == '__main__':

        f1 = float(input().strip())


        f2 = float(input().strip())


        Power = int(input().strip())


        Float_fun(f1, f2, Power)


    Using Float 2 (Hands-on - Using float)


    12.String Operations - 1 (Hands-on - String Operations)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'strng' function below.

    #

    # The function is expected to return an INTEGER.

    # The function accepts following parameters:

    #  1. STRING fn

    #  2. STRING ln

    #  3. STRING para

    #  4. INTEGER number

    #


    def stringoperation(fn, ln, para, number):

        # Write your code here

        print(fn+'\n'*number+ln)

        print(fn+" "+ln)

        print(fn*number)

        print(f"The sentence is {para}")


    if __name__ == '__main__':


        fn = input()


        ln = input()


        para = input()


        no = int(input().strip())


        stringoperation(fn, ln, para, no)



    String Operations - 1 (Hands-on - String Operations)

    13.Newline and Tab Spacing (Hands-on - Newline & Tab spacing)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'Escape' function below.

    #

    # The function accepts following parameters:

    #  1. STRING s1

    #  2. STRING s2

    #  3. STRING s3

    #


    def Escape(s1, s2, s3):

        # Write your code here

        s = "Python\tRaw\nString\tConcept"

        print(s1+'\n'+s2+'\n'+s3)

        print(s1+'\t'+s2+'\t'+s3)

        print(s)

        s = r"Python\tRaw\nString\tConcept"

        print(s)


    if __name__ == '__main__':

        s1 = input()


        s2 = input()


        s3 = input()


        Escape(s1, s2, s3)


    Newline and Tab Spacing (Hands-on - Newline & Tab spacing)


    14.String Operations - 2 (Hands-on - String Operations)


    #!/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

        print(first.strip().capitalize()+" "+second.strip().capitalize()+" "+parent.strip().capitalize()+" "+city.strip())

        print(phone.isdigit())

        print(phone.startswith(start))

        print(first.count(strfind)+second.count(strfind)+parent.count(strfind)+city.count(strfind))

        print(string1.split())

        print(city.find(strfind))


    if __name__ == '__main__':


        a = input()


        b = input()


        c = input()


        d = input()


        ph = input()


        no = input()


        ch = input()


        str = input()


        resume(a, b, c, d, ph, no, ch, str)


    String Operations - 2 (Hands-on - String Operations)


    15.List Operations 1 (Hands-on - List Operations)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'List_Op' function below.

    #

    # The function accepts following parameters:

    #  1. LIST Mylist

    #  2. LIST Mylist2

    #


    def List_Op(Mylist, Mylist2):

        # Write your code here

        print(Mylist)

        print(Mylist[1])

        for i in range(len(Mylist)):

            if(i==len(Mylist)-1):

                print(Mylist[i])

        Mylist.append(3)

        for i in range(len(Mylist)):

            if( i == 3 ):

                Mylist[i] = 60

        print(Mylist)

        print(Mylist[1:5])

        Mylist.append(Mylist2)

        print(Mylist)

        Mylist.extend(Mylist2)

        print(Mylist)

        Mylist.pop()

        print(Mylist)

        print(len(Mylist))


    if __name__ == '__main__':

        qw1_count = int(input().strip())


        qw1 = []


        for _ in range(qw1_count):

            qw1_item = int(input().strip())

            qw1.append(qw1_item)


        qw2_count = int(input().strip())


        qw2 = []


        for _ in range(qw2_count):

            qw1_item = int(input().strip())

            qw2.append(qw1_item)


        List_Op(qw1,qw2)


    List Operations 1 (Hands-on - List Operations)


    16.List Operations 2 (Hands-on - List Operations)


    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    #

    # Complete the 'tuplefun' function below.

    #

    # The function accepts following parameters:

    #  1. LIST list1

    #  2. LIST list2

    #  3. STRING string1

    #  4. INTEGER n

    #


    def tuplefunction(list1, list2, string1, n):

        # Write your code here

        tuple1 = tuple(list1)

        tuple2 = tuple(list2)

        tuple3 = tuple1 + tuple2

        print(tuple3)

        print(tuple3[4])

        tuple4 = (tuple1,tuple2)

        print(tuple4)

        print(len(tuple4))

        print((string1,)*n)

        print(max(tuple1))


    if __name__ == '__main__':

        

        qw1_count = int(input().strip())


        qw1 = []


        for _ in range(qw1_count):

            qw1_item = int(input().strip())

            qw1.append(qw1_item)


        qw2_count = int(input().strip())


        qw2 = []


        for _ in range(qw2_count):

            qw1_item = input()

            qw2.append(qw1_item)

            

        str1 = input()


        n = int(input().strip())


        tuplefunction(qw1,qw2,str1, n)


    List Operations 2 (Hands-on - List Operations)


  • List of Fresco Play Courses without Hands-On | Fresco Play
  • HMTL5 Semantics Elements MCQs Answers | Fresco Play
  • HMTL5 Semantics Elements Hands-On Solutions | Fresco Play
  • Styling with CSS3 Hands-On Solutions | Fresco Play
  • Blockchain Intermedio MCQs Answers | Fresco Play
  • Blockchain - Potentes Nexus MCQs Answers | Fresco Play
  • Azure Essentials MCQs Answers | Fresco Play
  • AWS Essentials MCQs Answers | Fresco Play

  • 17.Slicing (Hands-on – Slicing)


    #!/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

        a = slice(1,3)

        print(mylist[a])

        b = slice(1,len(mylist),2)

        print(mylist[b])

        c = slice(-1,-4,-1)

        print(mylist[c])


    if __name__ == '__main__':

        mylist_count = int(input().strip())


        mylist = []


        for _ in range(mylist_count):

            mylist_item = input()

            mylist.append(mylist_item)


        sliceit(mylist)


    Slicing (Hands-on – Slicing)


    18.Range 2 (Hands-on – range)


    #!/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

        list1 = list(range(startvalue,endvalue+1))

        print(list1[:3])

        list2 = list1[::-1]

        print(list2[0:5])

        print(list1[::4])

        print(list2[::2])


    if __name__ == '__main__':

        startvalue = int(input().strip())


        endvalue = int(input().strip())


        generateList(startvalue, endvalue)


    Range 2 (Hands-on – range)


    19.Set (Hands-on – set)


    #!/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

    #


    def setOperation(seta, setb):

        # Write your code here

        seta = set(seta)

        setb = set(setb)

        union = seta.union(setb)

        intersection = seta.intersection(setb)

        diff1 = seta.difference(setb)

        diff2 = setb.difference(seta)

        symdiff = seta.symmetric_difference(setb)

        frozenseta = frozenset(seta)

        return(union, intersection, diff1, diff2, symdiff, frozenseta )


    if __name__ == '__main__':

        seta_count = int(input().strip())


        seta = []


        for _ in range(seta_count):

            seta_item = input()

            seta.append(seta_item)


        setb_count = int(input().strip())


        setb = []


        for _ in range(setb_count):

            setb_item = input()

            setb.append(setb_item)


        un, intersec, diffa, diffb, sydiff, frset = setOperation(seta, setb)

        print(sorted(un))

        print(sorted(intersec))

        print(sorted(diffa))

        print(sorted(diffb))

        print(sorted(sydiff))

        print("Returned value is {1} frozenset".format(frset, "a" if type(frset) == frozenset else "not a"))


    Set (Hands-on – set)


    20.Dictionary (Hands-on – dict)



    #!/bin/python3


    import math

    import os

    import random

    import re

    import sys


    from pprint import pprint as print


    #

    # Complete the 'myDict' function below.

    #

    # The function accepts following parameters:

    #  1. STRING key1

    #  2. STRING value1

    #  3. STRING key2

    #  4. STRING value2

    #  5. STRING value3

    #  6. STRING key3

    #


    def myDict(key1, value1, key2, value2, value3, key3):

        # Write your code here

        dict1 = {key1:value1}

        print(dict1)

        dict1[key2] = value2

        print(dict1)

        dict1[key1] = value3

        print(dict1)

        dict1.pop(key3)

        return dict1


    if __name__ == '__main__':

        key1 = input()


        value1 = input()


        key2 = input()


        value2 = input()


        value3 = input()


        key3 = input()


        mydct = myDict(key1, value1, key2, value2, value3, key3)

        

        print(mydct if type(mydct) == dict else "Return a dictionary")

        

    Dictionary (Hands-on – dict)

    21. While Loop (Hands-on - While loop)


    #!/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

        list1 = list()

        i = startvalue

        while i<= endvalue:

            num = (i*(i+1)*(i+2)/6)

            list1.append(int(num))

            i = i + 1

        return list1


    if __name__ == '__main__':

        fptr = open(os.environ['OUTPUT_PATH'], 'w')


        startvalue = int(input().strip())


        endvalue = int(input().strip())


        result = calculateNTetrahedralNumber(startvalue, endvalue)


        fptr.write('\n'.join(map(str, result)))

        fptr.write('\n')


        fptr.close()


    While Loop (Hands-on - While loop)


    22.For Loop (Hands-on - For loop)


    #!/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

        first = 0

        second = 1

        result = 1

        if n <= 1:

            return 0

        else:

            for elem in range(2,n):

                next = first + second

                result = result + next

                first = second

                second = next

            return result


    if __name__ == '__main__':

        fptr = open(os.environ['OUTPUT_PATH'], 'w')


        n = int(input().strip())


        result = sumOfNFibonacciNumbers(n)


        fptr.write(str(result) + '\n')


        fptr.close()


    For Loop (Hands-on - For loop)


    23.IF (Conditional Statement) (Hands-on - using if)


    #!/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

        list1 = list()

        for i in range(len(students_marks)):

            count = 0

            sum = 0

            avg = 0

            for j in range(len(students_marks[i])):

                count = count + 1

                sum = sum + students_marks[i][j]

            avg = sum/count

            if avg >= 90:

                list1.append("A+")

            elif avg >= 80:

                list1.append("A")

            elif avg >= 70:

                list1.append("B")

            elif avg >= 60:

                list1.append("C")

            elif avg >= 50:

                list1.append("D")

            elif avg < 50:

                list1.append("F")

        return list1


    if __name__ == '__main__':

        fptr = open(os.environ['OUTPUT_PATH'], 'w')


        students_marks_rows = int(input().strip())

        students_marks_columns = int(input().strip())


        students_marks = []


        for _ in range(students_marks_rows):

            students_marks.append(list(map(intinput().rstrip().split())))


        result = calculateGrade(students_marks)


        fptr.write('\n'.join(result))

        fptr.write('\n')


        fptr.close()


    IF (Conditional Statement) (Hands-on - using if)


    If you want answers to any of the fresco play courses feel free to ask in the comment section, we will surely help.

    Post a Comment

    Any comments and suggestion will be appreciated.
    Cookie Consent
    We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
    Oops!
    It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
    AdBlock Detected!
    We have detected that you are using adblocking plugin in your browser.
    The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
    Site is Blocked
    Sorry! This site is not available in your country.

    Join Telegram Channel

    Join Notes Bureau Lets Teach and Learn

    Join Telegram Channel
    CLOSE ADS
    CLOSE ADS