Wednesday, 8 April 2026

πŸš€ Day 14/150 – Convert Celsius to Fahrenheit in Python 🌑️

 


πŸš€ Day 14/150 – Convert Celsius to Fahrenheit in Python

Temperature conversion is one of the most common beginner-friendly problems in programming. It helps you understand formulas, user input, functions, and even advanced concepts like list comprehensions.

The formula used is:

F=(C×95)+32F = (C \times \frac{9}{5}) + 32

Let’s explore multiple ways to implement this in Python πŸ‘‡

πŸ”Ή Method 1 – Direct Conversion

This is the simplest and most straightforward approach.

celsius = 25 fahrenheit = (celsius * 9/5) + 32 print("Temperature in Fahrenheit:", fahrenheit)


✅ Explanation:

  • We directly assign a value to celsius
  • Apply the formula
  • Print the result

πŸ‘‰ Best for: Quick calculations or testing

πŸ”Ή Method 2 – Using User Input

This makes your program interactive.

celsius = float(input("Enter temperature in Celsius: ")) fahrenheit = (celsius * 9/5) + 32 print("Temperature in Fahrenheit:", fahrenheit)




✅ Explanation:
  • input() takes user input as string
  • float() converts it into a number
  • Formula is applied as usual

πŸ‘‰ Best for: Real-world programs where users provide input

πŸ”Ή Method 3 – Using a Function

Functions make your code reusable and cleaner.

def celsius_to_fahrenheit(c): return (c * 9/5) + 32 print(celsius_to_fahrenheit(25))



✅ Explanation:

  • Function takes input c
  • Returns converted value
  • Can be reused multiple times

πŸ‘‰ Best for: Clean and modular code

πŸ”Ή Method 4 – Using Lambda Function (One-liner)

A shorter version of functions.

convert = lambda c: (c * 9/5) + 32 print(convert(25))


✅ Explanation:
  • lambda creates an anonymous function
  • Useful for quick operations

πŸ‘‰ Best for: Short, one-time use functions

πŸ”Ή Method 5 – Using List Conversion

Convert multiple values at once.

celsius_values = [0, 10, 20, 30] fahrenheit_values = [(c * 9/5) + 32 for c in celsius_values] print(fahrenheit_values)



✅ Explanation:

  • Uses list comprehension
  • Converts each value in the list
  • Efficient and Pythonic

πŸ‘‰ Best for: Bulk data processing

⚡ Key Takeaways

  • Always remember the formula: (C × 9/5) + 32
  • Use float() when taking decimal inputs
  • Functions improve reusability
  • Lambda is great for quick operations
  • List comprehensions are powerful for handling multiple values

April Python Bootcamp Day 4

 



Day 4: Input & Output in Python

Making Your Programs Interactive 


 Introduction

Till now, your programs were static — they always produced the same output.

But real-world programs don’t work like that.

They take input from users, process it, and then show output.

 This is the core idea of programming:

Input → Processing → Output

In this blog, you’ll learn how to:

  • Take input from users
  • Display output properly
  • Format output professionally

 What is Input?

Input is data provided to a program during execution.

This data can come from:

  • Keyboard (user typing)
  • Files
  • APIs (advanced)

But for now, we focus on user input from keyboard.


 Why Input is Important?

Without input:

  • Programs are fixed
  • No flexibility
  • Same output every time

Example:

 Static Program:

print("Hello Piyush")

 Dynamic Program:

name = input("Enter your name: ")
print("Hello", name)

 Now the output changes based on user → interactive program


 Taking Input in Python

Python provides a built-in function:

input()

 Basic Example:

name = input("Enter your name: ")
print(name)

 Important Concept (VERY IMPORTANT)

input() always returns a string

age = input("Enter your age: ")
print(type(age)) # Output: <class 'str'>

 Type Conversion (Revision)

To perform calculations, convert input:

age = int(input("Enter age: "))
print(age + 5)

Common Conversions:

int(input()) # integer
float(input()) # decimal
str(input()) # string (default)

 What is Output?

Output is the result displayed to the user after processing input.

Without output:

  • User cannot see results
  • Program has no visible effect

 Displaying Output in Python

Python uses:

print()

 Basic Example:

print("Hello World")

 Printing Multiple Values

name = "Piyush"
age = 21

print("Name:", name, "Age:", age)

 sep and end (Advanced Printing)

 Separator (sep)

