Let Us Python Solutions
eBook - ePub

Let Us Python Solutions

Learn by Doing-the Python Learning Mantra

  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Let Us Python Solutions

Learn by Doing-the Python Learning Mantra

Book details
Book preview
Table of contents
Citations

About This Book

Solutions To All Exercises In Let Us Python, Cross-check Your Solutions.Practice! That Is What Python Programming Is All About. To Be Able To Master Python You Need To Practice Writing A Large Number Of Programs In It. As You Try To Do So, You Would Find That There Are Multiple Ways Of Writing Any Program. So You Need To Find Out Whether You Have Chosen The Best Way To Implement Your Program. That's Where You Would Find This Book Useful.'let Us Python' Contains Exercises At The End Of Each Chapter. Solving These Exercises Would Help You Build Your Python Skills. As You Do So, Many Of You Would Feel The Need For A Trusted Companion Who Will Ratify Your Answers And Programs. 'let Us Python Solutions' Will Be That Trusted Companion. It Will Help You Validate Your Answers And Teach You How To Write Better Python Programs.Key FeaturesStrengthens The Foundations, As Detailed Explanations Of Programming Language Concepts Are Given In A Simple Manner.Lists Down All The Important Points That You Need To Know Related To Various Topics In An Organized Manner.Prepares You For Coding Related Interviews And Theoretical Questions.It Provides An In-depth Explanation Of Complex Topics And Questions.It Focuses On How To Think Logically To Solve A Problem.Follows A Systematic Approach That Will Help You To Prepare For An Interview In A Short Duration Of Time.Exercises Are Exceptionally Useful To Complete The Reader's Understanding Of A Topic.What Will You LearnData Types, Control Flow Instructions, Console & File Input/outputStrings, List & Tuples, List ComprehensionSets & Dictionaries, Functions & LambdasDictionary ComprehensionModules, Classes And Objects, InheritanceOperator Overloading, Exception HandlingIterators & Generators, Decorators, Command-line ParsingWho This Book Is ForStudents, Programmers, Researchers, And Software Developers Who Wish To Learn The Basics Of Python Programming Language.About the AuthorsYashavant Kanetkar: Through his books and Quest Video Courses on C, C++, Java, Python, Data Structures,.NET, IoT, etc. Yashavant Kanetkar has created, molded and groomed lacs of IT careers in the last three decades. Yashavant's books and Quest videos have made a significant contribution in creating top-notch IT manpower in India and abroad. Yashavant's books are globally recognized and millions of students/professionals have benefitted from them. Yashavant's books have been translated into Hindi, Gujarati, Japanese, Korean and Chinese languages. Many of his books are published in India, the USA, Japan, Singapore, Korea and China. Yashavant is a much sought after speaker in the IT field and has conducted seminars/workshops at TedEx, IITs, IIITs, NITs and global software companies. Yashavant has been honored with the prestigious "Distinguished Alumnus Award" by IIT Kanpur for his entrepreneurial, professional and academic excellence. This award was given to the top 50 alumni of IIT Kanpur who have made a significant contribution towards their profession and the betterment of society in the last 50 years. In recognition of his immense contribution to IT education in India, he has been awarded the "Best.NET Technical Contributor" and "Most Valuable Professional" awards by Microsoft for 5 successive years. Yashavant holds a BE from VJTI Mumbai and M.Tech. from IIT Kanpur.Aditya Kanetkar is currently working as a Software Engineer at Microsoft Corp., Seattle. Aditya's current passion is anything remotely connected to Python, Machine Learning, Distributed Systems, Cloud Computing, and C# related technologies. Aditya was formerly at Oracle America Inc. in Redwood City, California. Aditya holds a MS in Computer Science from Georgia Tech, Atlanta and B.Tech in Computer Science from IIT Guwahati.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Let Us Python Solutions by Yashavant Kanetkar,Aditya Kanetkar in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Python. We have over one million books available in our catalogue for you to explore.

Information

1

Introduction to Python

