ICP1 - PavankumarManchala/Python-and-Deep-Learning-Programming-ICPs GitHub Wiki

Submitted by:

Pavankumar Manchala Class ID: 22

Technologies Used:

PyCharm

Tasks:

1. Differences between Python 2 and 3 versions:

  • Python version 2 does not provide output with decimal when two numbers are divided. It always tries to round to the nearest number. Whereas in Python Version 3, the decimal part is also included in the output.
  • In Python version 2 we don't need to use parenthesis in the print function i.e., print "Welcome to python" is the syntax used for print function in version 2. Whereas in Version 3 parenthesis have to be included in the print function i.e., print("Welcome to Python!")
  • In Python version 2 all types are ASCII, whereas in Version 3 all types are of UNICODE

2. Delete atleast 2 characters from input string and print the reverse of resultant string:

string1 = input('Enter a string:') number1 = int(input('Enter number of characters to delete:'))

string = string1[0:-number1] print(string[::-1])

3. Program to replace each occurrence of python with Pythons:

4. Perform Arithmetic operations on user given two numbers:

x = input('Enter a number:') y = input('Enter another number:')

a = int(x) b = int(y)

print('Addition:',a + b) print('Subtraction:',a-b) print('Multiplication:',a * b) print('Division:',a / b) print('Modulus:',a % b) print('Exponent:',a ** b) print('Floor division:',a // b)