id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

rmueller@lasacs.com final2020period1 > div2and7
prev  |  next  |  chance

Given a number return the string both if it is evenly divisible by both 2 and 7, two if it is only evenly divisible by 2, seven if it is only evenly divisible by 7, and neither if it is not evenly divisible by either 2 or 7. NOTE: Codingbat uses Python 2.6 in which / represents an integer divide. Thus in Python 2.6, 17/5 is equal to the 3. In Python 3.x, 17/5 is equal to 3.4. In Python 2.6, to get a float as an answer for / you must convert either the dividend or the divisor to a float - e.g. float(17)/5 is equal to 3.4.


div2and7(14) → 'both'
div2and7(2) → 'two'
div2and7(21) → 'seven'

...Save, Compile, Run (ctrl-enter)

def div2and7(a):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 100

Copyright Nick Parlante 2017 - privacy