Have fun with Python!Samet Atdag This document contains 27 questions in these sections:●Warmup-2 ●Logic-2 ●String-2 ●List-2 Warmup-2 1.string_times Given a string and a non-negative int n, return a larger string that is n copies of the original string.string_times('Hi', 2) ...
Logic-2 make_chocolate We want make a package ofgoalkilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use, assuming we always use big bars before small bars. Return -1 if it can't be done. ...
def close_far(a, b, c): if abs(a - b) <= 1 and abs(c - a) >= 2 and abs(c - b) >= 2 or \ abs(a - c) <= 1 and abs(b - a) >= 2 and abs(b - c) >= 2: return True return False make_chocolate def make_chocolate(small, big, goal): needbig = goal // 5...
Logic-2 close_far next chance Given three ints, a b c, return True if one of b or c is "close" (differing from a by at most 1), while the other is "far", differing from both other values by 2 or more. Note: abs(num) computes the absolute value of a number. ...
SametAtdagThisdocumentcontains44questionsinthesesections:●Warmup-1●String-1●List-1●Logic-1Warmup-11.sleep_inTheparameterweekdayisTrueifitisaweekday,andtheparametervacationisTrueifweareonvacation.Wesleepinifitisnotaweekdayorwe'reonvacation.ReturnTrueifwesleepin.sleep_in(False,False)→Truesleep_in...
Basic boolean logic puzzles -- if else && || ! Logic-2 Medium boolean logic puzzles -- if else && || ! String-2 Medium String problems -- 1 loop String-3 Harder String problems -- 2 loops Array-2 Medium array problems -- 1 loop Array-3 Harder array problems -- 2 loops, ...
Codingbat python logic-1 cigar_party defcigar_party(cigars,is_weekend):ifis_weekendandcigars>=40:returnTrueelif40<=cigars<=60:returnTruereturnFalse date_fashion def date_fashion(you, date): if you <=2 or date <=2: return 0 elif you >=8 or date>=8:...
Have fun with Python!Samet Atdag This document contains 44 questions in these sections:●Warmup-1 ●String-1 ●List-1 ●Logic-1 Warmup-1 1.sleep_in The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is ...
PythonLogic-2 > round_sum prev | next | chance For this problem, we'll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. Alternately, round down to the previous multiple of 10 if its rightmost digit is less than 5, ...