Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kumar rakshith patch 1 #555

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 65 additions & 124 deletions 03_Day_Operators/day-3.py
Original file line number Diff line number Diff line change
@@ -1,124 +1,65 @@
# Arithmetic Operations in Python
# Integers

print('Addition: ', 1 + 2)
print('Subtraction: ', 2 - 1)
print('Multiplication: ', 2 * 3)
print ('Division: ', 4 / 2) # Division in python gives floating number
print('Division: ', 6 / 2)
print('Division: ', 7 / 2)
print('Division without the remainder: ', 7 // 2) # gives without the floating number or without the remaining
print('Modulus: ', 3 % 2) # Gives the remainder
print ('Division without the remainder: ', 7 // 3)
print('Exponential: ', 3 ** 2) # it means 3 * 3

# Floating numbers
print('Floating Number,PI', 3.14)
print('Floating Number, gravity', 9.81)

# Complex numbers
print('Complex number: ', 1 + 1j)
print('Multiplying complex number: ',(1 + 1j) * (1-1j))

# Declaring the variable at the top first

a = 3 # a is a variable name and 3 is an integer data type
b = 2 # b is a variable name and 3 is an integer data type

# Arithmetic operations and assigning the result to a variable
total = a + b
diff = a - b
product = a * b
division = a / b
remainder = a % b
floor_division = a // b
exponential = a ** b

# I should have used sum instead of total but sum is a built-in function try to avoid overriding builtin functions
print(total) # if you don't label your print with some string, you never know from where is the result is coming
print('a + b = ', total)
print('a - b = ', diff)
print('a * b = ', product)
print('a / b = ', division)
print('a % b = ', remainder)
print('a // b = ', floor_division)
print('a ** b = ', exponential)

# Declaring values and organizing them together
num_one = 3
num_two = 4

# Arithmetic operations
total = num_one + num_two
diff = num_two - num_one
product = num_one * num_two
div = num_two / num_two
remainder = num_two % num_one

# Printing values with label
print('total: ', total)
print('difference: ', diff)
print('product: ', product)
print('division: ', div)
print('remainder: ', remainder)


# Calculating area of a circle
radius = 10 # radius of a circle
area_of_circle = 3.14 * radius ** 2 # two * sign means exponent or power
print('Area of a circle:', area_of_circle)

# Calculating area of a rectangle
length = 10
width = 20
area_of_rectangle = length * width
print('Area of rectangle:', area_of_rectangle)

# Calculating a weight of an object
mass = 75
gravity = 9.81
weight = mass * gravity
print(weight, 'N')

print(3 > 2) # True, because 3 is greater than 2
print(3 >= 2) # True, because 3 is greater than 2
print(3 < 2) # False, because 3 is greater than 2
print(2 < 3) # True, because 2 is less than 3
print(2 <= 3) # True, because 2 is less than 3
print(3 == 2) # False, because 3 is not equal to 2
print(3 != 2) # True, because 3 is not equal to 2
print(len('mango') == len('avocado')) # False
print(len('mango') != len('avocado')) # True
print(len('mango') < len('avocado')) # True
print(len('milk') != len('meat')) # False
print(len('milk') == len('meat')) # True
print(len('tomato') == len('potato')) # True
print(len('python') > len('dragon')) # False

# Boolean comparison
print('True == True: ', True == True)
print('True == False: ', True == False)
print('False == False:', False == False)
print('True and True: ', True and True)
print('True or False:', True or False)

# Another way comparison
print('1 is 1', 1 is 1) # True - because the data values are the same
print('1 is not 2', 1 is not 2) # True - because 1 is not 2
print('A in Asabeneh', 'A' in 'Asabeneh') # True - A found in the string
print('B in Asabeneh', 'B' in 'Asabeneh') # False -there is no uppercase B
print('coding' in 'coding for all') # True - because coding for all has the word coding
print('a in an:', 'a' in 'an') # True
print('4 is 2 ** 2:', 4 is 2 ** 2) # True

print(3 > 2 and 4 > 3) # True - because both statements are true
print(3 > 2 and 4 < 3) # False - because the second statement is false
print(3 < 2 and 4 < 3) # False - because both statements are false
print(3 > 2 or 4 > 3) # True - because both statements are true
print(3 > 2 or 4 < 3) # True - because one of the statement is true
print(3 < 2 or 4 < 3) # False - because both statements are false
print(not 3 > 2) # False - because 3 > 2 is true, then not True gives False
print(not True) # False - Negation, the not operator turns true to false
print(not False) # True
print(not not True) # True
print(not not False) # False
# Basic arithmetic operations
print('Addition:', 5 + 3) # Outputs: Addition: 8
print('Subtraction:', 10 - 7) # Outputs: Subtraction: 3
print('Multiplication:', 4 * 6) # Outputs: Multiplication: 24

# Division
print('Division:', 15 / 4) # Outputs: Division: 3.75

# Integer Division
print('Integer Division:', 15 // 4) # Outputs: Integer Division: 3

# Modulus (Remainder)
print('Modulus:', 15 % 4) # Outputs: Modulus: 3

# Exponentiation
print('Exponential:', 2 ** 5) # Outputs: Exponential: 32
# Floating point arithmetic
print('Floating Point Division:', 17.5 / 2.5) # Outputs: Floating Point Division: 7.0

# Mixed operations
result = 2.5 * 3 + 7 / 2 - 1
print('Mixed Operations:', result) # Outputs: Mixed Operations: 9.5
# Variable assignments and reassignments
x = 5
y = 3
z = x + y
print('Value of z:', z) # Outputs: Value of z: 8

# Increment and decrement
counter = 0
counter += 1 # Increment
print('Counter:', counter) # Outputs: Counter: 1

counter -= 1 # Decrement
print('Counter:', counter) # Outputs: Counter: 0
# Calculating area of a triangle
base = 6
height = 4
area_of_triangle = 0.5 * base * height
print('Area of triangle:', area_of_triangle) # Outputs: Area of triangle: 12.0

# Calculating volume of a cube
side_length = 10
volume_of_cube = side_length ** 3
print('Volume of cube:', volume_of_cube) # Outputs: Volume of cube: 1000
# Boolean expressions
print('True and False:', True and False) # Outputs: True and False: False
print('True or False:', True or False) # Outputs: True or False: True
print('Not True:', not True) # Outputs: Not True: False

# Comparison operators
print('Greater than:', 5 > 3) # Outputs: Greater than: True
print('Less than or equal to:', 7 <= 7) # Outputs: Less than or equal to: True
print('Not equal to:', 10 != 12) # Outputs: Not equal to: True
# Membership operators
print('Substring in string:', 'python' in 'python programming') # Outputs: Substring in string: True
print('Character not in string:', 'a' not in 'hello') # Outputs: Character not in string: True

# Identity operators
a = 5
b = a
print('Identity:', a is b) # Outputs: Identity: True

c = 10
print('Identity:', a is not c) # Outputs: Identity: True
71 changes: 70 additions & 1 deletion 05_Day_Lists/day_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,73 @@
ages.sort()
print(ages)
ages.sort(reverse=True)
print(ages)
print(ages)


Certainly! Here are a few more examples of list operations in Python:

### Sorting Lists
Sorting a list can be done using the `sort()` method:

```python
fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.sort()
print(fruits) # ['banana', 'lemon', 'mango', 'orange']

fruits.sort(reverse=True)
print(fruits) # ['orange', 'mango', 'lemon', 'banana']

ages = [22, 19, 24, 25, 26, 24, 25, 24]
ages.sort()
print(ages) # [19, 22, 24, 24, 24, 25, 25, 26]

ages.sort(reverse=True)
print(ages) # [26, 25, 25, 24, 24, 24, 22, 19]
```

### Checking List Membership
You can check if an item exists in a list using the `in` keyword:

```python
fruits = ['banana', 'orange', 'mango', 'lemon']
print('banana' in fruits) # True
print('apple' in fruits) # False
```

### Reversing a List
To reverse the order of elements in a list, use the `reverse()` method:

```python
fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.reverse()
print(fruits) # ['lemon', 'mango', 'orange', 'banana']

ages = [22, 19, 24, 25, 26, 24, 25, 24]
ages.reverse()
print(ages) # [24, 25, 24, 26, 25, 24, 19, 22]
```

### Additional List Methods
#### Counting Occurrences:
The `count()` method counts occurrences of an element in a list:

```python
fruits = ['banana', 'orange', 'mango', 'lemon']
print(fruits.count('orange')) # 1

ages = [22, 19, 24, 25, 26, 24, 25, 24]
print(ages.count(24)) # 3
```

#### Finding Index:
The `index()` method returns the index of the first occurrence of an element:

```python
fruits = ['banana', 'orange', 'mango', 'lemon']
print(fruits.index('orange')) # 1

ages = [22, 19, 24, 25, 26, 24, 25, 24]
print(ages.index(24)) # 2
```

These examples should help you further understand how to manipulate and work with lists in Python effectively!
88 changes: 88 additions & 0 deletions Python Libraries and Modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Python libraries and modules are essential tools that extend the language's functionality beyond its built-in capabilities. Here's an in-depth look at some key Python libraries and modules across various domains:

1. Data Manipulation and Analysis
Pandas
Description: Pandas is a powerful library for data manipulation and analysis. It provides data structures like DataFrame and tools for reading, writing, and analyzing data.
Key Features:
Data manipulation: Filtering, merging, reshaping, and aggregating data.
Data analysis: Descriptive statistics, time series analysis, and handling missing data.
Integration with other libraries like Matplotlib for visualization.
Resources:
Official documentation: Pandas Documentation
Tutorials and examples: Pandas Tutorials
NumPy
Description: NumPy is fundamental for scientific computing in Python, providing support for large, multi-dimensional arrays and matrices.
Key Features:
Efficient operations on arrays: Mathematical, logical, shape manipulation, sorting, and selecting.
Linear algebra, Fourier transforms, and random number generation.
Integration with C/C++ and Fortran code.
Resources:
Official documentation: NumPy Documentation
Tutorials and examples: NumPy Tutorials
2. Data Visualization
Matplotlib
Description: Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.
Key Features:
Plot types: Line plots, scatter plots, bar plots, histograms, 3D plots, etc.
Fine-grained control over plot elements and styles.
Integration with Jupyter notebooks for interactive plotting.
Resources:
Official documentation: Matplotlib Documentation
Tutorials and examples: Matplotlib Tutorials
Seaborn
Description: Seaborn is built on top of Matplotlib and provides a higher-level interface for statistical data visualization.
Key Features:
Statistical plots: Violin plots, box plots, pair plots, heatmap, etc.
Integration with Pandas DataFrames for easy plotting.
Default themes and color palettes for aesthetic visualizations.
Resources:
Official documentation: Seaborn Documentation
Tutorials and examples: Seaborn Tutorials
3. Web Development
Flask
Description: Flask is a lightweight and flexible web framework for Python, designed with simplicity and minimalism in mind.
Key Features:
Built-in development server and debugger.
URL routing and request handling using decorators.
Jinja2 templating engine for HTML rendering.
Resources:
Official documentation: Flask Documentation
Tutorials and examples: Flask Tutorials
Django
Description: Django is a high-level web framework that encourages rapid development and clean, pragmatic design.
Key Features:
Admin interface for content management.
ORM (Object-Relational Mapping) for database interaction.
Built-in security features and middleware support.
Resources:
Official documentation: Django Documentation
Tutorials and examples: Django Tutorials
4. Machine Learning and Data Science
Scikit-learn
Description: Scikit-learn is a machine learning library that provides simple and efficient tools for data mining and analysis.
Key Features:
Various algorithms for classification, regression, clustering, and dimensionality reduction.
Model selection and evaluation tools.
Integration with NumPy and Pandas for data manipulation.
Resources:
Official documentation: Scikit-learn Documentation
Tutorials and examples: Scikit-learn Tutorials
5. Concurrency and Asynchronous Programming
asyncio
Description: asyncio is Python's standard library for writing concurrent code using coroutines, allowing for asynchronous I/O operations.
Key Features:
async and await keywords for defining asynchronous functions and tasks.
Event loop for managing tasks and executing coroutines concurrently.
Resources:
Official documentation: asyncio Documentation
Tutorials and examples: asyncio Tutorials
6. Testing and Quality Assurance
pytest
Description: pytest is a popular testing framework for Python that allows for simple unit tests as well as complex functional testing scenarios.
Key Features:
Simple test discovery and execution.
Fixture support for setup and teardown of test environments.
Integration with other testing tools and plugins.
Resources:
Official documentation: pytest Documentation
Tutorials and examples: pytest Tutorials