Python
Python Basics
- Introduction to Python and Its History
- Python Syntax and Indentation
- Python Variables and Data Types
- Dynamic and Strong Typing
- Comments and Docstrings
- Taking User Input (input())
- Printing Output (print())
- Python Operators (Arithmetic, Logical, Comparison)
- Type Conversion and Casting
- Escape Characters and Raw Strings
Data Structures in Python
- Strings and String Manipulation in Python
- Python Lists: A Guide to `list` and List Methods
- Tuples in Python: Immutable Sequences Made Easy
- Dictionaries in Python: Key-Value Pairs Explained Simply
- Python Sets: Unordered Collections Made Simple
- List Comprehensions and Generator Expressions in Python
- Dictionary Comprehensions in Python
- Set Comprehensions in Python
- String Formatting in Python: f-strings, format(), and % Operator
- Indexing and Slicing in Python: Lists, Strings, and Tuples
Python Core Concepts
Python Collections
- Python collections ChainMap
- Python collections
- Python collections ChainMap<
- Python counters
- Python deque
- Python dictionary
- Python Lists
Python Programs
- Array : Find median in an integer array
- Array : Find middle element in an integer array
- Array : Find out the duplicate in an array
- Array : Find print all subsets in an integer array
- Program : Array : Finding missing number between from 1 to n
- Array : Gap and Island problem
- Python Program stock max profit
- Reverse words in Python
- Python array duplicate program
- Coin change problem in python
- Python Write fibonacci series program
- Array : find all the pairs whose sum is equal to a given number
- Find smallest and largest number in array
- Iterate collections
- List comprehensions in Python
- Program: Calculate Pi in Python
- String Formatting in Python
python tuples
Discover the power of Python tuples—a cornerstone of immutable, ordered collections. Learn about tuple packing and unpacking, and how tuples enhance data integrity and efficiency in Python programming.
import pandas as pd
import csv
def getMedian(lst):
sorted_lst = sorted(lst)
n = len(sorted_lst)
if n % 2 == 0:
middle1 = sorted_lst[n // 2 - 1]
middle2 = sorted_lst[n // 2]
median = (middle1 + middle2) / 2
else:
median = sorted_lst[n // 2]
return median
ceditlist=[]
print(type(ceditlist))
with open("/Users/npblue/PycharmProjects/data/credit.csv", 'r') as file:
csvreader = csv.reader(file, delimiter=',')
count=0
for row in csvreader:
if count==0:
count += 1
else:
ceditlist.append(row)
amountTuple=()
for row in ceditlist:
amountTuple+=(float(row[7]),)
print(amountTuple)
print("Type :",type(amountTuple))
print("min value :",min(amountTuple))
print("max value :",max(amountTuple))
print("mean value :",sum(amountTuple)//len(amountTuple))
print("median value :",getMedian(amountTuple))
#Mode: The most frequent number—that is, the number that occurs the highest number
# of times.
# mode we can not calculate using set because all element are unique
#print("mode value :",max(set(amountset), key=amountset.count))