Python programming for beginners by Tanjimul Islam Tareq
Author:Tanjimul Islam Tareq
Language: eng
Format: epub
Publisher: BookRix
class Student(Person):
def init(self, name, age, student_id):
super().init(name, age)
self.student_id = student_id
def say_hello(self):
print(f"Hello, my name is {self.name}, I'm {self.age} years old and my student ID is {self.student_id}")
Output:
student = Student("Mike", 20, 12345)
student.say_hello()
In this example, we are creating a new class called Student that inherits from the Person class. The Student class adds a new attribute called student_id, and overrides the say_hello method to include the student_id in the output. We then create an object of the Student class and call the say_hello method.
2.2.2 Functional Programming
Python also supports functional programming concepts, such as higher-order functions, lambda functions, and map/reduce/filter functions.
- Higher-order functions: A higher-order function is a function that takes another function as an argument or returns a function as its result. For example:
def apply_function(f, x):
return f(x)
def square(x):
return x * x
result = apply_function(square, 2)
print(result)
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Brazilian Economy since the Great Financial Crisis of 20072008 by Philip Arestis Carolina Troncoso Baltar & Daniela Magalhães Prates(100668)
International Integration of the Brazilian Economy by Elias C. Grivoyannis(70691)
The Art of Coaching by Elena Aguilar(52093)
Flexible Working by Dale Gemma;(23199)
How to Stop Living Paycheck to Paycheck by Avery Breyer(19544)
The Acquirer's Multiple: How the Billionaire Contrarians of Deep Value Beat the Market by Tobias Carlisle(12074)
Thinking, Fast and Slow by Kahneman Daniel(11699)
The Radium Girls by Kate Moore(11575)
The Art of Thinking Clearly by Rolf Dobelli(9820)
Hit Refresh by Satya Nadella(8826)
The Compound Effect by Darren Hardy(8445)
Atomic Habits: Tiny Changes, Remarkable Results by James Clear(7995)
Tools of Titans by Timothy Ferriss(7746)
Turbulence by E. J. Noyes(7668)
Change Your Questions, Change Your Life by Marilee Adams(7326)
Nudge - Improving Decisions about Health, Wealth, and Happiness by Thaler Sunstein(7204)
A Court of Wings and Ruin by Sarah J. Maas(7166)
How to Be a Bawse: A Guide to Conquering Life by Lilly Singh(7138)
Win Bigly by Scott Adams(6795)
