#python functions
Explore tagged Tumblr posts
Text
Python Basics: Variables, Loops & Functions Explained Simply

🔹 Introduction to Python Programming
Python is like the cool friend who can suddenly make everything easier. Whether one is creating a calculator, automating mundane gestures, or simply dreaming of developing their own game, Python is often the first language anyone can turn to. But why?
👉 Join our full Python course to start learning step by step.
Being Python-Friendly for a Beginner
Because it has a clean readable syntax without a lot of techno babble. Python feels like English. You do not have to memorize some wild symbols or worry about setup-heavy jargon. It is just simple and direct, yet powerful.
What Can You Build with Python?
Python builds web apps, machine learning models, multimedia dashboards, even robots. Instagram, Dropbox, and Netflix all `speak` Python. Now, that is a cool thing!
🔹 Getting Started with Python
How to Install Python
To install Python and start coding, go to python.org. Click on download and install it just as you would install any application. Make sure you check the box that says "Add Python to PATH!"
Writing Your First Python Program
Open the terminal or IDLE, and type now:
python
print("Hello, world!")
Hit Enter. Boom! You just wrote your first Python program!
🔹 Understanding Variables in Python.
What Are Variables?
Think of variables as containers; they contain data that you may want to access later. Think of it like a jar with a label- the variable stands for something we can retrieve and reuse.
python
name = "Alice"
age = 25
Here, name holds "Alice," and age holds 25.
Python Variable Naming Rules
Start with a letter or underscore (_)
Cannot begin with a number
Use snake_case for readability
Be descriptive: user_age is better than x
Different Data Types in Python
Python variables can store:
Integers: 5
Floats: 3.14
Strings: "hello"
Booleans: True, False
Lists: [1, 2, 3]
Dictionaries: {"name": "Alice", "age": 25}
🔹 Introduction to Loops in Python
What Are Loops?
They let you execute the same set of commands repeatedly without having to copy the code a hundred times.
For Loop in Python
Perfect when you know exactly how many times to repeat something.
python
for i in range(5):
print("Loop number",i)
While Loop in Python
Perfect for when you don’t really know quite how many times you’re going to do something — you simply go on until a state-of- affairs has been met.
python
x = 0
while x < 5:
print(x)
x += 1
Loop Control Statements
break: terminates loop execution prematurely
continue: skips all statements in the current iteration and jumps to the next iteration of the loop
pass: does nothing; it is used as a placeholder
Also Read: Why Is Python A Good Programming Language For Beginners
🔹 Python Functions Made Easy
What Is a Function?
A function is a reusable block of code. It's like a recipe, one written once and used whenever a situation arises.
def greet():
print("Hello!")
Built-in Vs User-Defined Functions
Built-in: Already present, like print(), len(), and type()
User Defined: Created by you via def.
How to Define a Function
python
def say_hello(name):
print("Hello", name)
Call it using say_hello("Alice")
Function Parameters and Return Values
You can pass information into a function and possibly get a result back:
python
def add(a, b):
return a + b
🔹 Practical Examples of Variables, Loops & Functions
Simple Calculator Using Functions
python
def add(a, b):
return a + b
print(add(10, 5))
Looping through a List of Names
python
names= ["Alice", "Bob", "Charlie"]
for name in names:
print("Hello", name)
Using Variables to Keep Score
python
score = 0
score += 10
print("Your score is", score)
🔹 Common Mistakes Beginners Make
Variable Name Confusion
name and Name can be entirely different variables; Python is case-sensitive.
Infinite Loops
If you forget to update a variable used in a while loop, the program might never terminate.
Forget Return Statements
If a function is not specified with return, no value is returned; it simply performs an action.
🔹 Tips to Improve Your Python Skills
Practice Small Projects
Start with building a calculator, to-do app, or number guessing game.
Read Others' Code
Check out GitHub, follow tutorials, and watch how others approach a problem.
Use Online Platforms for Coding Practice
Try HackerRank, LeetCode, or Codecademy to get your practice and challenges.
Conclusion
Python is a beginner's best friend, especially once you understand the concepts of variables, loops, and functions. These concepts form the basis of almost every program. You will use these tools at every stage, from printing 'Hello World' to building a weather app.
So go ahead, code, break things, fix things, and most importantly, have fun with it. Python is always there for you!
🎓 Want to go beyond Python? Check out our full programming course library and take the next step in your coding journey.
At TCCI, we don't just teach computers — we build careers. Join us and take the first step toward a brighter future.
Location: Bopal & Iskcon-Ambli in Ahmedabad, Gujarat
Call now on +91 9825618292
Visit Our Website: http://tccicomputercoaching.com/
Note: This Post was originally published on https://tccicomputercoaching.wordpress.com/2025/05/07/python-basics-variables-loops-functions-explained-simply/ and is shared here for educational purposes.
0 notes
Text
Python Functions
Introduction In Python, functions are reusable blocks of code that perform a specific task. They allow you to break down your program into smaller, modular components, making your code more organized, easier to understand, and easier to maintain. Functions help avoid redundancy by allowing you to reuse the same code multiple times without having to rewrite it. Defining a Function In Python,…
View On WordPress
0 notes
Text
Python Functions: A Comprehensive Guide with Examples
Python, a versatile and powerful programming language, owes much of its popularity to its elegant syntax and extensive standard library. Among its many features, functions stand out as a fundamental building block for organizing and reusing code. Functions can be used for many in-code tasks such as manipulating Python lists or images for computer vision. In this comprehensive guide, we’ll delve…