print("Python", "Java", "C++", sep=" | ")

 End Parameter (end)

print("Hello", end=" ")
print("World")

 String Formatting

String formatting helps display output in a clean and professional way.


 1. f-Strings (Recommended)

name = "Piyush"
age = 21

print(f"My name is {name} and I am {age} years old")

 Fast, readable, modern


 2. .format() Method

print("My name is {} and I am {}".format(name, age))

 3. % Formatting (Old Style)

print("My name is %s and age is %d" % (name, age))

 Escape Characters

print("Hello\nWorld") # New line
print("Hello\tWorld") # Tab
print("He said \"Hi\"")

 Practice Questions

 Basic

Take name as input and print:
"Welcome, <name>"
Take two numbers and print their sum
Take age and print:
"You will be <age+5> after 5 years"

 Intermediate

Take name and marks, print:
"<name> scored <marks> marks"
Take 3 numbers and print their average

 Tricky

a = input("Enter number: ")
b = input("Enter number: ")
print(a + b)

 Why is output concatenation and not addition?


print("Hello", end="---")
print("World", end="***")

 Predict output


a, b = input().split()
print(int(a) + int(b))

 What if user enters only one value?



Tuesday, 7 April 2026

Python Coding Challenge - Question with Answer (ID -080426)

 


Code Explanation:

πŸ”Ή 1. Creating the Tuple
t = (1, 2, 3)
Here, a tuple named t is created.
It contains three elements: 1, 2, and 3.
Tuples are ordered and immutable (cannot be changed after creation).

πŸ”Ή 2. Accessing Tuple Elements
Each element in the tuple has an index:
t[0] → 1
t[1] → 2
t[2] → 3

πŸ”Ή 3. Attempting to Modify the Tuple
t[0] = 10
This line tries to change the first element (1) to 10.

πŸ”Ή 4. What Actually Happens

Python raises an error:

TypeError: 'tuple' object does not support item assignment
Reason: Tuples are immutable, meaning their values cannot be changed after creation.

Final Output:
Error

Book: AUTOMATING EXCEL WITH PYTHON



Python Coding challenge - Day 1126| What is the output of the following Python Code?

 


Code Explanation:

1️⃣ Defining the Class
class A:

Explanation

A class A is created.
It will contain variables and methods.

2️⃣ Defining Class Variable
x = 10

Explanation

x is a class variable.
It belongs to the class, not individual objects.

3️⃣ Defining @classmethod
@classmethod
def f(cls):

Explanation

f is a class method.
It receives the class itself as cls.

4️⃣ Accessing Class Variable via cls
return cls.x

Explanation

Accesses class variable x using cls.
Works for inheritance too (dynamic reference).

5️⃣ Defining @staticmethod
@staticmethod
def g():

Explanation

g is a static method.
It does NOT receive self or cls.

6️⃣ Accessing Class Variable Directly
return A.x

Explanation

Directly accesses class A.
Not flexible for inheritance (hardcoded).

7️⃣ Calling Methods
print(A.f(), A.g())

Explanation

Calls both methods using class A.

πŸ”„ Method Execution
πŸ”Ή A.f()
cls = A
Returns:
A.x → 10
πŸ”Ή A.g()
Directly returns:
A.x → 10

πŸ“€ Final Output
10 10

Python Coding challenge - Day 1125| What is the output of the following Python Code?

 


Code Explanation:

1️⃣ Importing dataclass
from dataclasses import dataclass

Explanation

Imports the dataclass decorator.
It auto-generates methods like __init__, __repr__, etc.

2️⃣ Applying @dataclass
@dataclass

Explanation

Converts class A into a dataclass.
Automatically creates constructor like:
def __init__(self, x=[]):
    self.x = x

⚠️ Important: x=[] is evaluated once, not per object.

3️⃣ Defining Class
class A:

Explanation

Defines class A.

4️⃣ Defining Attribute with Default Value
x: list = []

Explanation ⚠️ CRITICAL

x is given a default value of an empty list.
This list is shared across all instances.

πŸ‘‰ Only ONE list is created in memory.

5️⃣ Creating First Object
a1 = A()

Explanation

a1.x refers to the shared list.

6️⃣ Creating Second Object
a2 = A()

Explanation

a2.x refers to the same shared list.

πŸ‘‰ So:

a1.x is a2.x → True

