tag:blogger.com,1999:blog-68300544866789241412025-09-07T17:30:51.064+05:30HG BLOGSPassionate Blogger, Sharing insights, tips, and stories.HGhttp://www.blogger.com/profile/06113594604059490795[email protected]Blogger11125tag:blogger.com,1999:blog-6830054486678924141.post-43162995257300550832025-01-10T12:00:00.001+05:302025-01-10T12:00:00.118+05:30Tkinter and Api <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="weather.css">
<style>
body{
margin: 0px;
}
.text{
font-size: 18px;
}
@media screen and (max-width: 426px) {
.tkinter_code {
font-size: 9px;
}
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
/*Weather Css */
.tk_api_container h2{
margin: 0px;
}
pre {
background-color: #f2f2f2;
padding: 10px;
border-radius: 5px;
color: blue;
}
</style>
</head>
<body>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<section>
<div class="tk_api_container">
<h1>Tkinter and Api </h1>
<p>In this blog, we'll walk through the basics of Tkinter, how to interact with APIs. Whether you're a beginner or looking to brush up on your programming skills, this guide will set you on the right path to mastering Python and Tkinter.</p>
<h2>Tkinter</h2>
<p>Tkinter is like a special set of tools that helps you build that program. It gives you the building blocks – like buttons, boxes, and labels – and lets you put them together to create a program that looks nice and is easy to use.</p>
<h2>Widgets of Tkinter</h2>
<h3>Label</h3>
<p>This is used to display text or images. For instance, you can use Label to show the current temperature, weather conditions, or the name of the city.</p>
<pre>
<code class="tkinter_code">
from tkinter import Label
label = Label(root, text="Temperature: 25°C")
label.pack()
</code>
</pre>
<h3>Entry</h3>
<p>This widget allows users to enter a single line of text. You can use it to let users input a city name or ZIP code to get weather information.</p>
<pre>
<code class="tkinter_code">
from tkinter import Entry
entry = Entry(root)
entry.pack()
</code>
</pre>
<h3>Button</h3>
<p>Buttons can be used to trigger actions when clicked, like fetching weather data.</p>
<pre>
<code class="tkinter_code">
from tkinter import Button
button = Button(root, text="Get Weather", command=fetch_weather)
button.pack()
</code>
</pre>
<h3>Text</h3>
<p>This widget is useful for displaying multiple lines of text, such as weather details for different days or additional weather information.</p>
<pre>
<code class="tkinter_code">
from tkinter import Text
text = Text(root)
text.pack()
</code>
</pre>
<h2>Api(Application Programming Interface)</h2>
<p>An API (Application Programming Interface) is like a bridge that allows different software systems to communicate with each other.</p>
<ul>
<li>Interaction: APIs define how software components should interact. For example, a weather app might use an API to get weather data from a weather service.
</li>
<li>Requests and Responses: APIs operate through requests and responses, much like a conversation. Your app sends a request to an API, and the API sends back the response with the required data.</li>
<li>Formats: Most APIs use common data formats like JSON or XML, making it easier for different systems to understand the data shared.</li>
</ul>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-16174474990091542482025-01-03T12:00:00.001+05:302025-01-03T12:00:00.118+05:30Recursion In Python <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
margin: 0px;
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
.for-while-container{
background-image: url(img2.png);
margin: 20px;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
}
/*codes css*/
pre {
background-color: #f2f2f2;
padding: 10px;
border-radius: 5px;
color: blue;
}
</style>
</head>
<body>
<section>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<!--RECURSION-->
<div class="rec-container">
<h2>Recursion</h2>
<p>Recursion involves a function calling itself directly or indirectly to solve a problem by breaking it down into simpler and more manageable parts.
</p>
<h2>Python Recursive Function
</h2>
<p>In Python, a recursive function is defined like any other function, but it includes a call to itself.
</p>
<pre>
<code>
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n-1)
print(factorial(5))
</code>
</pre>
<h2>Basic Structure of Recursive Fucntion</h2>
<pre>
<code>
def recursive_function(parameters):
if base_case_condition:
return base_result
else:
return recursive_function(modified_parameters)
</code>
</pre>
<h2>Advantages:</h2>
<ul>
<li>Easier to Understand: For some problems, like navigating through a tree-like structure, recursive solutions can be much easier to grasp and write compared to using loops.
</li>
<li>Shorter Code: Often, you can express complex logic more concisely with recursion, leading to shorter and potentially more readable code.
</li>
</ul>
<h2>Disadvantages:
</h2>
<ul>
<li>Uses More Memory: Each time a function calls itself, it uses a bit of memory to keep track of where it was before. This can add up quickly, especially for deeply nested recursive calls.
</li>
<li>Can be Slower: The overhead of making function calls can sometimes make recursive solutions run slower than equivalent solutions using loops.
</li>
</ul>
<!--RECURSION CODES EXAMPLE-->
<h2>Examples</h2>
<p>Fibonnaci Series Using Recursion</p>
<pre>
<code>
def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n-1) + fibonacci(n-2)
result = fibonacci(6)
print(f"6th Fibonacci number is: {result}")
</code>
</pre>
<p>Factorial Using Recursion</p>
<pre>
<code>
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
result = factorial(5)
print(f"Factorial of 5 is: {result}")
</code>
</pre>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-68930876558833049032024-12-27T12:00:00.001+05:302024-12-27T12:00:00.230+05:30Functions in Python <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
body{
margin: 0px;
}
.text{
font-size: 18px;
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
.function-container{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfiVcG-YFenmMmGljXtVgzlAdH0t41jx0fUlV3y1jF8vvalhDpziUtAYy7drupQWLnwAsCT5afDFUPzYOZaqok0KrFFsW-PqVzCRHI-JqUZaYJPpzbVpnJzLP2mx9ubrVtCy0nZNwuhHpI1D5JDkxwiZmDtkzSsARKWN4iUYdCC8NIAp0qWlylR1d25uxr/s736/img2.png");
}
/*codes css*/
pre {
background-color: #f2f2f2;
padding: 10px;
border-radius: 5px;
color: blue;
}
</style>
<body>
<section>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<div class="function-container">
<h2>Functions</h2>
<p>The functions in python can be defined as the reusable block of codes that perform a certain task.
Before we start defining functions ourselves, we’ll look at some of Python’s built-in functions. Let’s start with the most well-known built-in function, called print:
</p>
<pre>
<code>
>>> print('Hello, readers!')
Hello, readers!
>>> print(15)
15
</code>
</pre>
<h2>Creating python functions</h2>
<p>In programming language there are certain syntax we need to follow and python is not an exception
</p>
<pre>
<code>
def function_name:
#statements
return
</code>
</pre>
<h2>Advantages of using functions
</h2>
<h3>Advantages of using functions
</h3>
<p>A Python function can be defined once and used many times. So it aids in code reuse: you don’t want to write the same code more than once.
Functions are a great way to keep your code short, concise, and readable. By giving a function a well-chosen name, your code will become even more readable because the function name directly explains what will happen. This way, others (or future you) can read your code, and without looking at all of it, understand what it’s doing anyway because of the well-chosen function names.
</p>
<h3>Return values
</h3>
<p>A function can return a value. This value is often the result of some calculation or operation. In fact, a Python function can even return multiple values.
We can make this more interesting by allowing an argument to be passed to our function. Again we define a function with def, but we add a variable name between the parentheses:
</p>
<pre>
<code>
>>> def say_hi(name):
print('Hi', name)
>>> say_hi('chiku')
Hi chiku
</code>
</pre>
<p>Our function now accepts a value, which gets assigned to the variable name. We call such variables the parameter, while the actual value we provide (‘Chiku’) is called the argument.
</p>
<h2>Variable scope</h2>
<p>The variable name only exists inside our function. We say that the variable’s scope name is limited to the function say_hi, meaning it doesn’t exist outside of it.
</p>
<h3>Scope
</h3>
<p>The visibility of a variable is called scope. The scope defines which parts of your program can see and use a variable.<br>
If we define a variable at the so-called top level of a program, it is visible in all places.
</p>
<pre>
<code>
>>> def say_hi():
... print("Hi", name)
... answer = "Hi"
...
>>> name = 'Chiku'
>>> say_hi()
Hi Chiku
>>> print(answer)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
</code>
</pre>
<p>NameError: name 'answer' is not defined
say_hi was able to use the variable name, as expected, because it’s a top-level variable: it is visible everywhere. However, answer, defined inside say_hi, is not known outside of the function and causes a NameError. Python gives us an informative and detailed error: “name ‘answer’ is not defined.”
</p>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-55750363502265947442024-12-20T12:00:00.000+05:302024-12-20T12:00:00.119+05:30Sets in python<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
margin: 0px;
}
section{
display: grid;
grid-template-columns: 1fr 1fr;
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
/*set-container css*/
.set-container{
grid-column: 1/span 2;
padding: 5px;
}
/*codes css*/
pre {
background-color: #f2f2f2;
padding: 10px;
border-radius: 5px;
color: blue;
}
/*heading margins css*/
h2,h3{
margin-bottom: 0px;
}
p{
margin-bottom: 0px;
margin-top: 2px;
}
h1{
margin-bottom: 0px;
}
</style>
</head>
<body>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<section>
<div class="set-container">
<h2>SETS</h2>
<p>Sets are an ideal choice for representing a group of unique values as a single entity. They offer several key characteristics: they do not allow duplicate elements, they do not preserve the order of insertion, and they do not support indexing or slicing. While the order of elements may not be guaranteed, sets can be sorted for specific purposes. This makes sets useful for tasks like removing duplicates from a list or performing set operations like union, intersection, and difference.
</p>
<pre>
<code>
s={10,20,30,40}
print(s)
Ouput:{10,20,30,40}
</code>
</pre>
<h2>Important set functions</h2>
<h3>add(x):</h3>
<p>When we want to add individual element to the set we use add()
</p>
<pre>
<code>
ex:
s={10,20,30}
s.add(40);
print(s) #{40, 10, 20, 30}
</code>
</pre>
<h3>update(x,y,z):</h3>
<p>when we want to add multiple elements to the set we use update()
</p>
<pre>
<code>
ex:
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
x.update(y)
print(x)
Output:
{'google', 'microsoft', 'apple',
'banana', 'cherry'}
</code>
</pre>
<h3>Copy()</h3>
<p>This set function is used when we want to copy the set
</p>
<pre>
<code>
ex:
s={10,20,30}
s1=s.copy()
print(s1)
</code>
</pre>
<h3>pop()</h3>
<p>It removes and returns some random element from the set.
</p>
<pre>
<code>
ex:
fruits = {"apple", "banana", "cherry"}
fruits.pop()
print(fruits)
output:
{'apple', 'cherry'}
</code>
</pre>
<h3>remove()</h3>
<p>The remove set function is used to remove the specified element from the set . If in case the element is not present in the set it returns keyerror.
</p>
<pre>
<code>
ex:
s={40,10,30,20}
s.remove(30)
output:
{40,10,20}
</code>
</pre>
<h2>Mathematical operation in set</h2>
<h3>union():</h3>
<p>We can use this function to return all the elements present in the set
</p>
<pre>
<code>
ex:
x={10,20,30,40}
y={30,40,50,60}
print(x.union(y))
#{10, 20, 30, 40, 50, 60}
print(x|y) #{10, 20, 30, 40, 50, 60}
</code>
</pre>
<h3>Intersection()
</h3>
<p>The intersection() is used to return the common element present in the sets.
</p>
<pre>
<code>
ex:
x={10,20,30,40}
y={30,40,50,60}
print(x.intersection(y)) #{40, 30}
print(x&y) #{40, 30}
</code>
</pre>
<h3>Difference():</h3>
<p>The difference() is used to return the elements presents in x and not in y </p>
<pre>
<code>
x={10,20,30,40}
y={30,40,50,60}
print(x.difference(y)) #{10, 20}
print(x-y) #{10, 20}
print(y-x) #{50, 60}
</code>
</pre>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-20210598254448568142024-12-13T12:00:00.003+05:302024-12-13T12:00:00.130+05:30List and Tuple in Python<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
margin: 0px;
}
section{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfiVcG-YFenmMmGljXtVgzlAdH0t41jx0fUlV3y1jF8vvalhDpziUtAYy7drupQWLnwAsCT5afDFUPzYOZaqok0KrFFsW-PqVzCRHI-JqUZaYJPpzbVpnJzLP2mx9ubrVtCy0nZNwuhHpI1D5JDkxwiZmDtkzSsARKWN4iUYdCC8NIAp0qWlylR1d25uxr/s736/img2.png");
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
/*LIST-TUPLE-CSS*/
.list-tup-container{
grid-column: 1 / span 2;
padding:5px;
}
h2,h3{
margin-bottom: 0px;
}
p{
margin-bottom: 0px;
margin-top: 2px;
}
h1{
margin-bottom: 0px;
}
/*list-tuple-table-css*/
.lst-tup-table {
/*border: 1px solid black; */
border-collapse: collapse;
margin: 20px;
padding:5px;
}
.lst-tup-table th, .lst-tup-table td {
border: 1px solid black;
padding: 10px;
text-align: center;
}
.lst-tup-table th {
background-color: #f2f2f2;
}
.lst-tup-table{
grid-column: 1 /span 2;
}
/*Css for codes in the blog*/
pre {
background-color: #f2f2f2;
padding: 10px;
border-radius: 5px;
color: blue;
}
</style>
</head>
<body>
<section>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<!--LIST-TUPLE-HTML-->
<div class="list-tup-container">
<h2>List</h2>
<p>A list is a data type in Python used to store a collection of items. Lists are mutable, which means we can modify their contents after they are created.The data in the list is stored in the square brackets.
</p>
<pre>
<code>
lst = [1,2,3,4,5]
</code>
</pre>
<h2>Accessing the elements of the list</h2>
<p>The elemnts of the list can be accessed by two methods</p>
<ul class="lst-part">
<li>By Indexing</li>
<li>By Slice Operator</li>
</ul>
<h3>Indexing</h3>
<pre>
<code>
lst = [1,2,3,4]
print(lst.[0])
output:1
</code>
</pre>
<h3>Slice operator</h3>
<pre>
<code>
list = list1[start:stop:step]
</code>
</pre>
<p>
start ==>it indicates the index where slice has to startdefault value is 0 <br>
stop ===>It indicates the index where slice has to end default value is max allowed index of list ie length of the list <br>
step ==>increment value default value is 1
</p>
<pre>
<code>
n=[1,2,3,4,5,6,7,8,9,10]
print(n[2:7:2])
print(n[4::2])
print(n[3:7])
print(n[8:2:-2])
print(n[4:100])
</code>
</pre>
<h2>Tuple</h2>
<p>Tuples are used to store multiple items in a single variable. A tuple is an immutable collection of data, meaning its elements cannot be changed once it's created. Tuples are written within parentheses.The tuple can also be defined as the read only version of the list as once the tuple is created we cannot make any changes in it.
</p>
<pre>
<code>
tup =(1,2,3,4,5)
</code>
</pre>
<h2>Tuple creation</h2>
<ul class="tup-part">
<li> t=()
creation of empty tuple</li>
<li> t=(10,)
t=10,
creation of single valued tuple ,parenthesis are optional,should ends with comma</li>
<li>t=10,20,30
t=(10,20,30)
creation of multi values tuples & parenthesis are optional</li>
</ul>
<h2>Accessing the elements of the Tuple</h2>
<ul class="lst-part">
<li>By Indexing</li>
<li>By Slice Operator</li>
</ul>
<h3>Indexing</h3>
<pre>
<code>
t=(10,20,30,40,50,60)
print(t[0]) #10
print(t[-1]) #60
print(t[100]) IndexError: tuple index out of range
</code>
</pre>
<h3>Slice Operator</h3>
<pre>
<code>
t=(10,20,30,40,50,60)
print(t[2:5])
print(t[2:100])
print(t[::2])
Output
(30, 40, 50)
(30, 40, 50, 60)
(10, 30, 50)
</code>
</pre>
</div>
<div class="lst-tup-table">
<h2>Difference b/w List and tuple</h2>
<table>
<thead>
<tr>
<th>List</th>
<th>Tuple</th>
</tr>
</thead>
<tbody>
<tr>
<td>List is a Group of Comma separated
Values within Square Brackets and Square
Brackets are mandatory.</td>
<td>Tuple is a Group of Comma separated
Values within Parenthesis and Parenthesis
are optional.</td>
</tr>
<tr>
<td>List Objects are Mutable i.e. once we
creates List Object we can perform any
changes in that Object.</td>
<td>Tuple Objeccts are Immutable i.e. once
we creates Tuple Object we cannot change
its content.</td>
</tr>
<tr>
<td>If the Content is not fixed and keep on
changing then we should go for List.</td>
<td>If the content is fixed and never changes
then we should go for Tuple.</td>
</tr>
<tr>
<td>List Objects can not used as Keys for
Dictionries because Keys should be
Hashable and Immutable</td>
<td>Tuple Objects can be used as Keys for
Dictionries because Keys should be
Hashable and Immutable.</td>
</tr>
</tbody>
</table>
<style>
.libutton {
display: flex;
flex-direction: column;
justify-content: center;
padding: 7px;
text-align: center;
outline: none;
text-decoration: none !important;
color: #ffffff !important;
width: 200px;
height: 32px;
border-radius: 16px;
background-color: #0A66C2;
font-family: "SF Pro Text", Helvetica, sans-serif;
}
</style>
<a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=harshit-gourlariya-a92b65299" target="_blank">Follow on LinkedIn</a>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-294015735364239662024-12-06T00:00:00.002+05:302024-12-06T00:00:00.113+05:30Strings and String Operations In Python <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
margin: 0px;
}
section{
display: grid;
grid-template-columns: 1fr ;
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxNxHB79IHE3wU5K-F_zsOTs8QWqYEDL5ewvRB9V6KRNnb9Q_9Q8zVF219X57DgNe83_vysokvpD2HWyGkQ_paLVCoYePfXlqv0T7pRAKbyJ0ceaokUHUsy6r2nGWp2oTeXkUMV2dcTl_EjXC7SYxM8kZuMaiBHpreLCH6CyhgFtRiEjEqCnyPORG2a4pM/s736/output-onlinepngtools.png");
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
padding: 5px;
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
/*Css for codes in string*/
pre {
background-color: #f2f2f2;
padding: 10px;
border-radius: 5px;
color: blue;
}
/*Css for str-container*/
h2,h3{
margin-bottom: 0px;
}
p{
margin-bottom: 0px;
margin-top: 2px;
font-weight: bold;
}
h1{
margin-bottom: 0px;
}
</style>
</head>
<body>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<section>
<div class="str-container">
<h2>Strings</h2>
<p>The string is defined as any set of characters within either single quote or the double quotes.
</p>
<pre>
<code>
ex:
s='Notes'
s="Notes"
</code>
</pre>
<h2>HOW TO ACESS CHARCTERS OF THE STRING</h2>
<p>There are two ways to access the characters in the string </p>
<ul class="str-part">
<li>By Indexing</li>
<li>By Slice Operator</li>
</ul>
<h2>Indexing</h2>
<pre>
<code>
s = "Notes"
print(s[0])
Output:N
print(s[1])
Output:o
print(s[2])
Output:t
print(s[3])
Output:e
print(s[4])
Output:s
</code>
</pre>
<h2>Slice Operators</h2>
<p>
Syntax:
s[begin:end:step]
</p>
<p>Begin: From where the we have to consider the slicing of the string <br>
End: From where the slicing of the string will end at index -1<br>
Step: It is the incremented value</p>
</div>
<pre>
<code>
ex: s='Notes'
print(s[0:2:1])
Output: No
print(s[1:2])
Output: o
</code>
</pre>
<h1>Mathematical Operators in String </h1>
<p>We can use Two types of mathematical Operators in String</p>
<ul class="str-part">
<li> '+' For concatenate</li>
<li>'*' For multiplication</li>
</ul>
<p>Note : Both the arguments should be in string to concanecate and to multiply</p>
<h2>len() Built in Function</h2>
<p>We can use the len() function to find the number of characters present in the string</p>
<pre>
<code>
ex:
s= "Notes"
print(len(s))
Output: 5
</code>
</pre>
<h2>Finding Substring</h2>
<p>We can use four methods to find the string</p>
<ul class="str-part">
<li> For forward Direction -> index() ,find()</li>
<li>For backward Direction -> rindex() ,rfind()</li>
</ul>
<h3>find()</h3>
<pre>
<code>
ex:
s="notes"
print(s.find("e"))
Ourput:3
</code>
</pre>
<h3>Index()</h3>
<p>The index method is same as find() the only difference is that it returns Value error if the required character o string is not
</p>
<h2>Replacing the String with another String</h2>
<pre>
<code>
ex:
s1= "notes"
s2 = print(s1.replace('notes','hello'))
</code>
</pre>
<h2>Splitting of the Strings</h2>
<p>We can also split the strings by using split()
</p>
<pre>
<code>
ex: s = 'python is a very good language'
s1 = s.split()
print(s1)
</code>
</pre>
<h2>Joining of the Strings</h2>
<pre>
<code>
ex:
s= ('My' ,'notes', 'are', 'very', 'good')
s1 = '-'.join(s)
print(s1)
</code>
</pre>
<h2>Changing the case of the Strings</h2>
<p>1. upper()===>To convert all characters to upper case <br>
2. lower() ===>To convert all characters to lower case <br>
3. swapcase()===>converts all lower case characters to upper case and all upper case characters to lower case <br>
4. title() ===>To convert all character to title case. i.e first character in every word should be upper case and all remaining characters should be in lower case. <br>
5. capitalize() ==>Only first character will be converted to upper case and all remaining characters
can be converted to lower case
</p>
<style>
.libutton {
display: flex;
flex-direction: column;
justify-content: center;
padding: 7px;
text-align: center;
outline: none;
text-decoration: none !important;
color: #ffffff !important;
width: 200px;
height: 32px;
border-radius: 16px;
background-color: #0A66C2;
font-family: "SF Pro Text", Helvetica, sans-serif;
}
</style>
<a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=harshit-gourlariya-a92b65299" target="_blank">Follow on LinkedIn</a>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-84535540879823012692024-11-29T12:00:00.002+05:302024-12-04T11:33:13.599+05:30For Loop and While Loop in Python <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
body{
margin: 0px;
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
.for-while-container{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfiVcG-YFenmMmGljXtVgzlAdH0t41jx0fUlV3y1jF8vvalhDpziUtAYy7drupQWLnwAsCT5afDFUPzYOZaqok0KrFFsW-PqVzCRHI-JqUZaYJPpzbVpnJzLP2mx9ubrVtCy0nZNwuhHpI1D5JDkxwiZmDtkzSsARKWN4iUYdCC8NIAp0qWlylR1d25uxr/s736/img2.png");
margin: 20px;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
}
/*For loop and while loop Css*/
.for-tab {
display: grid;
grid-template-columns: 1fr;
/* border: 1px solid black;*/
padding: 20px;
}
pre {
background-color: #f2f2f2;
padding: 10px;
border-radius: 5px;
color: blue;
}
.for-tab h1{
margin: 0px;
}
.for-tab p{
margin-bottom: 0px;
}
</style>
<body><section>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<div class="for-while-container">
<!--FOR AND WHILE LOOP-->
<div class="for-tab">
<h1>For Loop</h1>
<p>
A for loop is a control flow statement that allows you to execute a block of code repeatedly for a specified number of times. It's particularly useful when you know in advance how many times you want the loop to iterate.
</p>
<h2>Example:</h2>
<pre><code>
for i in range(6):
print(i)
</code></pre>
</div>
<div class="for-tab">
<h1>While Loop</h1>
<p>
A while loop is another control flow statement that executes a block of code repeatedly as long as a certain condition is true. It's useful when you don't know the exact number of iterations in advance.
</p>
<h2>Example:</h2>
<pre><code>
i=0
while i<11:
print(9*i)
i+=1
</code></pre>
</div>
<style>
.libutton {
display: flex;
flex-direction: column;
justify-content: center;
padding: 7px;
text-align: center;
outline: none;
text-decoration: none !important;
color: #ffffff !important;
width: 200px;
height: 32px;
border-radius: 16px;
background-color: #0A66C2;
font-family: "SF Pro Text", Helvetica, sans-serif;
}
</style>
<a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=harshit-gourlariya-a92b65299" target="_blank">Follow on LinkedIn</a>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-77963633921395643022024-11-22T12:00:00.002+05:302024-12-04T11:32:45.961+05:30Conditional Statements In Python <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
margin:0px;
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
section{
margin: 20px;
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfiVcG-YFenmMmGljXtVgzlAdH0t41jx0fUlV3y1jF8vvalhDpziUtAYy7drupQWLnwAsCT5afDFUPzYOZaqok0KrFFsW-PqVzCRHI-JqUZaYJPpzbVpnJzLP2mx9ubrVtCy0nZNwuhHpI1D5JDkxwiZmDtkzSsARKWN4iUYdCC8NIAp0qWlylR1d25uxr/s736/img2.png");
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
}
/*CONDITIONAL STATEMENT CSS*/
.conditional-container{
padding: 20px;
}
.conditional-type {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px; /* Adjust the gap as needed */
background-color: rgb(41, 40, 40);
color: white;
border-radius: 10px;
margin: 30px;
}
.conditional-column{
border: 1px solid white;
height: 14%;
padding-top: 5px;
text-align: center;
margin-top: 100px;
margin-bottom: 30px;
margin-left: 50px;
border-radius: 10px;
}
.conditional-column-2 {
display: grid;
grid-template-rows: 1fr 1fr;
gap: 10px; /* Adjust the gap as needed */
border-radius: 10px;
margin: 5px;
}
.condition-box {
border: 1px solid white;
border-radius: 10px;
margin: 5px;
padding: 10px;}
.heading-statement{
margin-bottom: 0px;
}
/* CODES OF CONDITIONAL STATEMENTS CSS*/
pre {
background-color: #f2f2f2;
border: 1px solid #ccc;
padding: 10px;
font-family: monospace;
font-size: 14px;
margin: 30px;
}
code{
color: #007bff;
}
@media screen and (max-width:426px){
code{
font-size: 9px;
}
.conditional-type{
font-size: 9px;
}
.conditional-column{
margin-top:20vh;
}
.heading-statement{
font-size:18px;
}
}
/* IMAGE OF FLOWCHARTS*/
.img-statements{
/* margin-left: 25vh;*/
}
</style>
</head>
<body>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<section>
<!---Conditional Statements-->
<div class="conditional-container">
<h2>Conditional Statements</h2>
<div class="condition">
<p>One of the most Crucial thing in programming is decision making It is required to give direction to the code.
</p>
<p> These are some operators which are used with conditional Statements.</p>
<h3>Equals (==)-></h3>
<p> We use it to check if a variable is equal to another variable. For example, m == n.
</p>
<h3>Not Equals (!=)-></h3>
<p> To check if a variable is not equal to another variable. For example, m != n.</p>
<h3>Greater Than (>)->
</h3>
<p> To check if a variable is greater than another variable. For example, m > n.
</p>
<h3>Less Than (<) ->
</h3>
<p> To check if a variable is less than another variable. For example, m < n.
</p>
<h3>Greater Than or Equal to->
</h3>
<p> To assess if a variable is greater than or equal to another variable. For example, m >= n.
</p>
<h3>Less Than or Equal to->
</h3>
<p>To evaluate if a variable is less than or equal to another variable. For example, m <= n. </p>
<h1 class="heading-statement"> FOUR TYPES OF CONDITIONAL STATEMENTS</h1>
</div>
<div class="conditional-type">
<div class="conditional-column">
Conditional Statements
</div>
<div class="conditional-column-2">
<div class="condition-box">
If Statement
</div>
<div class="condition-box">
Nested If statement
</div>
<div class="condition-box">
If-else statement
</div>
<div class="condition-box">
If-elif-else Statement
</div>
</div>
</div>
<div class="Statement">
<h1 class="heading-statement"> if Conditional Statement</h1>
<p>The if conditional statement is the simplest conditional statement in python programming In if conditional statement the code will execute if the given condition is true otherwise it will move forward in the program.
</p>
<pre>
<code>
x = 5
if x == 5:
print("True")
Output: True
</code>
</pre>
</div>
<div class="Statement">
<h1 class="heading-statement"> If else conditional statement
</h1>
<p>"In an if-else conditional statement, the code within the if block is executed if the given condition is True. If the condition is False, the code within the else block is executed instead."
</p>
<pre>
<code>
x = 5
if x == 4:
print("True")
else:
print("False")
Output: False
</code>
</pre>
</div>
<div class="Statement">
<h1 class="heading-statement"> Nested if conditional statement
</h1>
<p>"Nested if statements allow you to create complex decision-making structures in Python. By placing one if statement within another, you can execute different code blocks based on multiple conditions. However, excessive nesting can make code less readable and harder to maintain.
</p>
<pre>
<code>
x = 10
y = 20
if x > 5:
if y > 15:
print("Both x and y are greater")
else:
print("x is greater than 5,
but y is not greater than 15")
else:
print("x is not greater than 5")
Output: Both x and y are greater than
their respective values
</code>
</pre>
</div>
<div class="Statement">
<h1 class="heading-statement"> if-elif-else Conditional Statement </h1>
<p>"This conditional statement operates as follows: if the if condition evaluates to True, the code within its block is executed. Otherwise, if an else block is present, its code is executed instead."
</p>
<pre>
<code>
a = 7
b = 9
c = 10
if a >= b and a >= c:
print("a is greatest")
elif b >= a and b >= c:
print("b is greatest")
else:
print("c is greatest")
Output: is greatest
</code>
</pre>
<style>
.libutton {
display: flex;
flex-direction: column;
justify-content: center;
padding: 7px;
text-align: center;
outline: none;
text-decoration: none !important;
color: #ffffff !important;
width: 200px;
height: 32px;
border-radius: 16px;
background-color: #0A66C2;
font-family: "SF Pro Text", Helvetica, sans-serif;
}
</style>
<a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=harshit-gourlariya-a92b65299" target="_blank">Follow on LinkedIn</a>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-49974439633781196272024-11-15T12:00:00.017+05:302024-12-04T11:32:22.258+05:30Typecasting and Operator Precedency <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="Typecast.css">
</head>
<style>
body{
margin: 0px;
}
.text{
font-size: 18px;
}
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
/*TYPECAST CSS*/
section{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfiVcG-YFenmMmGljXtVgzlAdH0t41jx0fUlV3y1jF8vvalhDpziUtAYy7drupQWLnwAsCT5afDFUPzYOZaqok0KrFFsW-PqVzCRHI-JqUZaYJPpzbVpnJzLP2mx9ubrVtCy0nZNwuhHpI1D5JDkxwiZmDtkzSsARKWN4iUYdCC8NIAp0qWlylR1d25uxr/s736/img2.png");
margin: 10px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
font-weight:Bold;
}
.typecast-container {
display: grid;
grid-template-columns: 1fr; /* One column */
gap: 20px; /* Adjust the gap between divs as needed */
padding: 20px;
}
.implicit-container, .explicit-container {
padding: 10px;
}
/*Typecast divided into two parts*/
.typecast-comparison {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px; /* Adjust the gap as needed */
background-color: rgb(41, 40, 40);
color: white;
border-radius: 10px;
}
.Implicit-column{
border: 1px solid white;
padding-top: 20px;
height: 30%;
text-align: center;
margin-top: 30px;
margin-bottom: 30px;
margin: 30px;
font-size:12px;
border-radius: 10px;
}
.Explicit-column {
display: grid;
grid-template-rows: 1fr 1fr;
gap: 10px; /* Adjust the gap as needed */
border-radius: 10px;
margin: 5px;
}
.Typecast-box {
border: 1px solid white;
border-radius: 10px;
margin: 5px;
padding: 10px;}
/*Code EX Css*/
.code-container{
background-color: rgb(41, 40, 40);
color: white;
border-radius: 10px;
}
/* Operator Precedence and Associativity Css*/
.precedency-container{
grid-column: 1 / span 2;
padding-bottom:0px;
padding-right:10px;
padding-left:10px;
width: 96%;
}
.precedency-container-1{
grid-column: 1 / span 2;
padding-top: 0px;
padding-right:10px;
padding-left:10px;
padding-bottom:10px;
width: 96%;
}
/*Operator table css*/
.table-1 {
border-collapse: collapse;
width: 100%;
}
.th-1, .td-1 {
border: 1px solid black;
padding: 8px;
text-align: left;
}
.th-1{
background-color: #f2f2f2;
}
</style>
<body>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<section>
<div class="typecast-container">
<div class="heading">
<h2>Type Casting</h2>
<p class="text">Typecasting is one of the key feature in python. Type casting is a fundamental concept in Python that involves converting one data type to another. <br>There are two primary methods:
</p>
<!--Typecast Divided into Twoparts-->
<div class="typecast-comparison">
<div class="Implicit-column">
Typecasting
</div>
<div class="Explicit-column">
<div class="Typecast-box">
Implicit Typecasting
</div>
<div class="Typecast-box">
Explicit Typecasting
</div>
</div>
</div>
</div>
<p class="text">In this blog we will learn about how to typecast different variables or data.
</p>
</div>
<div class="implicit-container">
<h3>Implicit Type Casting</h3>
<p class="text">Python automatically performs implicit type casting in certain situations to prevent data loss. For instance, when dividing two integers, Python implicitly converts the result to a float to maintain precision.
</p>
<p>For ex - While dividing two integers number the interpreter implicitly converts the variable x into float
</p>
<div class="code-container">
<pre><code>
x = 5
y = 2
div = x / y
print(div) # Output: 2.5
</code></pre>
</div>
<h3>Explaination:</h3>
<p>
Here we have assigned the values to variable x and y <br>
The variable x has the value 5 and the variable y has the value 2 <br>
Now in the next line of code we have defined a variable Div in which we have assign the divison of x/y <br>
Now here the interpreter will implicitly convert the x variable into float data type <br>
In the last line of code we have print the output which is in the float data type <br>
</p>
</div>
<div class="explicit-container">
<h3>Explicit Type Casting</h3>
<p class="text">In explicit type casting, the programmer manually converts a data type using built-in functions like int(), float(), str(), bool(), and tuple(). This is often necessary when working with user input or when precise data type conversions are required.
</p>
<p>For example -> if we use the input in-built function in python by default it gives the value in string data type so a user can do explicit type casting by using any of the functions.
</p>
<div class="code-container">
<pre><code>
a = input("Enter a number: ")
b = int(a)
print(b)
</code></pre>
</div>
<p>In this example, the input() function returns a string. To perform arithmetic operations, we explicitly convert the input string to an integer using the int() function.
</p>
<h3>Explaination:</h3>
<p>In these codes of line two variables are defined which are taking input from the users the variable a and the variable b <br>
here in output we can see that when we print the variable a the output is in string variable <br>
But in next line of code for variable b the user has explicity type cast the input into integer <br>
Hence we can see a integer output.
</p>
</div>
<!--OPERATORS AND ASSOCIATIVITY-->
<div class="precedency-container">
<h1>Operator Precedence and Associativity</h1>
<h2 class="heading-op">Operator Precedence:</h2>
In Python, operator precedence determines the order in which operators are evaluated in an expression containing multiple operators. When the Python interpreter encounters such an expression, it evaluates the operators in a specific, hierarchical order.
<h2 class="heading-op">Operator Associativity:</h2>
While operator precedence helps resolve the order of different operators, associativity comes into play when an expression contains operators of the same precedence level. Associativity defines the direction (left-to-right or right-to-left) in which these operators are evaluated.
</div>
<div class="precedency-container-1">
<h2>Python Operator Precedence and Associativity Table</h2>
<table class="table-1">
<tr>
<th class="th-1">Operator</th>
<th class="th-1">Precedence</th>
<th class="th-1">Associativity</th>
</tr>
<tr>
<td class="td-1">() [] {}</td>
<td class="td-1">Highest</td>
<td class="td-1">Left-to-right</td>
</tr>
<tr>
<td class="td-1">**</td>
<td class="td-1">High</td>
<td class="td-1">Right-to-left</td>
</tr>
<tr>
<td class="td-1">*, /, //, %</td>
<td class="td-1">High</td>
<td class="td-1">Left-to-right</td>
</tr>
<tr>
<td class="td-1">+, -</td>
<td class="td-1">Medium</td>
<td class="td-1">Left-to-right</td>
</tr>
<tr>
<td class="td-1"><<, >>, &</td>
<td class="td-1">Medium</td>
<td class="td-1">Left-to-right</td>
</tr>
<tr>
<td class="td-1">^, |</td>
<td class="td-1">Low</td>
<td class="td-1">Left-to-right</td>
</tr>
<tr>
<td class="td-1"><, <=, >, >=, ==, !=</td>
<td class="td-1">Low</td>
<td class="td-1">Left-to-right</td>
</tr>
<tr>
<td class="td-1">not</td>
<td class="td-1">Low</td>
<td class="td-1">Right-to-left</td>
</tr>
<tr>
<td class="td-1">and</td>
<td class="td-1">Low</td>
<td class="td-1">Left-to-right</td>
</tr>
<tr>
<td class="td-1">or</td>
<td class="td-1">Lowest</td>
<td class="td-1">Left-to-right</td>
</tr>
</table>
</div>
<style>
.libutton {
display: flex;
flex-direction: column;
justify-content: center;
padding: 7px;
text-align: center;
outline: none;
text-decoration: none !important;
color: #ffffff !important;
width: 200px;
height: 32px;
border-radius: 16px;
background-color: #0A66C2;
font-family: "SF Pro Text", Helvetica, sans-serif;
}
</style>
<a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=harshit-gourlariya-a92b65299" target="_blank">Follow on LinkedIn</a>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-53831465445087964952024-11-08T12:00:00.002+05:302024-12-04T11:31:49.923+05:30Operators in Python <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="operator.css">
</head>
<style>
/*NAVBAR CSS IN OPERATORS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW OPERATORS NAVBAR*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
/* Operators Css*/
.grid-container-4 {
grid-column: 1 / span 2;
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfiVcG-YFenmMmGljXtVgzlAdH0t41jx0fUlV3y1jF8vvalhDpziUtAYy7drupQWLnwAsCT5afDFUPzYOZaqok0KrFFsW-PqVzCRHI-JqUZaYJPpzbVpnJzLP2mx9ubrVtCy0nZNwuhHpI1D5JDkxwiZmDtkzSsARKWN4iUYdCC8NIAp0qWlylR1d25uxr/s736/img2.png");
margin: 20px;
padding: 20px;
}
.grid-item-4 {
border: 1px solid #ccc;
padding: 20px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
section{
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
margin: 50px;
/*background-color: #dd5822;*/
}
@media screen and (max-width:426px) {
section{
margin: 0px;
}
.grid-container-4{
margin: 0px;
font-size:11px;
}
}
</style>
<body>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<section>
<!--OPERATORS AND OPERATORS TABLE -->
<div class="grid-container-4">
<h1>Operators</h1>
<p>In Python, operators are special symbols that perform specific operations on values and variables.</p>
<div class="grid-item-4">
<h2>Arithmetic Operators</h2>
<p>Arithmetic operators are symbols used to perform basic mathematical operations on numerical values. These operations include addition, subtraction, multiplication, division, modulus, floor division, and exponentiation.</p>
<table>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>+</td>
<td>Addition</td>
<td>x + y</td>
</tr>
<tr>
<td>-</td>
<td>Subtraction</td>
<td>x - y</td>
</tr>
<tr>
<td>*</td>
<td>Multiplication</td>
<td>x * y</td>
</tr>
<tr>
<td>/</td>
<td>Division</td>
<td>x / y</td>
</tr>
<tr>
<td>%</td>
<td>Modulus</td>
<td>x % y</td>
</tr>
<tr>
<td>**</td>
<td>Exponentiation</td>
<td>x ** y</td>
</tr>
<tr>
<td>//</td>
<td>Floor Division</td>
<td>x // y</td>
</tr>
</table>
</div>
<div class="grid-item-4">
<h2>Comparison Operators</h2>
<p>Comparison operators are used to compare two values and return a Boolean value (True or False). They are essential for making decisions and controlling the flow of your program</p>
<table>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>==</td>
<td>Equal to</td>
<td>x == y</td>
</tr>
<tr>
<td>!=</td>
<td>Not equal to</td>
<td>x != y</td>
</tr>
<tr>
<td>></td>
<td>Greater than</td>
<td>x > y</td>
</tr>
<tr>
<td><</td>
<td>Less than</td>
<td>x < y</td>
</tr>
<tr>
<td>>=</td>
<td>Greater than or equal to</td>
<td>x >= y</td>
</tr>
<tr>
<td><=</td>
<td>Less than or equal to</td>
<td>x <= y</td>
</tr>
</table>
</div>
<div class="grid-item-4">
<h2>Assignment Operators</h2>
<p>Assignment operators are used to assign values to variables</p>
<table>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>=</td>
<td>Assign value</td>
<td>x = y</td>
</tr>
<tr>
<td>+=</td>
<td>Add and assign</td>
<td>x += y</td>
</tr>
<tr>
<td>-=</td>
<td>Subtract and assign</td>
<td>x -= y</td>
</tr>
<tr>
<td>*=</td>
<td>Multiply and assign</td>
<td>x *= y</td>
</tr>
<tr>
<td>/=</td>
<td>Divide and assign</td>
<td>x /= y</td>
</tr>
<tr>
<td>%=</td>
<td>Modulus and assign</td>
<td>x %= y</td>
</tr>
<tr>
<td>**=</td>
<td>Exponentiate and assign</td>
<td>x **= y</td>
</tr>
<tr>
<td>//=</td>
<td>Floor divide and assign</td>
<td>x //= y</td>
</tr>
</table>
</div>
<div class="grid-item-4">
<h2>Logical Operators</h2>
<p>Logical operators are used to combine conditional statements and return a Boolean value (True or False). They are essential for making decisions and controlling the flow of your program.</p>
<table>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>and</td>
<td>Logical AND</td>
<td>x and y</td>
</tr>
<tr>
<td>or</td>
<td>Logical OR</td>
<td>x or y</td>
</tr>
<tr>
<td>not</td>
<td>Logical NOT</td>
<td>not x</td>
</tr>
</table>
</div>
<div class="grid-item-4">
<h2>Bitwise Operators</h2>
<p>Bitwise operators work on bits of an integer. They are used to manipulate individual bits within a binary representation of a number.</p>
<table>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>&</td>
<td>Bitwise AND</td>
<td>x & y</td>
</tr>
<tr>
<td>|</td>
<td>Bitwise OR</td>
<td>x | y</td>
</tr>
<tr>
<td>^</td>
<td>Bitwise XOR</td>
<td>x ^ y</td>
</tr>
<tr>
<td>~</td>
<td>Bitwise NOT</td>
<td>~x</td>
</tr>
<tr>
<td><<</td>
<td>Left shift</td>
<td>x << y</td>
</tr>
<tr>
<td>>></td>
<td>Right shift</td>
<td>x >> y</td>
</tr>
</table>
</div>
<div class="grid-item-4">
<h2>Identity Operators</h2>
<p>Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location.</p>
<table>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>is</td>
<td>Returns True if both variables
refer to the same object</td>
<td>x is y</td>
</tr>
<tr>
<td>is not</td>
<td>Returns True if both variables do not refer to the same object</td>
<td>x is not y</td>
</tr>
</table>
</div>
<div class="grid-item-4">
<h2>Membership Operators</h2>
<p>Membership operators are used to test whether a value or variable is found in a sequence (such as a string, list, tuple, set, or dictionary).</p>
<table>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>in</td>
<td>Returns True if a value is present in a sequence</td>
<td>x in y</td>
</tr>
<tr>
<td>not in</td>
<td>Returns True if a value is not present in a sequence</td>
<td>x not in y</td>
</tr>
</table>
</div>
<style>
.libutton {
display: flex;
flex-direction: column;
justify-content: center;
padding: 7px;
text-align: center;
outline: none;
text-decoration: none !important;
color: #ffffff !important;
width: 200px;
height: 32px;
border-radius: 16px;
background-color: #0A66C2;
font-family: "SF Pro Text", Helvetica, sans-serif;
}
</style>
<a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=harshit-gourlariya-a92b65299" target="_blank">Follow on LinkedIn</a>
</div>
</section>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0tag:blogger.com,1999:blog-6830054486678924141.post-41962890422442797832024-11-01T11:34:00.004+05:302024-12-04T11:30:15.915+05:30Python Basics<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="pb.css">
</head>
<style>
body{
margin: 0px;
background-color: #dd5822;
}
/*NAVBAR CSS*/
.navbar {
display: grid;
grid-template-columns: 1fr 1fr;
background-color: #dd5822;
padding: 10px;
/* Adds spacing between grid items */
}
.navbar-left a {
text-decoration: none;
padding: 10px;
color: white;
}
.navbar-right {
text-align: right;
color: white;
}
.navbar-heading {
margin: 0;
font-size: 20px;
}
/* IMAGE BELOW NAVBAR CSS*/
.sec .image-container {
text-align: center;
}
.sec .image-container img {
display: inline-block;
width: 50%;
margin-top: 10px;
}
.sec div{
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg");
background-repeat: no-repeat;
}
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
padding: 20px;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
margin: 50px 50px 50px 50px;
background-color: white;
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfiVcG-YFenmMmGljXtVgzlAdH0t41jx0fUlV3y1jF8vvalhDpziUtAYy7drupQWLnwAsCT5afDFUPzYOZaqok0KrFFsW-PqVzCRHI-JqUZaYJPpzbVpnJzLP2mx9ubrVtCy0nZNwuhHpI1D5JDkxwiZmDtkzSsARKWN4iUYdCC8NIAp0qWlylR1d25uxr/s736/img2.png");
}
.heading {
grid-column: 1 / span 2;
font-size: 45px;
font-family: 'Times New Roman', Times, serif;
margin-bottom: 10px;
font-weight: bolder;
}
.image-container{
grid-column: 2;
}
.image-container1 {
grid-column: 2;
}
.image-container1 img{
width: 70%;
margin-left: 50px;
margin-top:100px;
}
.text-container {
grid-column: 1;
font-size: 20px;
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
background-color: white;
padding: 20px;
}
/* VARIABLE DIVIDED INTO TWO PARTS CSS */
.code-comparison {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px; /* Adjust the gap as needed */
}
.variable-column {
border: 1px solid black;
padding: 10px;
text-align: center;
margin-top: 30px;
margin-bottom: 30px;
}
.code-column {
display: grid;
grid-template-rows: 1fr 1fr;
gap: 10px; /* Adjust the gap as needed */
}
.code-box {
border: 1px solid black;
padding: 10px;
}
/*LOCAL VARIABLE AND GLOBAL VARIABLE CSS*/
.content{
font-size: 18px;
}
/*#local{
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
background-color: white;
padding: 20px;
}
#Global{
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
background-color: white;
padding: 20px;
}*/
.chroma{
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
background-color: rgb(36, 36, 36);
color: white;
width: 50%;
font-size: 20px;
border-radius: 20px;
padding: 20px;
}
.chroma-2{
box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);
background-color: rgb(36, 36, 36);
color: white;
width: 50%;
font-size: 20px;
margin-top: 0px;
border-radius: 20px;
padding: 20px;
}
.code1{
margin-left: 10px;
}
#in{
margin-left: 30px;
}
/*Media query for laptop*/
@media screen and (min-width:769px) and (max-width:1024px) {
#t-1{
margin-bottom: 40px;
/*background-color: yellow;*/
}
.grid-container-3{
margin-bottom: 20px;
margin-top: 5vh;
}
.description-column{
font-size:12px;
width:100%;
}
.image-container1 img{
margin-left: 15vh;
margin-top: 10vh;
width: 60%;
}
}
/*Media query for tablet*/
@media screen and (min-width:427px) and (max-width:768px) {
.body{
background-color:orange;
}
.text-container{
grid-column: 1 / span 2;
}
.grid-container .image-container1 img{
display: none;
width: 0;
height: 0;
}
#t-1{
margin-bottom: 37px;
/*background-color: yellow;*/
}
.chroma{
width: 80%;
}
.chroma-2{
width: 80%;
}
.grid-container-3{
margin-bottom: 2px;
margin-top: 9vh;
/*height:20%; */
}
.grid-container-3 .data-type-column{
margin-top:10vh;
}
.data-type{
margin: 0px;
padding: 10px;
font-size:12px;
width:70%;
}
.description-column p{
font-size:12px;
width:70%
}
.image-container1 img{
margin-left: 8vh;
margin-top: 25vh;
width: 75%;
}
}
/*DATA TYPES CSS*/
.grid-container-1 {
grid-column: 1 / span 2;
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
/* padding: 20px; */
/*margin: 50px 50px 50px 50px; */
/*background-color: white;*/
background-image: url(img2.png);
}
.heading-1 {
grid-column: 1 / span 2;
font-size: 45px;
font-family: 'Times New Roman', Times, serif;
margin-bottom: 0px;
font-weight: bolder;
}
.text-container-2 {
grid-column: 1;
font-size: 20px;
/* box-shadow: 10px 10px 5px rgba(0, 0, 0, 0.3);*/
/*background-color: white;*/
padding: 20px;
padding-left: 0px;
}
.grid-container-3 {
display: grid;
grid-template-columns: 1fr 1fr ; /* Adjust column widths as needed */
gap: 20px;
margin-left: 5vh;
background-color: rgb(36, 36, 36);
color: white;
border-radius: 20px;
height:60%;
font-size:9px;
margin-top:50px;
}
/*DATA TYPE PARTS TABLE CSS*/
.data-type-column {
text-align: center;
margin-top: 11vh;
}
.data-type {
margin: 20px 0;
border: 1px solid rgb(255, 255, 255);
margin-right: 20px;
margin-left: 10px;
border-radius: 20px;
width:70%;
}
.description-column{
grid-column: 2;
}
.description-column p {
margin-bottom: 10px;
border: 1px solid rgb(245, 242, 242);
margin-right: 10vh;
padding: 3px;
padding-left: 8px;
border-radius: 20px;
width:70%;
}
/*DATA TYPE PARTS*/
.Dp{
font-size: 20px;
}
/* CSA FOR MOBILES*/
@media screen and (max-width:426px)
{
.grid-container h2{
font-size: 20px;
}
.grid-container .text-container{
font-size: 10px ;
}
.text-container{
grid-column: 1 / span 2;
}
.grid-container .image-container1{
height: 0;
width: 0;
}
.grid-container .image-container1 img{
display: none;
/* margin-left: 5vh;
margin-top: 20vh ;
width: 66%; */
}
.content{
font-size: 12px;
}
.content h1{
font-size: 20px;
}
.grid-container{
margin: 0px;
}
.text-container-2{
grid-column: 1 / span 2;
}
.grid-container-3{
display: none;
/* margin: 0px;
height: 70%;
margin-top: 8vh;*/
}
.data-type{
font-size: 10px;
}
.description-column{
font-size: 10px;
margin: 0px;
}
.Dp-1{
font-size: 10px;
}
.Dp{
font-size: 12px;
}
.chroma{
width: 80%;
font-size: 12px;
}
.chroma-2{
width: 80%;
font-size: 12px;
height:45%;
}
#t-1{
margin-bottom: 10.4vh;
}
.text-container-2 p{
font-size: 12px;
}
}
</style>
<body>
<!--NAVBAR-->
<div class="navbar">
<div class="navbar-left">
<a href="#">Home</a>
<!--<a href="#">About Us</a>-->
</div>
<div class="navbar-right">
<h2 class="navbar-heading">HG Blogs</h2>
</div>
</div>
<section1 id="s1" >
<!--IMAGE BELOW NAVABR-->
<div class="sec">
<div class="image-container">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpMIQcTX980HhsvfEEgLBHxlkLKqMQldUENG0USjzNqhfSpPiIKBDuD7G4vqUWJiJxhttUl2Is6NHL7W637L3EPeaEuiH-cP9Aw0MZXUcSQJyGnservB39N14mnScXwWN0ob7By6tKUpzg7kW94C-E5oqMyEJgIUIwUu8JcogbB_RUr2WC01uZTjLNuB5g/s4176/ajay-gorecha-K3FpO1x0qB0-unsplash.jpg" alt="Image description">
</div>
</div>
<!--PYTHON EXPLANATION BEGIN -->
<div class="grid-container" id="grid">
<h2 class="heading">PYTHON</h2>
<div class="text-container">
<p>"Python is a high-level programming language. It is also known as an interpreted language because it executes code line by line, rather than compiling the entire program at once."
</p>
<p>
The Variables are used to hold the values of different data types in Python. There are primarily two types of variables in most programming languages.
The local variable and the Global variable.
</p>
<!--VARIABLE DIVDED INTO TWO PARTS -->
<div class="code-comparison">
<div class="variable-column">
Variable
</div>
<div class="code-column">
<div class="code-box">
Local Variable
</div>
<div class="code-box">
Global Variable
</div>
</div>
</div>
</div>
<div class="image-container1">
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqOD687Aqwh65HhK8_TW-Ut3IckJStX2eSf2cW-A3lP8B_ru8DNwM5erHKzdEOleQoUwxpM0otJ7S6sqGnRdOPXvYXvaCupd31rDOgUzfczyuxdDY27qpuh3OI4ktjNHVBoN5xlkS3La5mufBVmPIVy_EXlB-IO4VhEUFOpa4ssaZZtQhYQRzMIay1TVVT/s1000/img.jpg"alt="Image">
</div>
<!--lOCAL VARIBALE AND GLOBAL VARIABLE -->
<div class="content" id="local">
<h1>Local variable</h1>
<p>The local varible is only defined with in the the specific functions. The local variable in a program doesn't hold any value outside the function in a program.
<div class="chroma">
<span class="code1">x=10</span><br>
<span class="code1">y=20</span><br>
<span class="code1">def add(a,b):</span><br>
<span class="code1" id="in"> c=a+b</span><br>
<span class="code1" id="in" > return c</span><br>
<span class="code1">sum=add(x,y)</span><br>
<span class="code1">print(sum)</span><br>
<span class="code1" id="in2">// here the variables a,b are local variables</span>
</div>
</div>
<div id="Global" class="content">
<h1>Global Variable</h1>
<p id="t-1">The Global Variable is the variable which is defined for the whole program it will work in every function.
</p>
<div class="chroma-2">
<span class="code1">x=10</span><br>
<span class="code1">y=20</span><br>
<span class="code1">def add(a,b):</span><br>
<span class="code1" id="in"> c=a+b</span><br>
<span class="code1" id="in" > return c</span><br>
<span class="code1">sum=add(x,y)</span><br>
<span class="code1">print(sum)</span><br>
<span class="code1" id="in2">// Here the variables x and y are global variables </span>
</div>
</div>
<!--DATA TYPE-->
<div class="grid-container-1">
<h2 class="heading-1">Data Types</h2>
<div class="text-container-2">
<p>"Data types define the kind of value a variable can hold. They determine the operations that can be performed on the variable.A variable can be of numeric data type(int,float,complex),String Data type etc.
</p>
<p>
"In Python, you don't need to explicitly declare the data type of a variable, unlike in languages like C and C++."
</p>
<p>
There are mainly 6 Types of Data type:
</p>
</div>
<div class="grid-container-3">
<div class="data-type-column">
<div class="data-type">Data Types</div>
</div>
<div class="description-column">
<p>Numeric</p>
<p>String</p>
<p>List</p>
<p>Boolean</p>
<p>Tuple</p>
<p>Dictionary </p>
</div>
</div>
<!-- DATA TYPES PARTS-->
<div class="Dp-1" id="datatype-1">
<h1>Numeric Data Type</h1>
<p class="Dp">Numeric data types represent numbers. They are further classified into two categories:</p>
<ul class="Dp">
<li>Integer: Whole numbers (e.g., 10, -5, 0)</li>
<li>Float: Decimal numbers (e.g., 3.14, -2.5)</li>
</ul>
</div>
<div class="Dp-1">
<h1>String Data Type</h1>
<p class="Dp">A sequence of characters enclosed in single or double quotes.</p>
<p class="Dp">Example: "Hello, World!"</p>
</div>
<div class="Dp-1">
<h1>Boolean Data Type</h1>
<p class="Dp">Represents either True or False.</p>
<p class="Dp">Example: True, False</p>
</div>
<div class="Dp-1">
<h1>List Data Type</h1>
<p class="Dp" >An ordered collection of items, enclosed in square brackets.</p>
<p class="Dp">Example: [1, 2, 3, "apple", "banana"]</p>
</div>
<div class="Dp-1">
<h1>Dictionary Data Type</h1>
<p class="Dp">An unordered collection of key-value pairs, enclosed in curly braces.</p>
<p class="Dp">Example: {"name": "Alice", "age": 30, "city": "New York"}</p>
</div>
<div class="Dp-1"><h1>Tuple Data Type</h1>
<p class="Dp">An ordered, immutable collection of items, enclosed in parentheses.</p>
<p class="Dp">Example: (10, 20, 30, "Python")</p>
</div>
<style>
.libutton {
display: flex;
flex-direction: column;
justify-content: center;
padding: 7px;
text-align: center;
outline: none;
text-decoration: none !important;
color: #ffffff !important;
width: 200px;
height: 32px;
border-radius: 16px;
background-color: #0A66C2;
font-family: "SF Pro Text", Helvetica, sans-serif;
}
</style>
<a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=harshit-gourlariya-a92b65299" target="_blank">Follow on LinkedIn</a>
</section1>
</body>
</html>HGhttp://www.blogger.com/profile/06113594604059490795[email protected]0