Icp1 - Anushad4/Python-Deeplearning GitHub Wiki
Icp1
Question-1: Difference between python 2.x and 3.x versions?
-
In python 2.x version the strings are stored as ASCII by default, in python 3.x version the strings are stored as Unicode by default.
-
In python 2.x version the calculation rounds to a nearest whole number where as in python 3.x version it rounds to a exact integer. Example: 5/2 = 2 - python 2 5/2 = 2.5 – python 3
-
In python 2.x version, simply we can print “hello”, whereas in python 3.x version we should write print(“hello”).
4.In error handling for python2.0v, there is no need to use “AS” keyword whereas, In python 3.xv we should use “AS” keyword in except statement.
Question 2: Write a python program for the following:– Input the string “Python” as a list of characters from console, delete at least 2 characters, reverse the resultant string and print it.
I have taken list of characters from console ,as i have used list datatype, .join() wont support so i have used .append() to convert list of characters into string by using loop.Then i have taken reverse function ,by using slicing or indexing concept i have reverse the string after deleting 2 characters.
Question 3:Take two numbers from user and perform arithmetic operations on them.
By taking two numbers from console and performing arithmetic operations on them.
Question4: Write a program that accepts a sentence and replace each occurrence of ‘python’ with ‘pythons’ without using regex?