Python – Quiz 1 – Answers

Python Quiz 1 Questions with Answers

  1. In Python 3, int value has no upper limit. We can store any length number as int.
    Answer: True. We dont have any length for datatypes in Python 3.
  2. How do you write 1234 as hexadecimal number in python
    Answer: For hexadecimal, we should add 0x or 0X before to the number. Thus, the answer is 0x1234 and 0X1234
  3. Write 2.3 * 10 power 3 in python using exponential approach
    Answer: exponential values are written as number prefixed by e. 2.3 * 10 power 3 is written as 2.3E3 or 2.3e3
  4. What is the answer of ‘python'[-4]
    Answer: Unlike other programming languages, Python has negative indexing. Last character of the string is -1 and it travels towards right. Here, for the given string ‘python’, -1 value is ‘n’, -2 value is ‘o’ and so on. Thus, ‘python'[-4] is ‘t’.
  5. What is the output of print(“c:\\new folder”)
    Answer: Usually, \n denotes new line character in Python. To avoid the confusion, we give \ separately, the next \n will not be considered as new line character. Thus, we could get c:\new folder as output.
  6. 50/4*4+4-4
    Answer: BODMAS rule is applied here. BODMAS is a short form for Brackets, Of, Division, Multiplication, Addition and Subtraction.
    Thus, the answer is 50.0
  7. “raja”*(3+4) – What is the answer for this
    Answer: 3+4 will be 7. 7 times raja will be printed.
    rajarajarajarajarajarajaraja
  8. name = “payilagam chennai”
    print(name[2::-1])

    Answer: We know step operator. Default step value is 1. If we specify step value in negative, characters will be printed from right to left. Hence, we start from index 2, i.e., ‘y’ and traverse from right to left. Thus, the output is ‘yap’.