This example defines a simple route in Django that returns a welcome message. It demonstrates how Django’s URL dispatcher and view system work together to handle web requests efficiently.
Django is a powerful Python web framework designed for rapid development of secure and maintainable websites
Learn more about our open source developer community at kekoexchange.com
from django.urls import path
from django.http import HttpResponse
def home(request):
return HttpResponse("Welcome to Django!")
urlpatterns = [
path('', home),
]
// C subroutine
#include <stdio.h>
// Function to calculate the square of a number
int square(int num) {
return num * num;
}
# bash command to compile C subroutine into shared library
gcc -shared -o libsquare.so -fPIC square.c
# Python code that calls C subroutine by loading shared library
from ctypes import cdll, c_int
# Load the shared library
lib = cdll.LoadLibrary('./libsquare.so')
# Set the argument and return types
lib.square.argtypes = [c_int]
lib.square.restype = c_int
# Call the C function from Python
result = lib.square(4)
print(f"The square of 4 is {result}.")
Python code running C subroutine:
# Context Manager
class FileCloser:
def __init__(self, filename):
self.filename = filename
# Code that is executed right after the with
# statement
def __enter__(self):
self.file = open(self.filename, 'r')
return self.file
# Code that is executed right after the code block
# is executed
def __exit__(self, exc_type, exc_val, exc_tb):
self.file.close()
# Using Context Manager
with FileCloser('myfile.txt') as f:
# Your code here
pass
Text
Example of Context Managers in Python
Consistency does win the race when it comes to becoming a senior engineer.
The journey from a junior to a senior developer is paved with continuous learning and curiosity.
Staying abreast of the latest trends, tools, and technologies is crucial in the fast-evolving tech landscape.
Learn more about our SWE community at kekoexchange.com
Want to be known as a trusted engineer?
Learn to manage a project efficiently.
Nothing is more trustworthy than an engineer with a track record of delivering projects on time.
The best engineers do one thing very well:
Explain complex technology to non-technical audiences.
Clear communication demystifies technology, fostering collaboration and innovation across teams.
Intimidated by code reviews as a junior developer?
It's a growth opportunity, not a judgment.
Code reviews are a learning journey: each one makes you a better developer.
A week in
Discuss ss s
Tues - Sat: Discuss in small groups
Sun: Comment on AI powereed annotated summary of everyone's discussions
Teach and learn
adsfsadas
from collections import defaultdict
# Initialize the defaultdict
word_count = defaultdict(int)
# Efficiently count occurrences of each word
words = ['apple', 'banana', 'apple', 'pear']
for word in words:
word_count[word] += 1
Python Tip:
Use the standard library whenever you can
INFO 253A: Frontend Web Architecture
Kay Ashaolu
<ul id="todos">
<li>Task 1</li>
<li>Task 2</li>
</ul>
src/index.js
import React from "react";
import ReactDOM from "react-dom";
const jsx_element = <h1>Hello, world!</h1>;
const dom_element = document.getElementById('root');
ReactDOM.render(jsx_element, dom_element);
src/index.js
let formatName = (user) => {
return user.firstName + ' ' + user.lastName;
}
const user = {
firstName: 'Harper',
lastName: 'Perez'
};
const element = (
<h1>
Hello, {formatName(user)}!
</h1>
);
ReactDOM.render(
element,
document.getElementById('root')
);
src/index.js
import React from "react";
import ReactDOM from "react-dom";
function tick() {
const element = (
<div>
<h1>Hello, world!</h1>
<h2>It is {new Date().toLocaleTimeString()}.</h2>
</div>
);
ReactDOM.render(element, document.getElementById('root'));
}
setInterval(tick, 1000);
import React from "react";
import ReactDOM from "react-dom";
function FormatName(props) {
return (
<h1>
Hello, {props.firstName} {props.lastName}!
</h1>
);
}
ReactDOM.render(
<FormatName firstName="Kay" lastName="Ashaolu" />,
document.getElementById('root')
);
<FormatName firstName="Kay" lastName="Ashaolu" />,