Comparison-Operator

Tue 09 December 2025
#  Comparison  Operators
# Equal to (==)
x = 20
y = 20
print( x == y)
True
p = 'My name is John'
q = 'My name is John'
print( p == q)
True
r = 'Text'
s = 'text'
print( r == s)
False
t = [1, 2, 3, 4]
u = [1, 2, 3]
print( t == u)
False
List1 = [10, 20 …

Category: Python basics

Read More

Continue-Statement

Tue 09 December 2025
# Syntax of Continue Statement in Python
for letter in 'Technology':
    if letter == 'n':
        print('Skipping the loop at', letter)
        continue
Skipping the loop at n
   print(letter)
y
for letter in 'Technology':
    if letter == 'n':
        print('Skipping the loop at', letter)
        continue
    print(letter)
T
e
c
h
Skipping the …

Category: Python basics

Read More

Control Flow (If, Elif, Else)

Tue 09 December 2025
age = 18
if age >= 18:
    print("You are an adult")
else:
    print("You are a minor")


score = 85
if score >= 90:
    grade = 'A'
elif score >= 80:
    grade = 'B'
elif score >= 70:
    grade = 'C'
else:
    grade = 'D'
print(f"Your grade is {grade}")


is_even = "Even" if (age % 2 == 0) else "Odd …

Category: Python basics

Read More

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
Page 2 of 4

« Prev Next »