0% found this document useful (0 votes)
2 views5 pages

Python Recursion and Functions Guide

The document provides detailed and short notes on various Python concepts including recursion, input functions, return statements, loops, and data structures. It explains key topics such as the importance of base cases in recursion, the use of the input() function, and the differences between mutable and immutable types. Additionally, it covers error handling with try-except, module imports, and other fundamental programming principles.

Uploaded by

khushimourya494
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Python Recursion and Functions Guide

The document provides detailed and short notes on various Python concepts including recursion, input functions, return statements, loops, and data structures. It explains key topics such as the importance of base cases in recursion, the use of the input() function, and the differences between mutable and immutable types. Additionally, it covers error handling with try-except, module imports, and other fundamental programming principles.

Uploaded by

khushimourya494
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON FULL NOTES (DETAILED + SHORT)

------------------------------------

1. TERMINATING CONDITION IN RECURSION

Detailed: A recursion must stop at a base case, otherwise it keeps calling itself infinitely and crashes.

Short: Base case stops infinite recursion.

2. input() FUNCTION

Detailed: Takes user input as a string.

Short: Used to take input.

3. return STATEMENT

Detailed: Sends a value back to the calling point of a function.

Short: Gives output from function.

4. RETURN VALUES CONDITIONS

Detailed: Function can return none, single, multiple values.

Short: Returns multiple types.

5. BOOLEAN FUNCTION

Detailed: Function returning True/False.

Short: True or False function.

6. FACTORIAL (RECURSION)

fact(n)=n*fact(n-1), base: if n==0 return 1.

7. FIBONACCI SERIES

fib(n)=fib(n-1)+fib(n-2), base: 0→0,1→1.

8. GCD USING RECURSION


gcd(a,b)=gcd(b,a%b), base: b == 0.

9. LOOPS

Detailed: Repeat blocks of code.

Short: Repetition.

10. range()

Generates number sequence.

11. FILE – READING WORD LIST

Use readlines().

12. 'in' OPERATOR

Checks membership.

13. LIST/TUPLE/DICT/STRING

List=mutable, Tuple=immutable, Dict=key-value, String=text.

14. EXCEPTION HANDLING

Prevents crash.

15. TRY–EXCEPT–FINALLY

try: risky code, except: error, finally: always runs.

16. open() MODES

r, w, a, rb, wb.

17. SET

Unordered unique items.

--- SECOND PAGE ---


18. PREFIX/POSTFIX

Python has prefix, no postfix.

19. type() OPERATOR

Shows data type.

20. SYNTAX VS RUNTIME ERROR

Syntax=before running. Runtime=while running.

21. FUNCTION & USE

Reusability, readability.

22. USER-DEFINED VS BUILT-IN

User-created vs Python-provided.

23. =, ==, ===

Assign, compare, (=== not in Python).

24. ASSIGNMENT VS EQUALITY

= assign, == check.

25. KEYWORDS

Reserved.

26. import

Loads modules.

27. DOT OPERATOR

Access module functions.

28. MODULE

File with functions.


29. SMALL PROGRAMS

Basic loops, conditions.

30. LOOPS / NESTED LOOPS

Loops inside loops.

31. IF–ELSE

Decision making.

32. pass

Empty placeholder.

33. NESTED CONDITIONS

if inside if.

34. RECURSION

Function calling itself.

------------------------------------

SHORT NOTES (1-PAGE REVISION)

• recursion → needs base case

• input() → takes string input

• return → sends back value

• loops → repeat code

• try–except → handle errors

• list=mutable, tuple=immutable

• = assign, == compare

• import → use module

• nested loops → loops inside loops


• recursion → fact, fib, gcd

------------------------------------

You might also like