Skip to content
Nikii1118 edited this page Jan 27, 2019 · 5 revisions

Answer 1. Python 2 vs Python 3

  1. In python 2 print is considered as a statement rather than function In Python 3 print is considered as a function which uses parenthesis
  2. 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.
  3. 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.
  4. 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.
  5. xrange() : In python 2 we use xrange() function to iterate. In Python 3, range(): Here, we use range() function to iterate.
  6. 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
answer1_classid_7code

Output answer1_classid_7output

To print the string in reverse form.
Input answer2_classid_7code

Output
answer2_classid_7output

Arithmetic operation
Input
arithmetic_operation

Output
arithmetic_opeartion_output

Clone this wiki locally