View On WordPress
0 notes
Text
Python split()
The split() method in Python is used to split a string into a list of substrings based on a delimiter. Here are multiple examples demonstrating its usage. Example 1: Splitting a String by Space sentence = "This is an example sentence." words = sentence.split() # Defaults to splitting by space print(words) # Output: ['This', 'is', 'an', 'example', 'sentence.'] Example 2: Splitting a String by…

View On WordPress
0 notes
Text
Day-6: Python Functions
Day-6: Python Fuctions - Python Boot Camp 2023
Introduction to Python functions Python functions are blocks of reusable code designed to perform specific tasks. They allow you to break down complex programs into smaller, manageable pieces. Functions enhance code reusability and readability, making it easier for developers to maintain and understand their programs. In this article, we will explore various aspects of Python functions, from…

View On WordPress
#Built-in functions in Python#Function annotations in Python#Function definition in Python#How to call a function in Python#Lambda functions in Python#Python decorators#Python function advantages#Python function best practices#Python function disadvantages#Python function examples#Python function parameters#Python function scope and lifetime#Python function tutorial#Python functions#Recursive functions in Python
0 notes
Text










These are the vibes I THE WHYTE PYTHON WORLD TOUR brings to the function bookshelf.
It's Spinal Tap meets Austin Powers.
It's an 80s themed wrestling duo alarming the interviewer.
It's Lorelei Gilmore Reading THE DIRT.
It's Ozzy Osbourne on reality TV.
It's "The Wind of Change" being used as a political battle cry.
Get ready for the world tour...
#fiction#books#whyte python world tour#reading#spinal tap#austin powers#the vibe i bring to the function#carl hiaasen#satire#humor#comedy#book review
341 notes
·
View notes
Text
deskpet mikey :)