7️⃣ Modifying List from a1
a1.x.append(1)

Explanation

Adds 1 to the shared list.

πŸ‘‰ Now shared list becomes:

[1]

8️⃣ Printing from a2
print(a2.x)

Explanation

Since a2.x points to the same list:
[1]

πŸ“€ Final Output
[1]

Python Coding challenge - Day 1124| What is the output of the following Python Code?

 


Code Explanation:

1️⃣ Importing Enum
from enum import Enum

Explanation

Imports the Enum class from Python’s enum module.
Used to create enumerations (named constants).

2️⃣ Defining Enum Class
class Color(Enum):

Explanation

Creates an enum class named Color.
It inherits from Enum.

3️⃣ Defining Enum Members
RED = 1
BLUE = 2

Explanation

Defines two enum members:
Color.RED → value 1
Color.BLUE → value 2

πŸ‘‰ These are unique objects, not just numbers.

4️⃣ Comparing Enum Values
print(Color.RED == Color(1))

Explanation

Color.RED → enum member
Color(1) → converts value 1 into enum member

πŸ‘‰ So:

Color(1) → Color.RED

5️⃣ Final Comparison
Color.RED == Color.RED

Explanation

Both refer to the same enum member.

πŸ“€ Final Output
True

Python Coding challenge - Day 1123| What is the output of the following Python Code?

 


Code Explanation:

1️⃣ Importing lru_cache
from functools import lru_cache

Explanation

Imports lru_cache from the functools module.
It is used for memoization (caching function results).

2️⃣ Applying Decorator
@lru_cache(None)

Explanation

This decorator caches results of function calls.
None means unlimited cache size.

πŸ‘‰ So once a value is computed, it is stored and reused.

3️⃣ Defining Function
def f(n):

Explanation

Defines function f that takes input n.

4️⃣ Base Condition
if n <= 1:
    return n

Explanation

If n is 0 or 1, return n.
This is the base case of recursion.

5️⃣ Recursive Case
return f(n-1) + f(n-2)

Explanation

This is Fibonacci logic.
Computes:
f(n) = f(n-1) + f(n-2)

6️⃣ Calling Function
print(f(5))

Explanation

Calls f(5).
πŸ”„ Execution (Step-by-Step)

Without cache:

f(5)
= f(4) + f(3)
= (f(3)+f(2)) + (f(2)+f(1))
= ...

πŸ‘‰ Many repeated calls!

⚡ With lru_cache

Each value is computed once only:

Call Value
f(0) 0
f(1) 1
f(2) 1
f(3) 2
f(4) 3
f(5) 5

πŸ“€ Final Output
5

Monday, 6 April 2026

Python Coding Challenge - Question with Answer (ID -070426)

 


Code Explanation:

1. Global Variable Declaration
x = 14
A variable x is created in the global scope.
Its value is 14.
This means x can be accessed anywhere in the program unless shadowed locally.

⚙️ 2. Function Definition
def func():
A function named func is defined.
No parameters are passed to this function.

πŸ–¨️ 3. First Statement Inside Function
print(x)
Python looks for x inside the function first (local scope).
But notice: later in the function, x = 5 exists.
Because of that assignment, Python treats x as a local variable throughout the function.

πŸ‘‰ Important rule:

If a variable is assigned anywhere inside a function, Python considers it local to that function (unless declared global).

❗ 4. Local Assignment
x = 5
This creates a local variable x inside func.
It does NOT affect the global x.

🚨 5. Function Call
func()
When the function runs:
Python sees x = 5 → decides x is local
Then tries print(x) BEFORE assigning it

πŸ’₯ 6. Error Occurs

You will get:

UnboundLocalError: local variable 'x' referenced before assignment
Why?
Python thinks x is local
But print(x) tries to use it before it's assigned

Final Output:
Error

Book: Python Functions in Depth — Writing Clean, Reusable, and Powerful Code

Fundamentals of Deep Learning Models

 


Artificial Intelligence is transforming industries at an unprecedented pace — and at the heart of this transformation lies deep learning. From voice assistants to self-driving cars, deep learning models are powering the most advanced technologies of our time.

Fundamentals of Deep Learning Models is a beginner-friendly guide that helps you understand the core concepts, architectures, and techniques behind these intelligent systems. Whether you’re starting your AI journey or strengthening your foundation, this book provides a solid entry point. πŸš€


