Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# PART 1 (10 minutes or less) # Students: copy the two functions below and load into Python. # TA, after a few minutes, ask

image text in transcribed

# PART 1" (10 minutes or less) # Students: copy the two functions below and load into Python. # TA, after a few minutes, ask 1) give example of input that yields Execute/test on several values. Think about differences different results, 2) give concise but general characterization of difference? def ifV1 (num) if (numS20) print ( num, ' is divisible by 2.') nun%3-0) print ( num, ' is divisible by 3.') elif def fV2 (num) print ( umis divisible by 2.) if (numS30) print ( mum, ' is divisible by 3.') # PART 2" (20 minutes) # How can we extract and print the digits of an integer using math? # Some people might know that in Python we first convert the number to a # string of digitas and then look at each character in the string. BUT, the goal # here is to do it with just math-NO STRING OPERATIONS. # HOW2 Use this approach: l. we can get last digit of an integer by using % 10 digit-: number % 10 #2. we can get a new mumber with all but the last digit via newumber number /f 10 #3. we repeat those steps until nothing's left # (First, everyone should try examples of 1 and 2 at a Python prompt. # E.g" enter 432 % 10 and 432 // 10) # In code these steps become (TAs should write out the code here, bit by bit) def printDigitsOf (number) # add code here return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

What growth strategies might Southwest pursue?

Answered: 1 week ago

Question

4 6 8 . .

Answered: 1 week ago

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago