Uploaded July 2024 | Updated September 2026, 1 week ago
#pythontutorial #python #pythonprogramming
# PyQt5 Layout Managers
import sys
from PyQt5.QtWidgets import (QApplication, QMainWindow, QLabel, QWidget, QVBoxLayout, QHBoxLayout, QGridLayout)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(700, 300, 500, 500)
self.initUI()
def initUI(self):
central_widget = QWidget()
self.setCentralWidget(central_widget)
label1 = QLabel("#1")
label2 = QLabel("#2")
label3 = QLabel("#3")
label4 = QLabel("#4")
label5 = QLabel("#5")
label1.setStyleSheet("background-color: red;")
label2.setStyleSheet("background-color: yellow;")
label3.setStyleSheet("background-color: green;")
label4.setStyleSheet("background-color: blue;")
label5.setStyleSheet("background-color: purple;")
# VERTICAL LAYOUT
# -----------------
# vbox = QVBoxLayout()
# vbox.addWidget(label1)
# vbox.addWidget(label2)
# vbox.addWidget(label3)
# vbox.addWidget(label4)
# vbox.addWidget(label5)
# central_widget.setLayout(vbox)
# HORIZONTAL LAYOUT
# -----------------
# hbox = QHBoxLayout()
# hbox.addWidget(label1)
# hbox.addWidget(label2)
# hbox.addWidget(label3)
# hbox.addWidget(label4)
# hbox.addWidget(label5)
# central_widget.setLayout(hbox)
# GRID LAYOUT
# -----------------
grid = QGridLayout()
grid.addWidget(label1, 0, 0)
grid.addWidget(label2, 0, 1)
grid.addWidget(label3, 1, 0)
grid.addWidget(label4, 1, 1)
grid.addWidget(label5, 1, 2)
central_widget.setLayout(grid)
def main():
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
if ___name___ == "__main__":
main()
#pythontutorial #python #pythonprogramming
# PyQt5 Layout Managers
import sys
from PyQt5.QtWidgets import (QApplication, QMainWindow, QLabel, QWidget, QVBoxLayout, QHBoxLayout, QGridLayout)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(700, 300, 500, 500)
self.initUI()
def initUI(self):
central_widget = QWidget()
self.setCentralWidget(central_widget)
label1 = QLabel("#1")
label2 = QLabel("#2")
label3 = QLabel("#3")
label4 = QLabel("#4")
label5 = QLabel("#5")
label1.setStyleSheet("background-color: red;")
label2.setStyleSheet("background-color: yellow;")
label3.setStyleSheet("background-color: green;")
label4.setStyleSheet("background-color: blue;")
label5.setStyleSheet("background-color: purple;")
# VERTICAL LAYOUT
# -----------------
# vbox = QVBoxLayout()
# vbox.addWidget(label1)
# vbox.addWidget(label2)
# vbox.addWidget(label3)
# vbox.addWidget(label4)
# vbox.addWidget(label5)
# central_widget.setLayout(vbox)
# HORIZONTAL LAYOUT
# -----------------
# hbox = QHBoxLayout()
# hbox.addWidget(label1)
# hbox.addWidget(label2)
# hbox.addWidget(label3)
# hbox.addWidget(label4)
# hbox.addWidget(label5)
# central_widget.setLayout(hbox)
# GRID LAYOUT
# -----------------
grid = QGridLayout()
grid.addWidget(label1, 0, 0)
grid.addWidget(label2, 0, 1)
grid.addWidget(label3, 1, 0)
grid.addWidget(label4, 1, 1)
grid.addWidget(label5, 1, 2)
central_widget.setLayout(grid)
def main():
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
if ___name___ == "__main__":
main()

