1. Please look at Figure 1. We try to use if statement to test if the given number is even or odd. The code is not working as its current form. Please identify one problem with the code.
Figure 1
x=4
if x%2==0
print('x is even')
else:
print('x is odd')
2. We try to define a function in Figure 2, please identify two problems with the code.
Figure 2
def function(input1 input2):
output=input1 + input2
return (output)
Answer 1:
colon missed at if condition
Indentation is missed for print statements:

Answer 2:
Syntax error at parameters. They need to separated by ,other than this there is no error in the code
def function(input1,input2):
output=input1 + input2
return (output)
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
1. Please look at Figure 1. We try to use if statement to test if the...
This exercise is also from C++
How do I even figure this out? please help me solve so I can
get the answer correctly!
Question 28 10 pts (SHORT ANSWER) Define a function named findEvenOrOdd that has 1 int parameter: num. When the function is called, it should use an if/else statement -OR- conditional expression to determine whether the variable num is an even or odd number and display appropriate message as follows: • If the value in num is...
12p
I need help this is Python
EXCEPTIONS: It's easier to ask forgiveness than permission. Try the code and catch the errors. The other paradigm is 'Look before you leap' which means test conditions to avoid errors. This can cause race conditions. 1.Write the output of the code here: class MyError(Exception): pass def notZero(num): if num == 0: raise MyError def run(f): try: exec(f) except TypeError: print("Wrong type, Programmer error") except ValueError: print("We value only integers.") except Zero Division Error:...
USING C# LANGUAGE WE USE SCANF AND PRINTF PLEASE USE THAT IN THE ANSWER WE DONT USE CONSOLEWRITE OR READ Write a program that takes in a number from the user. Then it prints a statement telling the user if the number is even or odd. If the number is odd, it counts down from the number to 0 and prints the countdown on the screen, each number on a new line. If the number is even, it counts down...
Nac Mina Mert - O X midtermoview.coe [Compatibility Mode] Worci Review View Help O lel me what you want to do file Home Insert Design Layout Retreces Mailing Share Predict the output of the following programs: def odd num): if num == 0 : return False else: below = nur 1 returr. even (below) def ever (.1.10.): if Ilut. == 0 : relurr. True else: below num - 1 return odd (below) print. odd (1) orint even (4) print odd...
Please help on my homework Q i got wrong: PYTHON Question 1 def higherOrderFilter(data, p) : res = [] for d in data : if p(d) : res.append(d) return res def FilterR(data, p): if data == []: return [] return [data[0]] + FilterR(data[1:], p) if p(data[0]) else FilterR(data[1:], p) Both of these functions produce the same output given the same data and same filtering condition p. True False Question 2...
python programming
X Canvas 4 → XCO Question 26 10 pts (SHORT ANSWER) Define a function named find_even_odd that has 1 parameter: num. When the function is called, it should use an if/else statement to determine whether the variable num is an even or odd number and display appropriate message as follows: • If the value in num is an even number, the progr will output the message: "XX is an EVEN number", where XX is the value in the...
c++ please
(1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...
use python please
Write two new functions that simulate the addition and
subtraction operators. Each of these functions should accept a
width value as an argument (integer) and a single character
(string) -- the function should then return the generated pattern.
You can assume the operators will always be 5 units high. Here's
some sample code:
temp = plus(5, '*')
print(temp)
print()
temp = minus(5, '*')
print(temp)
Which will generate ...
*
*
*****
*
*
*****
Note that your...
Hi, I need help writing a code for this. The language is python 3, and we cannot use things like break, continue, exit(), lambda, map, filter, raise, try, except, and assert in our code. Thank you! We must write a function called "binary_to_decimal(binary_number)" that takes a string for a binary number and output the decimal integer for that number. The solution, aka the code, MUST contain a for loop of this form (power is an integer variable you define earlier):...
Please write where its written write your code here!! please use java for the code! please use the given code and I will rate thanks Magic index in an array a[1..n] is defined to be an index such that a[ i ] = i. Given an array of integers, write a recursive method to find the first magic index from left to right. If one exists in the given array, return the index number i, otherwise return -1. Here are...