Python-Buildin-Types

Wed 12 November 2025
#  created : 20250113
#  https://www.scientecheasy.com/2022/09/data-types-in-python.html/
#  Dynamic data

#  which means we dont want to specify a data type when assigning to a variable
#  the change in the value leads to a change in data type
my_var = "Hi Friends!" # holding string.
my_var = 25 # same variable holding numeric …

Category: python-basics

Read More

Python-Comments

Wed 12 November 2025
#  created : 20250112
#  https://www.scientecheasy.com/2022/09/comments-in-python.html/
#  in python comments are written in (#) symbol
print('Hello mate!!')  # this will not get print in the output
Hello mate!!
name = "Jerin" # Variable declaration and initialization.
print(name)
Jerin
#  multi line comments used like this 
'''
I 
am
multiline 
comments
'''
'\nI …

Category: python-basics

Read More

Python-Delimeter

Wed 12 November 2025
#  created : 20250111
#  https://www.scientecheasy.com/2022/09/reserved-keywords-in-python.html/
#  list of delimeters 
msg = 'hi jerin how are you'  # --> single quote delimeter
print(f'{msg}')
hi jerin how are you
num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # --> square braces delimiter
print(num)
[1, 2, 3, 4 …

Category: python-basics

Read More

Python-Docstring

Wed 12 November 2025
#  created : 20250113
#  https://www.scientecheasy.com/2022/09/docstring-in-python.html/
#  docstring in python 
# Function with a Docstring.
def getSum(x, y):
    """This is a docstring

    This method takes two argument values and returns the summation of it."""
    print("Sum = ", (x + y))
getSum(20, 40) # Calling function.
print(getSum.__doc__) # Calling …

Category: python-basics

Read More

Python-Indentations

Wed 12 November 2025
#  created : 20250112
#  https://www.scientecheasy.com/2022/09/indentation-in-python.html/
#  Python indentations

#  in python indendation means the whitespace 
#  after function definition we have to give four indendation
def display():
  var = "Scientech Easy" 
  print(var)
display()
Scientech Easy
def display(parameter):
    var = "Hello" 
    print(var) 
    print(var, parameter)
display("Python")
Hello …

Category: python-basics

Read More

Python-Literals

Wed 12 November 2025
#  created : 20250112
#  https://www.scientecheasy.com/2022/09/literals-in-python.html/
#  python literals
# Types of literals

# String literals
# Numeric literals
# Boolean literalsb
# Literal Collections
#  single line string
sigle_line_string = 'Welcome \
to \
Scientech Easy'
print(sigle_line_string)
Welcome to Scientech Easy
multi_line_string = '''Welcome \
to \
Scientech Easy, \
Dhanbad'''
print(multi_line_string)
Welcome to Scientech Easy, Dhanbad …

Category: python-basics

Read More

Python-Tokens

Wed 12 November 2025
#  created : 20250113
#  https://www.scientecheasy.com/2022/09/python-tokens.html/
#  python tokens
# Keywords (Reserved words) : True, False, None, class, continue, break, if, elif, else, from, or, def, del, import, etc.
# Identifier : User-defined names
# Literals : String, Numeric, Boolean, Collection,
# Delimeters : ( ), { }, [ ], :, ., =, ;, +=, -=, *=, /=, %=, etc.
# Operators : +, -, *, **, /, %, <<, >>, etc.
x = int(input("Enter your first number = ")) # --> in …

Category: python-basics

Read More

Replace-Negative

Wed 12 November 2025

def replace_negatives(lst):
    replaced = [x if x >= 0 else 0 for x in lst]
    print("List after Replacing Negatives:", replaced)

# Example usage
replace_negatives([-1, 2, -3, 4, -5])
List after Replacing Negatives: [0, 2, 0, 4, 0]
# intersection of a list 
def list_intersection(lst1, lst2):
    intersection = [x for x in …

Category: python-basics

Read More

Reversed-Keyword

Wed 12 November 2025
#  created : 20250111
#  https://www.scientecheasy.com/2022/09/reserved-keywords-in-python.html/
import keyword
print(keyword.kwlist)
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield …

Category: python-basics

Read More

Second-Large-Numbers

Wed 12 November 2025

def second_largest(numbers):
    if len(numbers) < 2:
        return "Error: List must have at least two distinct numbers."

    # Remove duplicates
    unique_numbers = list(set(numbers))

    if len(unique_numbers) < 2:
        return "Error: Not enough distinct numbers to determine the second largest."

    # Sort the unique numbers in descending order
    unique_numbers.sort(reverse=True)

    # Return …

Category: python-basics

Read More
Page 7 of 8

« Prev Next »