0% found this document useful (0 votes)
7 views

8 intro to Python - part 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

8 intro to Python - part 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ms. Nanda @BMS Ms.

Nanda @BMS

Rectify the errors from below programs


#program 3 – Type Value Error #program 4- int() function for integer
a=input(“Enter the first value”) conversion a=int(input(“Enter the first value”))
b=input(Enter the second value “) b=int(input(Enter the second value “))
print(a*b) c=a+b
#error message is displayed as * cannot print(“Sum of the numbers is “, c)
be used on strings(The string values
cannot be multiplied together)

#program 5 – Swapping two #Program 6 – Area & Perimeter of a


numbers a=int(input(“Enter the square s= int(input(“Enter the side of the
value of a”)) square”)) ar=s*s
b=int(input(Enter the value of b“)) p=4*s
a, b = b, a print(“The area of the square is “, ar)
print(“Value of a after swapping” , a) print(“The Perimeter of the square is “, p)
print(“Value of b after swapping” , b)

#Program 7 – Using Comma #Program 8 – Using \t tab space


Operator a=100 a=100
b=20 b=20
c=5000000 c=5000000
print(a, b, c) print(a, “\t”, b, “\t”, c)

#Program 9 – Using \n tab space #Program 10 – Without Escape


a=100 Sequence Name=input(“Enter your
b=20 name – “)
c=5000000 Age = input(Enter your age – “)
print(a, “\n”, b, “\n”, c) Class = input(“Enter your Class – “)
print(“Your name is :”, Name)
print((“Your age is :”, Age)
print(“Your class is :”, Class)

#Program 11 – With Escape Sequence #Program 12 – Binary Operators


\n Name=input(“Enter your name – \n“) a=input(“Enter the first value”)
Age = input(Enter your age – \n“) b=input(Enter the second value “)
Class = input(“Enter your Class – \n“) print(“The sum of the numbers is”, a+b)
print(“Your name is :\n”, Name) print(“The difference of the numbers is”, a-b)
print((“Your age is :\n”, Age) print(“The product of the numbers is”, a*b)
print(“Your class is :\n”, Class) print(“The quotient of the numbers is”, a/b)
print(“The result of floor division of the numbers
is”, a//b)
print(“The cube of the first number is - ”, a**3)
print(“The remainder of the division of the
numbers is ”, a%b)

#Program 13 – Concatenation #Program 14 – String Replication


Operator a=”Hard work “ print(“Welcome” * 30
b=”is the key to Success” print(“Hello “*40
print((a+b) print(“I am learning String Replication”*2)
#Program 15 – float() function for decimals #Program 16 -predict the output
r=float(input(“(Enter the radius of the print(52*7)
circle-“)) c=2 * 3.14 * r print(“52*7”)
ar=3.14 * r * r print(“52*7 = “, 52*7)
print(“The circumference of the circle is-“, print(“52”*7)
c) print(“The area of the circle is-“, ar)

Ms. Nanda @BMS Ms. Nanda @BMS

You might also like