-
Notifications
You must be signed in to change notification settings - Fork 0
ICP1
Nikii1118 edited this page Jan 27, 2019
·
5 revisions
Answer 1. Python 2 vs Python 3
- In python 2 print is considered as a statement rather than function In Python 3 print is considered as a function which uses parenthesis
- Integer Division: In python 2,it returns an integer. So, If we take 7/2 it will give 3. To get exact answer we need to use 7.0/2.0. In python 3, integer division can give us a float answer. For example: 7/2 will give 3.5.
- Input() Function: In Python 2, input() function can be used to read as strings if they are inside quotation marks else read as a numbers only. In python3, input() function read the input as a string.
- Unicode Support: To store as Unicode, in python2 we need to use a label with "u".In python 3 it store string as Unicode in default only.
- xrange() : In python 2 we use xrange() function to iterate. In Python 3, range(): Here, we use range() function to iterate.
- Exception handling: In Python2 ,exception arguments can be enclosed in notations. Here, in Python3 exception arguments can be enclosed with parenthesis.
Screenshots of the codes of ICP1
ANSWER2.
To Count the number of digits and letters
Input
Output
To print the string in reverse form.
Input
Output
Arithmetic operation
Input
Output