![Java printf() is really useful! 🖨️
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args) {
// printf() is a method used to format output
// % [flags] [width] [.precision] [specifier-character]
// [specifier-character]
String name = Spongebob;
char firstLetter = S;
int age = 30;
double height = 60.5;
boolean isEmployed = true;
System.out.printf(Hello %sn, name);
System.out.printf(Your name starts with a %cn, firstLetter);
System.out.printf(You are %d years oldn, age);
System.out.printf(You are %f inches talln, height);
System.out.printf(Employed: %bn, isEmployed);
System.out.printf(%s is %d years old, name, age);
// [.precision]
double price1 = 9.99;
double price2 = 100.15;
double price3 = -54.01;
System.out.printf(%.3fn, price1);
System.out.printf(%.3fn, price2);
System.out.printf(%.3fn, price3);
// [flags]
// + = output a plus
// , = comma grouping separator
// ( = negative numbers are enclosed in ()
// space = display a minus if negative, space if positive
System.out.printf(%fn, price1);
System.out.printf(%fn, price2);
System.out.printf(%fn, price3);
// [width]
// 0 = zero padding
// number = right justified padding
// negative number = left justified padding
int id1 = 1;
int id2 = 23;
int id3 = 456;
int id4 = 7890;
System.out.printf(id: %04dn, id1);
System.out.printf(id: %04dn, id2);
System.out.printf(id: %04dn, id3);
System.out.printf(id: %04dn, id4);
}
} Java printf() is really useful! 🖨️](https://i.ytimg.com/vi/nTBDjxWAcoE/mqdefault.jpg)

![Learn Java overloaded methods in 6 minutes! 🍕
#java #javatutorial #javacourse
public class Main {
public static void main(String[] args){
// overloaded methods = methods that share the same name,
// but different parameters
// signature = name + parameters
String pizza = bakePizza(flat-bread, mozzarella, pepperoni);
System.out.println(pizza);
}
static String bakePizza(String bread){
return bread + pizza;
}
static String bakePizza(String bread, String cheese){
return cheese + + bread + pizza;
}
static String bakePizza(String bread, String cheese, String topping){
return topping + + cheese + + bread + pizza;
}
} Learn Java overloaded methods in 6 minutes! 🍕](https://i.ytimg.com/vi/nhnAx79gxCM/mqdefault.jpg)
![The Java Math class + exercises! 📐
#java #javatutorial #javacourse
00:00:00 intro
00:00:10 constants
00:00:57 methods
00:04:24 exercise1
00:08:27 exercise2
00:13:25 printf
public class Main {
public static void main(String[] args) {
System.out.println(Math.PI);
System.out.println(Math.E);
double result;
result = Math.pow(3, 4);
result = Math.abs(-5);
result = Math.sqrt(16);
result = Math.round(3.14);
result = Math.ceil(3.14);
result = Math.floor(3.14);
result = Math.max(10, 20);
result = Math.min(10, 20);
System.out.println(result);
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double a;
double b;
double c;
System.out.print(Enter the length of side A: );
a = scanner.nextDouble();
System.out.print(Enter the length of side B: );
b = scanner.nextDouble();
c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
System.out.println(The hypotenuse is: + c + cm);
scanner.close();
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// circumference = 2 * Math.PI * radius;
// area = Math.PI * Math.pow(radius, 2);
// volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3)
Scanner scanner = new Scanner(System.in);
double radius;
double circumference;
double area;
double volume;
System.out.print(Enter the radius: );
radius = scanner.nextDouble();
circumference = 2 * Math.PI * radius;
area = Math.PI * Math.pow(radius, 2);
volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);
System.out.printf(The circumference is: %.1fcmn, circumference);
System.out.printf(The area is: %.1fcm²n, area);
System.out.printf(The volume is: %.1fcm³n, volume);
scanner.close();
}
} The Java Math class + exercises! 📐](https://i.ytimg.com/vi/nle8CQXYhl4/mqdefault.jpg)


![Create QR codes with Python in 4 minutes! 📱
#python #coding #programming
# In a terminal: pip install qrcode[pil]
import qrcode
url = input(Enter the URL: ).strip()
file_path = qrcode.png
qr = qrcode.QRCode()
qr.add_data(url)
img = qr.make_image()
img.save(file_path)
print(QR Code was generated!) Create QR codes with Python in 4 minutes! 📱](https://i.ytimg.com/vi/pJdTyvufOdg/mqdefault.jpg)

![Learn typedef in 5 minutes! 📛
#coding #programming #cprogramming
typedef int Number;
typedef char String[50];
typedef char Initials[3];
int main() {
// typedef = reserved keyword that gives an existing datatype a nickname
// Helps simplify complex types and improves code readability
// typedef existing_type new_name;
// Example 1
Number x = 3;
Number y = 4;
Number z = x + y;
printf(%d, z);
// Example 2
String name = Bro Code;
printf(%s, name);
// Example 3
Initials user1 = BC;
Initials user2 = SS;
Initials user3 = PS;
Initials user4 = ST;
printf(%sn, user1);
printf(%sn, user2);
printf(%sn, user3);
printf(%sn, user4);
return 0;
} Learn typedef in 5 minutes! 📛](https://i.ytimg.com/vi/pNNC6WAJfdk/mqdefault.jpg)
![Learn to reshape NumPy arrays in 4 minutes! ↔️
#python #coding #numpy
# reshape() = Changes the shape of an array
# w/o altering its underlying data
# array.reshape(rows, columns)
import numpy as np
array = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
array = array.reshape(2, 6)
array = array.reshape(3, 4)
# array = array.reshape(4, 4) # Too many elements
# array = array.reshape(2, 4) # Too few elements
array = array.reshape(4, 3)
array = array.reshape(2, 2, 3) # 3D
array = array.reshape(3, 2, 2) # 3D
# -1 NumPy will automatically infer the correct size for that dimension
array = array.reshape(1, -1)
array = array.reshape(-1, 1)
print(array) Learn to reshape NumPy arrays in 4 minutes! ↔️](https://i.ytimg.com/vi/pgPwaNpC0so/mqdefault.jpg)