Python 3
For the code shown below:
for num in range(4):
print(num)
What is the first value printed?
| 4 |
| 1 |
| No correct answer is shown |
| '0' |
Python 3 For the code shown below: for num in range(4): print(num) What is the first...
I have this code for python: num = int(input()) if num == 0: print('No change') else: dol = num // 100 num %= 100 Quarters = num // 25 num %= 25 Dimes = num // 10 num %= 10 Nickels = num // 5 num %= 5 Pennies = num if dol > 0: if dol == 1: print('1 Dollar') if Dollars > 1: print(dol,'Dollars') if Quarters > 0: if Quarters == 1: print('1 Quarter') if Quarters > 1:...
Python Assignment: def sliceNdice(list2, s,e): L = len(list2) if(s>0 and s<e and e+s<=L): list1 = list2[s:e+s] else: list1 = [ ] return list1 refer to the code above. What is the value of L after line 2 and we call: x = sliceNdice([3,6,9,7] 2,6) 3. Refer to the previous question. What is happening at line 4? 4. For the code shown below: for num in range (1,4): print(num) What is the first value printed
Write a python program write a function numDigits(num) which counts the digits in int num. Answer code is given in the Answer tab (and starting code), which converts num to a str, then uses the len() function to count and return the number of digits. Note that this does NOT work correctly for num < 0. (Try it and see.) Fix this in two different ways, by creating new functions numDigits2(num) and numDigits3(num) that each return the correct number of...
python programming
Which of the following code will print all odd numbers between 3 and 11, each number separated by a space as shown below 35 7 9 11 for i in range(3, 11, 1): if 1%2 ID: print(i, end = " for i in range(3, 10, 2): print(i, end = for i in range, 11, 2): if 152 == 0: print(i, end = "") for i in range 12, 1): print(i, end = "")
In Python: What is the output of the following code? for i in range(5): if i == 2: continue print(i) Question 22 options: 0 1 2 4 0 1 3 4 0 1 3 0 1 4
python
print ("num=", num) 12. (2) The following loop should print the squares of the odd numbers never ends. What is the error and how could it be fixed? num = 1 while num != 12: print (num ** 2) num += 2
47. (2 points) What will the following code print? my-list-on"n) for n in range( 5) İf(n.nr%2--ol print(my_list) Answer Assume that the variable data refers to the list [5, 3, 7). Write the value of the following expressions for questions 48-49. 48. (1 points) datal-11 Answer: 49. (1 points) 0 in data Answer: 50. (4 points) Given my_dict my_dict l'a:3, x':7, r':5, write Python code to print all the key and value pairs of Answer:
c. print python code that requests a person's first name, birth year, birth month like 'January', and birth day of month as input, then outputs a full sentence using the three inputs and another sentence that tells the length of the previous sentence that was printed.. Include one line of comment explaining each line of code: d., print python code that assigns the 4 variables shown in step 8 the math formulas created in step 8. Output a sentence that...
Python
What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. s = 2 for n in range (1, 6): s = s + n print(s) b. s = 1 for n in range (1, 11): n = n + 2 s = s + n print(s) c. S = 1 for in range (1, 6) s = s + n n = n + 1 print(s, n) Rewrite the...
In python What is the output of below code? print(len(“what’s up”))