From 4c4c68119501fa0518a2ac7095e7fa68957e6a1a Mon Sep 17 00:00:00 2001 From: Makkapati Harshini Sai <25wh1a05j6@bvrithyderabad.edu.in> Date: Fri, 25 Sep 2026 11:26:55 +0530 Subject: [PATCH] Fix prose typos in functions and OOP lectures --- lectures/functions.md | 10 +++++----- lectures/oop_intro.md | 6 +++--- lectures/python_oop.md | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lectures/functions.md b/lectures/functions.md index 9152f15d..09f3148c 100644 --- a/lectures/functions.md +++ b/lectures/functions.md @@ -25,7 +25,7 @@ kernelspec: ## Overview -Functions are an extremely useful construct provided by almost all programming. +Functions are an extremely useful construct provided by almost all programming languages. We have already met several functions, such as @@ -35,7 +35,7 @@ We have already met several functions, such as In this lecture we'll 1. treat functions systematically and cover syntax and use-cases, and -2. learn to do is build our own user-defined functions. +2. learn how to build our own user-defined functions. We will use the following imports. @@ -360,7 +360,7 @@ Notes Now, there are several ways that we can simplify the code above. -For example, we can get rid of the conditionals all together by just passing the desired generator type as a function, method, or other [callable](https://typing.python.org/en/latest/spec/callables.html) object. +For example, we can get rid of the conditionals altogether by just passing the desired generator type as a function, method, or other [callable](https://typing.python.org/en/latest/spec/callables.html) object. To understand this, consider the following version. @@ -417,7 +417,7 @@ your programming career. Basically, a recursive function is a function that calls itself. -For example, consider the problem of computing $x_t$ for some t when +For example, consider the problem of computing $x_t$ for some $t$ when ```{math} :label: xseqdoub @@ -669,7 +669,7 @@ print([x(i) for i in range(10)]) :label: func_ex5 ``` -Rewrite the function `factorial()` in from [Exercise 1](factorial_exercise) using recursion. +Rewrite the function `factorial()` from [Exercise 1](factorial_exercise) using recursion. ```{exercise-end} ``` diff --git a/lectures/oop_intro.md b/lectures/oop_intro.md index 21787a1d..cd5d9699 100644 --- a/lectures/oop_intro.md +++ b/lectures/oop_intro.md @@ -192,7 +192,7 @@ When Python creates this integer object, it stores with it various auxiliary inf Any name following a dot is called an *attribute* of the object to the left of the dot. -* e.g.,``imag`` and `__class__` are attributes of `x`. +* e.g., `imag` and `__class__` are attributes of `x`. We see from this example that objects have attributes that contain auxiliary information. @@ -299,7 +299,7 @@ The answer is related to the fact that Python aims for readability and consisten In Python, it is common for users to build custom objects --- we discuss how to do this {doc}`later `. -It's quite common for users to add methods to their that measure the length of +It's quite common for users to add methods to their objects that measure the length of the object, suitably defined. When naming such a method, natural choices are `len()` and `length()`. @@ -343,7 +343,7 @@ This includes not just lists, strings, etc., but also less obvious things, such * files opened for reading or writing * integers, etc. -Remember that everything is an object will help you interact with your programs +Remembering that everything is an object will help you interact with your programs and write clear Pythonic code. ## Exercises diff --git a/lectures/python_oop.md b/lectures/python_oop.md index 14d4403f..4fae2993 100644 --- a/lectures/python_oop.md +++ b/lectures/python_oop.md @@ -155,7 +155,7 @@ Before we do so, in order to indicate some of the power of Classes, we'll define ```{code-cell} python3 def earn(w,y): - "Consumer with inital wealth w earns y" + "Consumer with initial wealth w earns y" return w+y def spend(w,x): @@ -186,7 +186,7 @@ print("w0,w1,w2,w3,w4 = ", w0,w1,w2,w3,w4) A *Class* bundles a set of data tied to a particular *instance* together with a collection of functions that operate on the data. -In our example, an *instance* will be the name of particular *person* whose *instance data* consist solely of its wealth. +In our example, an *instance* will be the name of a particular *person* whose *instance data* consist solely of its wealth. (In other examples *instance data* will consist of a vector of data.) @@ -206,7 +206,7 @@ We'll build a `Consumer` class with Admittedly a little contrived, this example of a class helps us internalize some peculiar syntax. -Here how we set up our Consumer class. +Here's how we set up our Consumer class. ```{code-cell} python3 class Consumer: @@ -223,7 +223,7 @@ class Consumer: "The consumer spends x dollars if feasible" new_wealth = self.wealth - x if new_wealth < 0: - print("Insufficent funds") + print("Insufficient funds") else: self.wealth = new_wealth ``` @@ -240,7 +240,7 @@ The `earn` and `spend` methods deploy the functions we described earlier and tha The `__init__` method is a *constructor method*. -Whenever we create an instance of the class, the `__init_` method will be called automatically. +Whenever we create an instance of the class, the `__init__` method will be called automatically. Calling `__init__` sets up a "namespace" to hold the instance data --- more on this soon.