πŸ’‘ Why Deep Learning Matters

Deep learning is a subset of machine learning that uses multi-layered neural networks to learn patterns from data.

It is widely used in:

  • 🧠 Natural Language Processing (chatbots, translation)
  • πŸ‘ Computer Vision (image recognition)
  • 🎧 Speech recognition systems
  • 🎯 Recommendation engines

Its ability to learn complex patterns from large datasets has made it one of the most powerful tools in modern AI .


🧠 What This Book Covers

This book focuses on building a strong conceptual foundation, making it easier for readers to understand and apply deep learning techniques.

πŸ”Ή Introduction to AI, ML, and Deep Learning

The book begins by explaining how:

  • Artificial Intelligence → broad field
  • Machine Learning → subset of AI
  • Deep Learning → subset of ML

This layered understanding helps learners see the big picture of intelligent systems .


πŸ”Ή Neural Networks Fundamentals

At the core of deep learning are neural networks. You’ll learn:

  • Structure of neurons and layers
  • Activation functions (ReLU, Sigmoid, etc.)
  • Forward propagation

These are the building blocks of all deep learning models.


πŸ”Ή Training Deep Learning Models

The book explains how models learn using:

  • Gradient descent optimization
  • Backpropagation algorithms
  • Loss functions and error minimization

These concepts are essential for improving model performance and accuracy.


πŸ”Ή Popular Deep Learning Architectures

You’ll explore widely used architectures such as:

  • Feedforward Neural Networks (FNNs)
  • Convolutional Neural Networks (CNNs)
  • Recurrent Neural Networks (RNNs)

These architectures power applications in image processing, text analysis, and sequence prediction .


πŸ”Ή Model Evaluation and Challenges

The book also highlights real-world challenges like:

  • Overfitting and underfitting
  • Bias-variance tradeoff
  • Model generalization

Understanding these helps you build more reliable AI systems.


πŸ›  Learning Approach

One of the strengths of this book is its beginner-friendly approach:

  • Simple explanations without heavy math
  • Visual illustrations and examples
  • Step-by-step concept building

It focuses on helping readers understand concepts intuitively, rather than just memorizing formulas .


🎯 Who Should Read This Book?

This book is ideal for:

  • Beginners in AI and machine learning
  • Students in computer science or data science
  • Developers exploring deep learning
  • Professionals transitioning into AI

It’s designed to take you from basic understanding → practical awareness.


πŸš€ Why This Book Stands Out

What makes this book valuable:

  • Covers fundamentals in a structured way
  • Explains concepts with clarity and simplicity
  • Connects theory to real-world applications
  • Suitable for both beginners and intermediate learners

It acts as a foundation builder before diving into advanced deep learning topics.


Hard Copy: Fundamentals of Deep Learning Models

πŸ“Œ Final Thoughts

Deep learning is one of the most exciting and impactful areas of technology today. But to truly master it, you need a strong understanding of its fundamentals.

Fundamentals of Deep Learning Models provides that foundation — helping you understand how models work, how they learn, and how they are applied in real-world scenarios.

If you’re starting your journey in AI or looking to strengthen your basics, this book is a great place to begin. πŸ“ŠπŸ€–

FROM FORGOTTEN TECHNOLOGIES TO ARTIFICIAL INTELLIGENCE: Tracing the Evolution of Artificial Intelligence

 


Artificial Intelligence may seem like a modern breakthrough, but its roots stretch back decades — even centuries. Behind today’s powerful AI systems lies a long history of forgotten ideas, experimental technologies, and visionary thinkers.

From Forgotten Technologies to Artificial Intelligence: Tracing the Evolution of Artificial Intelligence takes readers on a fascinating journey through time, revealing how past innovations shaped the intelligent systems we use today. πŸš€


πŸ’‘ Why Understanding AI’s History Matters

AI didn’t appear overnight. It evolved through multiple phases — from early theoretical ideas to modern deep learning breakthroughs.

In fact:

  • The foundations of AI began as early as the early 1900s
  • Major developments took place in the 1950s, marking the birth of AI as a field
  • Progress came in waves, including periods of rapid growth and “AI winters” where interest declined

Understanding this journey helps us:

  • Appreciate current technologies
  • Learn from past failures
  • Predict future trends in AI

🧠 What This Book Explores

