Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Coding Issue!
#3
(Sep-13-2019, 08:33 AM)ankitdixit Wrote: Hello Everyone,

Why Is The “Pass” Keyword Used For In Python?

>>> if x==0:
pass
else:
print "x!=0"

Anyone tell me why it is used in python or Anyone tells me best wat to learn python. I want to explore more about python coding.

In spoken language it's: 'if x is equal zero do nothing, else print that x is not equal to zero.'. However, in spoken language and in Python it usually expressed:

# spoken language: "if x is not equal to zero notify the user about that"
if x != 0:
    print('x != 0')
EDIT:

Of course there is built-in help in Python (press 'q' key to exit help):

>>> help('pass')
The "pass" statement
********************

   pass_stmt ::= "pass"

"pass" is a null operation — when it is executed, nothing happens. It
is useful as a placeholder when a statement is required syntactically,
but no code needs to be executed, for example:

   def f(arg): pass    # a function that does nothing (yet)

   class C: pass       # a class with no methods (yet)
(END)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Python Coding Issue! - by ankitdixit - Sep-13-2019, 08:33 AM
RE: Python Coding Issue! - by jsira2003 - Sep-13-2019, 09:56 AM
RE: Python Coding Issue! - by perfringo - Sep-13-2019, 10:58 AM
RE: Python Coding Issue! - by rohanjoshi0894 - Sep-25-2019, 06:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Very basic coding issue aary 4 2,527 Jun-03-2020, 11:59 AM
Last Post: buran
  Very basic coding issue mstichler 3 2,637 Jun-03-2020, 04:35 AM
Last Post: mstichler
  Coding issue 1557676 2 36,560 Aug-02-2019, 08:54 PM
Last Post: cvsae
  New member with simple coding issue shaikh 0 3,037 Apr-24-2017, 05:28 PM
Last Post: shaikh
  coding issue Lee 2 3,552 Feb-13-2017, 10:53 AM
Last Post: Lee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020