⚡0 XP🔥0

Ch 1 · Python Revision Tour | पायथन दोहराव

Lesson 1 of 10 ⏱ 3 min read ✎ 1 exercises ❓ 5-question quiz ▶ Runs Python

Tokens, data types, operators, strings, lists, tuples, dictionaries and control flow - a quick revision of Class 11 Python.

Tokens and data types#

Tokens are the smallest units: keywords, identifiers, literals, operators and punctuators.

Type Example Mutable?
int, float, complex 10, 3.5, 2+3j -
str "Rewa" No
list [1, 2, 3] Yes
tuple (1, 2, 3) No
dict {"roll": 1} Yes (keys must be immutable)
▶ Try it YourselfPython
Ctrl + Enter to run

Operators and precedence#

** (right to left) > unary − > * / // % > + − > relational > not > and > or. Remember // is floor division and % gives the remainder; 7 // 2 = 3, -7 // 2 = -4.

हिंदी में समझें

पायथन में list और dict परिवर्तनशील (mutable) हैं, जबकि str और tuple अपरिवर्तनशील (immutable)। ** ऑपरेटर दाएँ से बाएँ हल होता है - 2 ** 3 ** 2 = 2 ** 9 = 512।

Strings and lists - common methods#

▶ Try it YourselfPython
Ctrl + Enter to run

Control flow#

if-elif-else, for with range(), while, break, continue. A for loop's else runs only if the loop was not ended by break.

Exam tips#

  • Output-prediction questions: trace slicing, negative indices and nested loops carefully.
  • Know the difference between append() and extend(), remove() and pop().

Practice Exercises

Write your code, then press Check. Your program is tested automatically.

1

Count vowels

Read a line of text with input() and print the number of vowels (a, e, i, o, u - upper or lower case).

Test input:
Vindhya Education
Expected output:
7

Quick Quiz

Q1.

Which of these is mutable?

Q2.

Value of 2 ** 3 ** 2 is

Q3.

Output of print('abc'[::-1]) is

Q4.

-7 // 2 evaluates to

Q5.

Dictionary keys must be