This book offers a historical and conceptual exploration of AI, focusing on both well-known breakthroughs and overlooked innovations.

πŸ”Ή Forgotten Technologies That Shaped AI

Many early technologies and ideas contributed to AI but are often overlooked. The book highlights:

  • Early computational theories
  • Primitive automation systems
  • Historical attempts at machine intelligence

These “forgotten” innovations laid the groundwork for modern AI systems.


πŸ”Ή The Birth and Evolution of AI

The book traces key milestones such as:

  • The creation of artificial neural models in the 1940s
  • The rise of symbolic AI and rule-based systems
  • The transition to machine learning and deep learning

It shows how AI evolved from simple rule-based systems to complex learning models.


πŸ”Ή The Cyclical Nature of AI Progress

AI development has not been linear. Instead, it has gone through cycles:

  • AI Booms → periods of excitement and funding
  • AI Winters → periods of decline and skepticism

Even “forgotten waves” like the Semantic Web era played a crucial role in shaping today’s intelligent systems .


πŸ”Ή Modern AI and the Rise of Intelligent Systems

The book connects history to the present, explaining how we arrived at:

  • Machine learning and deep learning
  • Generative AI and large language models
  • Autonomous agents and intelligent systems

Today’s AI is built on decades of accumulated knowledge and experimentation.


πŸ›  Key Takeaways from the Book

By reading this book, you will:

  • Understand the historical roots of AI
  • Learn about forgotten innovations that influenced modern systems
  • See how AI evolved through successes and failures
  • Gain insights into future directions of AI

It helps you move beyond just using AI — to truly understanding its evolution.


🎯 Who Should Read This Book?

This book is ideal for:

  • Students and beginners in AI
  • Tech enthusiasts curious about AI history
  • Researchers and professionals in machine learning
  • Anyone interested in how technology evolves over time

No deep technical knowledge is required — just curiosity about AI and its journey.


πŸš€ Why This Book Stands Out

Unlike many technical AI books, this one focuses on storytelling and historical context.

What makes it unique:

  • Highlights overlooked and forgotten technologies
  • Connects past innovations to present breakthroughs
  • Explains AI evolution in a simple, engaging way
  • Provides a broader perspective beyond coding and algorithms

It shows that AI is not just a technology — it’s a continuously evolving story.


Hard Copy: FROM FORGOTTEN TECHNOLOGIES TO ARTIFICIAL INTELLIGENCE: Tracing the Evolution of Artificial Intelligence

Kindle: FROM FORGOTTEN TECHNOLOGIES TO ARTIFICIAL INTELLIGENCE: Tracing the Evolution of Artificial Intelligence

πŸ“Œ Final Thoughts

Artificial Intelligence is often seen as the future — but to truly understand it, we must look at the past.

From Forgotten Technologies to Artificial Intelligence reminds us that innovation is built on layers of ideas, experiments, and even failures. Every breakthrough today stands on the shoulders of forgotten technologies.

If you want to understand not just how AI works, but how it came to be, this book is a fascinating and insightful read. 🌟

Popular Posts

Categories

100 Python Programs for Beginner (119) AI (239) Android (25) AngularJS (1) Api (7) Assembly Language (2) aws (28) Azure (10) BI (10) Books (262) Bootcamp (3) C (78) C# (12) C++ (83) Course (87) Coursera (300) Cybersecurity (30) data (5) Data Analysis (29) Data Analytics (21) data management (15) Data Science (340) Data Strucures (16) Deep Learning (145) Django (16) Downloads (3) edx (21) Engineering (15) Euron (30) Events (7) Excel (19) Finance (10) flask (4) flutter (1) FPL (17) Generative AI (68) Git (10) Google (51) Hadoop (3) HTML Quiz (1) HTML&CSS (48) IBM (41) IoT (3) IS (25) Java (99) Leet Code (4) Machine Learning (278) Meta (24) MICHIGAN (5) microsoft (11) Nvidia (8) Pandas (13) PHP (20) Projects (32) pytho (1) Python (1288) Python Coding Challenge (1124) Python Mistakes (50) Python Quiz (466) Python Tips (5) Questions (3) R (72) React (7) Scripting (3) security (4) Selenium Webdriver (4) Software (19) SQL (48) Udemy (18) UX Research (1) web application (11) Web development (8) web scraping (3)

Followers

Python Coding for Kids ( Free Demo for Everyone)