100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary Think Python2 Chapter 5 $3.38   Add to cart

Summary

Summary Think Python2 Chapter 5

 147 views  0 purchase
  • Course
  • Institution
  • Book

This is the summary for YOU, if you want to learn the basics of Python quickly. Not everyone has time to read a book of more than 200 pages. That's why I thought, why don't I make a short summary of it! This is a summary of chapter 5 of the book ThinkPython2 (with the exercises!). I can't summari...

[Show more]

Preview 1 out of 7  pages

  • No
  • Chapter 5
  • October 8, 2018
  • 7
  • 2018/2019
  • Summary
avatar-seller
Chapter 5 Conditionals and recursion




The main topic of this chapter is the if statement, which executes different code depending on the
state of the program. But first two new operators are introduced: floor division and modulus.
5.1 Floor division and modulus
The floor division operator (//) divides 2 integers and round down to an integer. Suppose a movie
is 105 minutes. You want to know how many hours that is. A division returns a floating point:
>>> minutes = 105 1.75
>>> minutes / 60
But you want to know it in an integer. Floor division returns the hours in integer, rounding down:
>>> minutes = 105 1
>>> hours = minutes // 60
>>> hours
To get the remainder you use modulus (%) which divides 2 numbers and returns the remainder:
>>> remainder = minutes % 60 45
>>> remainder
You could also use this to check whether a number is divisible by another: if x % y is 0, then x is
divisible by y. Or you could extract the right most digit(s) from a number: x % 10 yields the right-
most digit of x (in base 10). Similarly x % 100 yields the last two digits.
5.2 Boolean expressions

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Yuna429. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $3.38. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79064 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$3.38
  • (0)
  Add to cart