0% found this document useful (0 votes)
4 views4 pages

Complete Coding Cheat Sheets Python HTML Luau

The document contains cheat sheets for Python, HTML, and Luau (Roblox), providing essential syntax and examples for each programming language. It covers topics such as printing, variables, operators, conditions, loops, lists, dictionaries, functions, and classes for Python; basic HTML structure and elements; and Lua scripting for Roblox including functions, conditions, loops, and event handling. Each section includes code snippets to illustrate the concepts clearly.

Uploaded by

yahyayafi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Complete Coding Cheat Sheets Python HTML Luau

The document contains cheat sheets for Python, HTML, and Luau (Roblox), providing essential syntax and examples for each programming language. It covers topics such as printing, variables, operators, conditions, loops, lists, dictionaries, functions, and classes for Python; basic HTML structure and elements; and Lua scripting for Roblox including functions, conditions, loops, and event handling. Each section includes code snippets to illustrate the concepts clearly.

Uploaded by

yahyayafi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Complete Coding Cheat Sheets

Includes: Python • HTML • Luau (Roblox)


■ PYTHON CHEAT SHEET

# PRINT
print("Hello World")

# VARIABLES
name = "Yahya"
age = 14
pi = 3.14
is_student = True

# OPERATORS
+ - * / // % **

# CONDITIONS
if age > 18:
print("Adult")
elif age == 18:
print("Exactly 18")
else:
print("Minor")

# LOOPS
for i in range(5):
print(i)

while age < 18:


age += 1

# LISTS
numbers = [1, 2, 3]
[Link](4)
[Link](2)
print(numbers[0])

# DICTIONARIES
student = {"name": "Yahya", "grade": 8}
print(student["name"])

# FUNCTIONS
def greet(name):
return "Hello " + name

# CLASSES
class Player:
def __init__(self, name):
[Link] = name

def speak(self):
print("Hi, I'm", [Link])
■ HTML CHEAT SHEET

<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>

<h1>Main Heading</h1>
<h2>Sub Heading</h2>

<p>This is a paragraph.</p>

<a href="[Link]

<img src="[Link]" alt="Image">

<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>

<ol>
<li>First</li>
<li>Second</li>
</ol>

<div>
<p>Container</p>
</div>

<form>
<input type="text" placeholder="Enter name">
<button>Submit</button>
</form>

</body>
</html>
■ LUAU (ROBLOX) CHEAT SHEET

-- PRINT
print("Hello Roblox")

-- VARIABLES
local name = "Player"
local score = 0

-- FUNCTIONS
local function greet(playerName)
return "Hello " .. playerName
end

-- CONDITIONS
if score > 10 then
print("Winner!")
elseif score == 10 then
print("Almost!")
else
print("Keep trying!")
end

-- LOOPS
for i = 1, 5 do
print(i)
end

-- TABLES
local player = {
Name = "Yahya",
Level = 1
}

-- ACCESSING OBJECTS
local part = [Link]
[Link] = [Link]("Bright red")

-- EVENTS
[Link]:Connect(function(player)
print([Link] .. " joined!")
end)

Common questions

Powered by AI

HTML manages user input with form elements, such as 'input type="text"', capturing user data for submission . Python captures user input with built-in functions like 'input()', allowing the program to process user-entered data during execution [not explicitly in Source 1]. HTML focuses on web-based GUI input, while Python collects data within executed scripts, emphasizing different use contexts.

In Python, conditions are implemented using 'if', 'elif', and 'else' statements to check conditions such as if a person is a minor, exactly 18, or an adult based on age. Similarly, in Luau, conditions use 'if', 'elseif', and 'else' to decide outputs based on the score, such as printing 'Winner!' if the score is greater than 10, 'Almost!' if it equals 10, or 'Keep trying!' otherwise . However, their syntax differs slightly due to language design, such as the use of a different concatenation operator for strings.

Python lists support dynamic resizing and a range of methods like 'append()' and 'remove()' for adding or removing elements, facilitating flexible data handling . Luau tables also support dynamic data manipulation but can additionally mimic arrays and hash tables due to their versatile design . Python lists focus on element-order manipulation efficiency, while Luau tables offer broader structural configurations, enhancing adaptability for complex data operations.

Python implements loops primarily using 'for' and 'while', allowing iteration over a sequence or until a condition is met. For example, 'for i in range(5):' iterates five times from 0 to 4 . Luau uses 'for i = 1, 5 do' to iterate from 1 to 5 inclusive, similar to a for-loop in other programming languages . Both languages ensure iteration by controlling the loop counter or condition that dictates the cycle through elements.

Python offers a variety of operators for arithmetic, such as '+', '-', '*', '/', '//', '%', and '**' for addition, subtraction, multiplication, division, integer division, modulus, and exponentiation, respectively . For example, 'pi = 3.14' uses '=' to assign, while 'if age > 18:' demonstrates comparison operators. These allow developers to perform complex calculations and logic within conditional and iterative structures efficiently.

Python uses dictionaries which are collections of key-value pairs; data is stored and accessed using unique keys. For example, a student's name is accessed using 'student["name"]' . In Luau, tables can store similar data structures with keys and values, such as 'player = { Name = "Yahya", Level = 1 }', where accessing 'player.Name' retrieves the player's name . Both structures allow efficient data look-up using keys, but tables in Luau are more versatile, supporting array-like and hash-map configurations.

Python implements OOP using classes to define blueprints of objects. The 'class' keyword defines a class, and an '__init__' method initializes instance variables. For example, the 'Player' class has an '__init__' that accepts 'name' and assigns it to 'self.name', and a 'speak' method to say 'Hi' with the player's name . This approach encapsulates data and behaviors, enabling code reuse and modularity.

In Luau, events are vital for responding to user interactions asynchronously. The 'game.Players.PlayerAdded:Connect(function(player)' listens for when a player joins and executes attached code, like printing the player's name . Events create dynamic, responsive applications by executing specific actions in response to user or system actions, facilitating interactive gameplay experiences.

HTML elements create the foundational structure of a webpage. 'head' contains 'title', defining the page's title. Body elements like 'h1' and 'h2' create headings for hierarchy. Paragraphs ('p') add text, while 'a' links to external resources. Lists ('ul', 'ol') organize information. The 'div' groups elements, often for styling. Forms, such as 'input' and 'button', allow user interaction . These elements structure content logically and semantically, enhancing user navigation.

In Python, functions are defined using the 'def' keyword, with parameters listed within parentheses, such as 'def greet(name):'. The return statement sends back data from the function . Luau defines functions using the 'function' keyword and uses '..' for string concatenation, for example, 'local function greet(playerName) return "Hello " .. playerName end' . Both handle parameters similarly by taking inputs at runtime, but their syntax in declaration differs slightly.

You might also like