100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary Introduction to phyton $7.99   Add to cart

Summary

Summary Introduction to phyton

 0 view  0 purchase
  • Course
  • Institution

It has a basic information on phyton language

Preview 1 out of 3  pages

  • November 19, 2023
  • 3
  • 2023/2024
  • Summary
  • Secondary school
  • Unknown
  • 1
avatar-seller
The code is in Python, a case-sensitive language. So, we need to
convert a given string to uppercase. Earlier, we talked about
string methods. We can see all the available functions or
methods in a string object by typing dot. We use the upper
method to convert the string to uppercase, which returns a new
string.

If the given string includes a lowercase "k", we should convert
the weight to pounds and print it on a terminal. We declare a
variable called "converted," get the weight, divide it by 0.45 to
convert it to pounds, and print the weight in pounds. To
terminate this block, we add "is" and concatenate it with
"converted."

If the "k" condition is not true, that means the weight was
entered in pounds. To convert it to kilograms, we declare a
variable called "converted," set it to weight times 0.45, and print
the weight in kilograms. To terminate this block, we add "in
kilograms" and concatenate it with "converted."

While Loops in Python
In Python, we use while loops to repeat a block of code multiple
times. We can use this to print the numbers 1 to 1 million times
in Python. But, writing 1 million lines of code isn't a good
approach. We can use a while loop and print the numbers using a
loop instead.

In every iteration of the loop, the value of "i" is incremented by
one. We can use the multiplication operator to repeat a string
based on the value of a number in Python, but we can't
concatenate a number to a string. In this case, we multiply a
number by a string to repeat that string. We see one extra
asterisk in every iteration.

It will never terminate, and our program will continue running
until it runs out of memory. So, we need to add a break
statement to terminate the loop after a certain number of
iterations.

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 sriguru. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

80435 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
$7.99
  • (0)
  Add to cart