The if statement
The if statement is used to check a condition: if the condition is true, we run a block of
statements (called the if-block), else we process another block of statements (called
the else-block). The else clause is optional.
The while statement allows you to repeatedly execute a block of statements as long
as a condition is true. A while statement is an example of what is called a looping
statement. A while statement can have an optional else clause.
The for…in statement is another looping statement which iterates over a sequence
of objects i.e. go through each item in a sequence. We will see more about sequences
in detail in later chapters. What you need to know right now is that a sequence is just
an ordered collection of items.
Twende unit tests
Si uweke collection ya izi lessons mahali nifuatilie mdogo
Boring. You don’t need to learn programing in the era of AI. Hii saa hii ni kama kutumia smoke signals. Uko nyuma sana
Apa hakuna kitu nashikanisha
Why are You Always Bitter and Negative My Friend… Ama Ni Ju You Have Nothing to Showcase… Just be Appreciative Sometimes… It Won’t Kill You…
Ni vile huna akili
Mbwaaaa
looks complex but its very easy when you run the examples Online Python Compiler
mimi nacheza chess ya 4D kama nabii, i wont go into the details. infact zile vitu nimekuwa nikipost hapa za tech have come to pass long before everyone and their mothers have jumped into the hype train, najua kire nafanya.
nyamazisha mdomo bakuli wazee wakiongea mbwa koko ghasia

I just built an entire game in less than five seconds that anyone can run and play RIGHT NOW. You’re basically a letter delivery boy in the era of email. You have a PhD in checkers when everyone has a degree in Chess. Quit now boy:
import pygame
Define colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
Define screen size
WIDTH = 400
HEIGHT = 400
Initialize Pygame
pygame.init()
Create the screen
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption(“Checkers”)
Set up the board
board = pygame.Surface((WIDTH, HEIGHT))
board.fill(WHITE)
Draw the checkers board
for i in range(8):
for j in range(8):
if (i + j) % 2 == 0:
color = BLACK
else:
color = WHITE
pygame.draw.rect(board, color, pygame.Rect(i * 50, j * 50, 50, 50))
Draw the checkers pieces
pieces = pygame.sprite.Group()
for i in range(3):
for j in range(2, 6, 2):
piece = pygame.sprite.Sprite(pieces)
piece.image = pygame.Surface((40, 40))
piece.image.fill(BLACK)
piece.rect = pygame.Rect(j * 50, i * 50, 40, 40)
Start the main loop
running = True
while running:
# Check for events
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Update the pieces
pieces.update()
# Fill the screen with white
screen.fill(WHITE)
# Draw the board and pieces
screen.blit(board, (0, 0))
pieces.draw(screen)
# Update the display
pygame.display.flip()
Quit Pygame
pygame.quit()
Kek. Python fags really have it rough. You guys have to use a boolean flag, multiple if-else statements and a while loop to simulate what in C/C++ would have been a simple do-while loop.
In C++ that whole guessing game would simply have been
#include <iostream>
#include <ctime>
int main()
{
srand(static_cast<unsigned int>(time(0)));
int answer = rand() % 100;
int guess;
do{
std::cout << "Enter an integer:\n";
std::cin >> guess;
if (guess > answer)
{
std::cout << "Too high\n";
}
else if (guess < answer)
{
std::cout << "Too low\n";
}
}while (guess != answer);
std::cout << "Correct!\n";
}
Simple as… Notice how much shorter the loop is. Python is so verbose sometimes.
Also @mundu_mulosi p̶l̶e̶a̶s̶e̶ ̶a̶d̶d̶ ̶f̶u̶n̶c̶t̶i̶o̶n̶a̶l̶i̶t̶y̶ ̶f̶o̶r̶ ̶c̶o̶d̶e̶ ̶f̶o̶r̶m̶a̶t̶t̶i̶n̶g̶.̶ Never mind.
This of an AI as a tool it can’t replace real skills
I just proved they can
maybe mediocre devs and beginners still can’t beat the creativity and initution of humans
isn’t it ironic that the same company that built chat gpt has employed programmers my point is the ai tool can’t test it self and execute it self maybe in the coming future it can




