Def-Keyword

Tue 09 December 2025
#  def keyword
def func():
    print("Inside Function")
func()
Inside Function
#  return keyword
def func_return():
    x = 20
    return x

def func_no_return():
    y = 50

    return y
print(func_return())
20
print(func_no_return())
50
def func():
    x = 0
    for i in range(5):
        x += i
        yield x
for i in func():
    print(i)
0 …

Category: Python basics

Read More

Escape-Sequennce

Tue 09 December 2025
#  Escape Sequence in Python
#  error code for escape sequence 
print("he said 'python is fun ultimated'")
he said 'python is fun ultimated'
print('He said "Python is fun unlimited"')
He said "Python is fun unlimited"
print('He said \'Python is fun unlimited\'')
He said 'Python is fun unlimited'
print("Welcome …

Category: Python basics

Read More

Expression-Python

Tue 09 December 2025
#  Arithmetic Expression
num1 = 20
num2 = 40
sum = num1 + num2 # An arithmetic expression.
print("Sum of two numbers is ", sum)
Sum of two numbers is  60
num1 = 88
num2 = 22
sum = num1 + num2 # An arithmetic expression.
print("Sum of two numbers is ", sum)
Sum of two numbers is  110
# Relational/Conditional …

Category: Python basics

Read More

Facker-Pandas

Tue 09 December 2025
import pyutil as pyu
pyu.get_local_pyinfo()
---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

Cell In[1], line 1
----> 1 import pyutil as pyu
      2 pyu.get_local_pyinfo()


ModuleNotFoundError: No module named 'pyutil'
print(pyu.ps2("pandas"))
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

Cell In[2], line 1
----> 1 print(pyu.ps2("pandas …

Category: Python basics

Read More

Funct-Arg

Tue 09 December 2025
# Default Arguments in Python
def studentInfo(name, gender = 'Male'):
  Cell In[2], line 1
    def studentInfo(name, gender = 'Male'):
                                           ^
SyntaxError: incomplete input
def studentInfo(name, gender = 'Male'):
# This function displays the student's info passed in the function parameters.
    print('Name:',name)
    print('Gender:',gender)
# Main program.
# Function call 1 …

Category: Python basics

Read More

Function-Call

Tue 09 December 2025
# Function call in Python
# Function definition.
def funct_name(): # function header.
    print('This function does not contain any parameter.')
# Main program execution started from here.
funct_name() # function calling.
This function does not contain any parameter.
# Function definition.
def calcSum(x, y): # Here, x and y are local variables.
    z = x + y …

Category: Python basics

Read More

Functions

Tue 09 December 2025
def greet(name):
    return f"Hello, {name}!"

print(greet("Alice"))


def power(base, exponent=2):
    return base ** exponent

print(power(3))     
print(power(3, 3))   


def sum_all(*numbers):
    total = 0
    for num in numbers:
        total += num
    return total

print(sum_all(1, 2, 3, 4))  
Hello, Alice!
9
27
10


Score …

Category: Python basics

Read More

Identity-Operators

Tue 09 December 2025
#  Identity Is operator (is)
x = 20
y = 20
result = x is y
print(result)
True
str1 = "Python"
str2 = "Python"
result = str1 is str2
print(result)
True
name1 = "John"
name2 = "Jack"
result = name1 is name2
print(result)
False
a = True
b = 1
result = a is b
print(result)
False
p = "20 …

Category: Python basics

Read More

Loops (For And While)

Tue 09 December 2025
print("Counting to 5:")
for i in range(1, 6):
    print(i)


count = 0
print("\nWhile loop example:")
while count < 3:
    print(f"Count is {count}")
    count += 1

print("\nLoop control:")
for num in range(10):
    if num == 2:
        continue  
    if num == 7:
        break     
    print(num)
Counting to …

Category: Python basics

Read More
Page 2 of 3

« Prev Next »