Abstraction in Python Programming

slide1 n.w
1 / 11
Embed
Share

Explore the concept of abstraction in Python programming, from simplifying complex processes to utilizing functions as abstractions. Learn how abstraction is utilized in programming and gain insights into various aspects of abstraction in Python.

  • Python
  • Abstraction
  • Programming
  • Functions
  • Concepts

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. ABSTRACTION IN PYTHON Peter Larsson-Green J nk ping University Autumn 2018

  2. WHAT IS ABSTRACTION? A simplified view of how something complex works.

  3. WHAT IS ABSTRACTION? A simplified view of how something complex works.

  4. WHAT IS ABSTRACTION? A simplified view of how something complex works.

  5. ABSTRACTION IN PROGRAMMING Functions are abstractions. print() prints to the console. How?! input() reads from the console. How?! open() opens a file. How?!

  6. ABSTRACTION IN PROGRAMMING Functions are abstractions. def is_most_popular_name_in_sweden(name): # ... if is_the_most_popular_name_in_sweden("Alice"): print("Alice is the most popular name in Sweden.") else: print("There exists more popular names than Alice in Sweden.")

  7. ABSTRACTION IN PROGRAMMING def get_distance(lon1, lat1, lon2, lat2): return ((lon2 - lon1)**2 + (lat2 - lat1)**2)**0.5

  8. ABSTRACTION IN PROGRAMMING The function get_all_humans() gives you back all the humans in the world. The function get_oldest_human(human1, human2) gives you back the oldest of human1 and human2. def get_all_humans(): # ... def get_oldest_human(human1, human2): # ... humans = get_all_humans() oldest = humans[0] for human in humans: oldest = get_oldest_human(oldest, human)

  9. ABSTRACTION IN PROGRAMMING Functions are abstractions. A lot of other things are abstractions as well. 2 + 5 evaluates to 7. How?! if-else statement conditionally executes other statements. How?! for loop iterates over a sequence of values. How?!

  10. SUMMARY Abstraction: Just accept that things work in some specific ways.

More Related Content