+ 1

What is the output of this code

Num=7 If num> 3: Print("3") If num==7: Print("7") Option 👉a) none ,b)print (3), c) print (7) D) all of the above

28th Apr 2020, 10:04 AM
Rubio
Rubio - avatar
61 ответ
+ 9
Good Lord ! Why would you use 'If' and 'Print' and both Num and num in one place?? Learn the difference between uppercase and lowercase letters first.
29th Apr 2020, 12:37 PM
Mehnaz ✨
Mehnaz ✨ - avatar
+ 6
Oma Falk because "If" instead of "if", and "Print" instead of "print" etc?
28th Apr 2020, 11:12 AM
Anananel [INACTIVE]
Anananel [INACTIVE] - avatar
+ 4
The output will be : 3 7 ''' When you use if operator followed by if operator then both the expression would be executed irrespective of the expression being true or false'''
29th Apr 2020, 4:27 AM
$layer
$layer - avatar
+ 4
It will throw error. As here If👈is used. It should b if.
30th Apr 2020, 8:28 AM
Amisha Jha
Amisha Jha - avatar
+ 3
First: Num and num are not same. So if we consider it as a program (a) will be the output. Second: If we consider it as a typing mistake then the output will be (a) Explanation: first we can see num's value is 7 which is greater than 3 so it will print 3. Now as you haven't used "else", instead of skipping the next code, python will check it against the condition as it has a "if" part. And as 7 is equal to 7 it will print 7 onto the console. So the final answer will be 37. Option D says all but alone a or b will not be printed.
29th Apr 2020, 8:23 PM
Anupam datta
Anupam datta - avatar
+ 2
Anananel yes BTW copy to codeplayground will do it.
28th Apr 2020, 11:26 AM
Oma Falk
Oma Falk - avatar
+ 1
This is a basic calculation that could have been done in the code playground. If the "nim" is meant to be "num" then the answer will output "3 7". So, it'll be D.
28th Apr 2020, 10:12 AM
rafalzacher1
+ 1
That's the comparison operator, it checks in this context of the variable num equals 7, it it does it will print 7 otherwise nothing will happen.
28th Apr 2020, 10:19 AM
rafalzacher1
+ 1
Ok thanks
28th Apr 2020, 10:20 AM
Rubio
Rubio - avatar
+ 1
error the output is error
28th Apr 2020, 10:59 AM
Oma Falk
Oma Falk - avatar
+ 1
Output is 3 7
29th Apr 2020, 11:43 AM
Roghayeh
Roghayeh - avatar
+ 1
Output: Traceback(most recent call last) if num>3 NameError name 'num' is not defined
29th Apr 2020, 2:01 PM
🥞OlAd46kA
🥞OlAd46kA - avatar
+ 1
Nothing because the variable Num if different to num and the if statement is not write it correctly and the print function too.
29th Apr 2020, 11:37 PM
Jonathan Alvarado
Jonathan Alvarado - avatar
+ 1
num=7 if num > 3: print("3") if num==7: print("7") Here is what u would want to write also the output is: 3 7
30th Apr 2020, 12:29 AM
Razvan Radu
Razvan Radu - avatar
+ 1
That would be 3 if the 'else' preceeds the if statement, or the whole value would have collapsed if the return statement preceeds the if. if i'm right.
30th Apr 2020, 3:01 AM
Divine Onyema
Divine Onyema - avatar
+ 1
The problem is in the code
30th Apr 2020, 4:24 AM
Spiderboy Scrambling
Spiderboy Scrambling - avatar
+ 1
None bc u had to use "elif" instead of the second "if"
30th Apr 2020, 5:10 AM
Simera
+ 1
Yup
30th Apr 2020, 5:11 AM
Spiderboy Scrambling
Spiderboy Scrambling - avatar
+ 1
error
30th Apr 2020, 5:19 AM
HARSHA ASHMIN
HARSHA ASHMIN - avatar
+ 1
no
30th Apr 2020, 6:35 AM
Spiderboy Scrambling
Spiderboy Scrambling - avatar