uz
Feedback
CBSE COMPUTER SCIENCE

CBSE COMPUTER SCIENCE

Kanalga Telegram’da o‘tish

QUESTION BANK, REFERENCE BOOK, LAB MANUAL , WORKSHEET ETC., PYTHON TEXT BOOK AND REFERENCE BOOKS, 01. ASK QUESTIONS AT https://t.me/joinchat/FJ1noGs-64I0OWI1

Ko'proq ko'rsatish
549
Obunachilar
Ma'lumot yo'q24 soatlar
Ma'lumot yo'q7 kunlar
Ma'lumot yo'q30 kunlar
Postlar arxiv
#Scope of the Variables """The part of the program where it is visible that is Area where you can use it""" A=10 #Global for i in range(3): #A=5 #Embedded print("Outer Loop : ",A+i) for j in range(3): #A=15 #Local print("inner Loop : ",A+j,end=" ") print()

========================= RESTART: /home/maha/scope.py ========================= Outer Loop : 5 inner Loop : 5 inner Loop : 6 inner Loop : 7 Outer Loop : 6 inner Loop : 5 inner Loop : 6 inner Loop : 7 Outer Loop : 7 inner Loop : 5 inner Loop : 6 inner Loop : 7 >>>

#Scope of the Variables """The part of the program where it is visible that is Area where you can use it""" A=10 #Global for i in range(3): A=5 #Embedded print("Outer Loop : ",A+i) for j in range(3): #A=15 #Local print("inner Loop : ",A+j,end=" ") print()

========================= RESTART: /home/maha/scope.py ========================= Outer Loop : 5 inner Loop : 15 inner Loop : 16 inner Loop : 17 Outer Loop : 6 inner Loop : 15 inner Loop : 16 inner Loop : 17 Outer Loop : 7 inner Loop : 15 inner Loop : 16 inner Loop : 17 >>>

#Scope of the Variables """The part of the program where it is visible that is Area where you can use it""" A=10 #Global for i in range(3): A=5 #Embedded print("Outer Loop : ",A+i) for j in range(3): A=15 #Local print("inner Loop : ",A+j,end=" ") print()

def power(a, b): """Returns arg1 raised to power arg2.""" return a**b print(power.doc) Output: Returns arg1 raised to power arg2.

Output: Using doc: Demonstrates triple double quotes docstrings and does nothing really. Using help: Help on function my_function in module main: my_function() Demonstrates triple double quotes docstrings and does nothing really.

def my_function(): '''Demonstrates triple double quotes docstrings and does nothing really.''' return None print("Using doc:") print(my_function.doc) print("Using help:") help(my_function)

SHUNMUGA SUNDARAM S, [29.04.21 23:42] simply says that... It is commenting statement either single line or multiline comment.... SHUNMUGA SUNDARAM S, [29.04.21 23:44] Every function definition, classes may have docstring... that is what is the purpose of the function or classes and so on... and also it should be immediate statement of function definition header...

One-line Docstrings One-liners are for really obvious cases. They should really fit on one line. For example: def kos_root(): """Return the pathname of the KOS root directory.""" global _kos_root if _kos_root: return _kos_root ... Notes: Triple quotes are used even though the string fits on one line. This makes it easy to later expand it. The closing quotes are on the same line as the opening quotes. This looks better for one-liners. There's no blank line either before or after the docstring. The docstring is a phrase ending in a period. It prescribes the function or method's effect as a command ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...".

two types of extra docstrings may be extracted by software tools: String literals occurring immediately after a simple assignment at the top level of a module, class, or init method are called "attribute docstrings". String literals occurring immediately after another docstring are called "additional docstrings".

What is a Docstring? A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the doc special attribute of that object. All modules should normally have docstrings, and all functions and classes exported by a module should also have docstrings. Public methods (including the init constructor) should also have docstrings. A package may be documented in the module docstring of the __init__.py file in the package directory.

====================== RESTART: /home/maha/passingarray.py ===================== Average 1 = 30.0 Average 2 = 35.50833333333333 Average 3 = 30.0 >>>

#Passing an Array/List to a Function def calcavg(L): tot=0 for i in range(len(L)): tot=tot+L[i] return tot/len(L) # Sending Lists object to a function A=[10,20,30,40,50] X=calcavg(A) print("Average 1 =",X) # Sending Lists object to a function A=[10.5,20.6,30.9,40.3,50.3,60.45] X=calcavg(A) print("Average 2 =",X) # Sending Tuple object to a function A=(10,20,30,40,50) X=calcavg(A) print("Average 3 =",X)

photo content

photo content

photo content

photo content

photo content

photo content