[A] Answer the following:
(a) Mention 5 fields in which Python is popularly used.
Answer
- System Programming
- Game Programming
- Robotics Programming
- Rapid Prototyping
- Internet Scripting
(b) Where is event-driven programming popularly used?
Answer
Event-driven programming is primarily used for creating GUI application containing elements like windows, check, boxes, button, combo-boxes, scroll-bars, menus etc. When we interact with these GUI elements through mouse/keyboard/touch an event occurs and a function gets called to tackle that event.
(c) Why Python is called portable language?
Answer
We can create and test code on one platform and run it on any other platform. This makes Python a portable language.
(d) What is the single most important feature of different programming models discussed in this chapter?
Answer
Functional programming model - It decomposes a problem into a set of functions.
Procedural programming model - It solves a problem by implementing one statement (procedure) at a time. Thus it contains explicit steps that are executed in a specific order. It also uses functions, but these are not mathematical functions like the ones used in functional programming. Functional programming focuses on expressions, whereas Procedural programming focuses on statements.
Object-oriented programming model - It mimics the real world by creating inside the computer a mini-world of objects.
Event-driven programming model - It generates events when we interact with different GUI elements like Windows, check boxes, buttons, combo-boxes, scroll bars, menus, etc. Each event is tackled by calling an event handler function.
(e) Which of the following is not a feature of Python?
- Static typing
- Variable declaration before use
- Destruction of objects after use through destructor
- Run-time error handling through error numbers
- Library support for containers like Lists, Dictionaries, Tuples
Answer
- Static typing
- Variable declaration before use
- Destruction of objects after use through destructor
- Run-time error handling through error numbers
[B] State whether the following statements are True or False:
(a) Python is free to use and distribute.
Answer
True
(b) Same Python program can work on different OS - microprocessor combinations.
Answer
True
(c) It is possible to use C++ or Java libraries in a Python program.
Answer
True
(d) In Python type of the variable is decided based on its usage.
Answer
True
(e) Python cannot be used for building GUI applications.
Answer
False
(f) Python supports functional, procedural, object-oriented and event-driven programming models.
Answer
True
[C] Match the following:
a. Functional programming 1. GUI element based interaction
b. Event-driven programming 2. Interaction of objects
c. Procedural programming 3. Statements
d. Object-oriented programming 4. Maths-like functions
Answer
Functional programming - Maths-like Function
Event-driven programming - GUI element based interaction
Procedural programming - Statements
Object-oriented programming - Interaction of objects
[D] Fill in the blanks:
(a) Functional programming paradigm is also known as Declarative programming model.
(b) Procedural programming paradigm is also known as Imperative programming model.
(c) Python was created by Guido Van Rossum.
(d) Python programmers are often called Pythonists or Pythonistas.

2

Python Basics

[A] Answer the following:
(a) Write a program that swaps the values of variables a and b. You are not allowed to use a third variable. You are not allowed to perform arithmetic on a and b.
Program
# Swap values of two variables a = 5
b = 10
a, b = b, a
print(‘a =’, a)
print(‘b =’, b)
Output
a = 10
b = 5
(b) Write a program that makes use of trigonometric functions available in math module.
Program
# Use of trigonometric functions
import math
a = math.pi / 6
print(‘The value of sine of pi / 6 is’, end = ‘’)
print(math.sin(a))
print(‘The value of cosine of pi / 6 is’, end = ‘’)
print(math.cos(a))
Output
The value of sine of pi / 6 is 0.49999999999999994
The value of cosine of pi / 6 is 0.8660254037844387
(c) Write a program that generates 5 random numbers in the range 10 to 50. Use a seed value of 6. Make a provision to change this seed value every time you execute the program by associating it with time of execution?
Program
# Generate random numbers
import random
import time
random.seed(6)
for i in range(5):
print(random.randint(10, 50))
print()
t = int(time.time())
random.seed(t)
for i in range(5):
print(random.randint(10, 50))
Output
46
15
41
26
12
39
36
21...

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. About the Authors
  6. Table of Contents
  7. 1 Introduction to Python
  8. 2 Python Basics
  9. 3 Strings
  10. 4 Decision Control Instruction
  11. 5 Repetition Control Instruction
  12. 6 Console Input/Output
  13. 7 Lists
  14. 8 Tuples
  15. 9 Sets
  16. 10 Dictionaries
  17. 11 Comprehensions
  18. 12 Functions
  19. 13 Recursion
  20. 14 Functional Programming
  21. 15 Modules and Packages
  22. 16 Namespaces
  23. 17 Classes and Objects
  24. 18 Intricacies of Classes and Objects
  25. 19 Containership and Inheritance
  26. 20 Iterators and Generators
  27. 21 Exception Handling
  28. 22 File Input/Output
  29. 23 Miscellany
  30. 24 Multi-threading
  31. 25 Synchronization