#if anyone wants him i can put him on a github repo with instructions on how to configure him to ur screensize / the right file path#also u need to have python and pyautogui installed and also he only works properly on windows. i need to fix the little white dots#i love my barely functional son 🫶#my art :D#woe.begone
61 notes
·
View notes
Text
Feeling inspired by a post I saw a few months ago, I programmed a simple game of tic-tac-toe in python, in a single expression. Like regular functional programming, this means I can't mutate variables. But more than functional programming, this also means I can't
Declare variables at all
Declare functions
Use most loops and branch structures
The resulting program is 1730 characters long after removing all the non-strictly necessary whitespace and contains "lambda" 9 times.
The players are asked where they want to play using a number for each cell, in the configuration of a standard numpad. The program checks for invalid input too.
Source code under the cut
(lambda grid,toggle,players,cells_filled,print_grid,check_victory,ask_xy,validate_input,the_game:(lambda victor:print('=====\n'+('Draw.'if victor is None else f"{victor} wins!")))(the_game(grid,players,cells_filled,toggle,print_grid,check_victory,ask_xy,validate_input,the_game)))([[7,8,9],[4,5,6],[1,2,3]],True,['X','O'],0,lambda grid:print('\n'+'\n'.join(' '.join(map(str,ligne))for ligne in grid)),lambda grid,players:([player for player in players if any(set(grid[i][col]for i in[0,1,2])=={player}for col in[0,1,2])or any(set(grid[row])=={player}for row in[0,1,2])or set(grid[i][i]for i in[0,1,2])=={player}or set(grid[i][2-i]for i in[0,1,2])=={player}]+[None])[0],lambda players,toggle,grid,ask_xy,validate_input:validate_input(input(f"{players[toggle]}, place your symbol: "),grid,players,toggle,ask_xy,validate_input),lambda selection,grid,players,toggle,ask_xy,validate_input:(lambda selection,grid,players,toggle,ask_xy,validate_input:(selection%3,2-selection//3)if grid[2-selection//3][selection%3]not in players else ask_xy(players,toggle,grid,ask_xy,validate_input))(int(selection)-1,grid,players,toggle,ask_xy,validate_input)if len(selection)==1 and'0'<selection<='9'else ask_xy(players,toggle,grid,ask_xy,validate_input),lambda grid,players,cells_filled,toggle,print_grid,check_victory,ask_xy,validate_input,the_game:(print_grid(grid),the_game((lambda players,toggle,xy,grid:[[players[not toggle]if(j,i)==xy else grid[i][j]for j in[0,1,2]]for i in[0,1,2]])(players,toggle,ask_xy(players,not toggle,grid,ask_xy,validate_input),grid),players,cells_filled+1,not toggle,print_grid,check_victory,ask_xy,validate_input,the_game)if check_victory(grid,players)is None and cells_filled<9 else check_victory(grid,players))[1])
If you can't read any of this, don't worry, I can't either.
You can find the original code and a slightly more readable version on my gitlab: https://gitlab.com/Rijaja/gaae/-/tree/main/tttaae (but careful, the game is in French)
96 notes
·
View notes
Text
I'm gonna start working on my sims 4 radqueer script mod again
#we'll see how far my lack of coding skills goes#there's an app that makes it easy#unfortunately it can't be as complex as I want it to be unless I gain the executive function to learn python :(#edit is I Forgor about this but I don't have time anymore#one day...
15 notes
·
View notes
Text
I am writing in python rather than the pre 89 C shitshow at work right now..
And... I am just enjoying mixing function and object oriented design. Procedural mixed with imperative.
Just... making complex machines by swimming through the wonderfull sea of code in a modern langauge
9 notes
·
View notes
Text
i've spent 1.5 years studying and achieving a level of C/C++ literacy to go to a class, which is really cool, basis of machine learning and genetic based algorithms and i am a sucker for biology but we're applying those in python. what sucks is that now my brain and hands literally itch to put semicolons and curly brackets and indent the code to my needs and implement methods and functions when python doesn't even use those :( and now i can do more powerful things but the code looks like we've just discovered how to paint caves with our fingers
#personal ramblings you can totally skip#but it's bugging me a lot#and i know python is a great way as an outsider to get into coding and do some really cool stuff because it has a lot of built in libraries#and the syntax is closer to english than most coding languages#but it's a bit frustrating to me and i lose time trying to rephrase what i've learned so far#the only advantage so far is that instead of writing like 3 different functions for a vector in c/c++#i only use like 3 lines of code in python for the same things#my frustrations could also be from the fact that i went to this class where we used python straight from a 3 hour class where we used c
4 notes
·
View notes
Text
python baby PLEEEEAAAAASEEEEE add generics. it would make my typehinting life SOOOOOO much easier
#programming#python#still haven't found a type checker that doesn't flag my code as “possibly incorrect” because pandas and numpy and stuff love to have like#seventeen different possible return types for a given function#and I don't want them doing static analysis on the whole library because that's why pylyzer has stack overflows out the ass
5 notes
·
View notes
Text
speaking as a previous learner of C, THIS IS THE ONE MOST BEAUTIFUL THING I'VE EVER SEEN

#you can!! chain functions!! on a string!! and it works!! it doesn't throw a tantrum!! it's ok with it!! it loves you!!#python is my beautiful sister and i am playing around with all of her functions in an open field#🌙rambling#no id#🌙computerposting#//edit: YOU CAN JUST DO IT ALL ON THE SAME LINE YOU FIRST GET THE VARIABLE!!!?!#is it ok if i die on your carpet
7 notes
·
View notes
Text
I have a new idea for the wip list that will likely actually get made at some point, but I need to learn programming in Python first smh my head
#i'm fairly decent at web dev coding already and i've heard python is pretty easy to learn#which i hope so because i tried programming basic site functions with JS and it made me want to eat my keyboard#anyways i'm not touching this for a little while. i just wanted to speak it into the world so i dont forget (permanently lol)#elkk.txt
5 notes
·
View notes
Text
This morning I misread the theorem on the board and thought it said subset instead of subspace, which was rather troubling since we used convexity in the argument. Naturally, I ask what guarantees convexity and the professor pointed out subspace so cool. Great.
But he also said "where did you pick that up? Off the street?"
Because yeah, you can use a convex set instead of subspace. But it was such an unexpected question, phrased in such an unexpected way.
#the theorem is the metric based on the min distance between a point and a closed subspace#i do remember proving the closed convex set version once on a hw assignment (differential topology class) and it was a nightmare#seven stories#functional#DEs was also confusing and all over the place today#we were doing some matlab stuff but mostly listend/watched him? but most of us had our laptops out#which was great for me cause i was running a python script all day so I was able to fix a mistake on the input txt file during class#and start the script again#i also just like. did the entire cosing problem from the hw during class. it took like 5 min
4 notes
·
View notes
Text
it may surprise you to know that i AM in fact attempting to start my homework but i got carried away trying to read an article about wave function collapse algorithms
2 notes
·
View notes