VOOZH about

URL: https://www.geeksforgeeks.org/python/output-python-programs-set-23-string-loops/

⇱ Output of Python Programs | Set 23 (String in loops) - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of Python Programs | Set 23 (String in loops)

Last Updated : 14 Dec, 2017
Prerequisite: Loops and String Note: Output of all these programs is tested on Python3
1. What is the output of the following?
  1. None
  2. geeksforgeeks
  3. i i i i i i …
  4. g e e k s f o r g e e k s
Output:
1. None
Explanation: 'i' is not present in string 'geeksforgeeks'
2. What is the output of the following?
  1. 0 1 2 3 0
  2. 0 1 2 0
  3. 0 1 2
  4. Error
Output:
2. 0 1 2 0
Explanation: The else part is executed when the condition in the while statement is false.
3. What is the output of the following?
  1. 0 1 2 3 ... 12
  2. geeksforgeeks
  3. None
  4. Error
Output:
4. Error
Explanation: range(str) is not allowed.
4. What is the output of the following?
  1. GEEKSFORGEEKS
  2. geeksforgeeks
  3. Error
  4. None
Output:
2. geeksforgeeks
Explanation: Changes do not happen in-place, rather it will return a new instance of the string.
5. What is the output of the following?
  1. gaaaaaaaaaaaa
  2. geeksforgeeks a a a a a a a a a a a a
  3. Error
  4. None
Output:
2. geeksforgeeks a a a a a a a a a a a a
Explanation: String is modified only after ‘geeksforgeeks’ has been printed once.
Comment