100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
INF1511 Unit 3 Jupyter Notebook Answers $2.98   Add to cart

Other

INF1511 Unit 3 Jupyter Notebook Answers

 26 views  0 purchase
  • Course
  • Institution

The answers to the exercises in the Jupyter Notebook for unit 3 (FOR/WHILE/LOOPING).

Preview 1 out of 2  pages

  • May 15, 2022
  • 2
  • 2022/2023
  • Other
  • Unknown
avatar-seller
INF1511 Unit 3 Jupyter Notebook
Answers
If you need help or have any questions please email: learning.materials.docs@gmail.com




1.Write a program to print the even numbers from a start number to an end
number.

#this code prints the even numbers from start number to an end number
for icount in range (0,13,2):
print(icount)

2.Write a program to print the odd numbers from a start number to an end
number as input from the user.

start_number=int(input('Please provide a number : '))
end_number=int(input('Please provide a number : '))
for icount in range(start_number,end_number,):

#condition for printing odd numbers only from the range
if icount % 2 != 0:

#number % 2==0 is a valid boolean expression that checks whether number %2
is equivalent to 0
#for even numbers the result is the value True
#for odd numbers its the opposite: %2 !=0

print(icount)

3.Write a program that uses a FOR loop. The program must prompt the digits
of your ID number. The program must output each digit as well as the sum
of the digits.

#this code prompts your ID number and sum of the digits
idnumber=int(input('Please provide your ID number : '))
#inputs the id number

print(idnumber)
#outputs the digits of id number

print(sum(int(digit) for digit in str(idnumber)))
#outputs the sum of the id number digits

4.Write a program that requests numbers as input from the user. Add these
numbers. The WHILE loop must terminiate once the sum exceeds a
SecretNumber variable value. Please make provision to avoid an infinte
loop!

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

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

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