Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed some errors #4

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion 1.2 variables & types/Python.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ You dont have ro declare a the type of variable Python will automatically. The m
## 1.3 Basic Arithmetic

Heres the basic arithmetics python accepts:
- Addition (+)

- Addition (+)

- Subtraction (-)
- Multiplication (*)
Expand Down
4 changes: 3 additions & 1 deletion 2.1-4 ControlFlow.md/2.1 Conditionals.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 2.1
## If, Elif, Else

## If, Elif, Else

__You can use if, elif (short for “else if”), and else to perform different actions based on certain conditions.__

**Here’s a simple example:**
Expand Down
12 changes: 10 additions & 2 deletions 2.1-4 ControlFlow.md/2.2 Lists.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# 2.2
# 2.2

## Lists
A list in Python is a changeable ordered sequence of elements. Each value/ element inside a list is considered a item.

A list in Python is a changeable ordered sequence of elements. Each value/ element inside a list is considered a item.

````python
fruits = ["apple", "grapes", "banana"]
````

You can access items in a list by referring to their index number, starting at 0.

````python

print(fruits[0]) # apple
````

````python
print(friuts[1]) # grapes
````

````python
print(fruits[2]) # banana
````
6 changes: 6 additions & 0 deletions 2.1-4 ControlFlow.md/2.3 Loops.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# 2.3

## Loops

### The for loops

For loop in Python iterates over an iterable object such as a list:

````python
for fruit in fruits:
print(fruit)
````

### The While Loop

A while loop continues to execute as long as a certain condition is true:

````python
Expand Down
7 changes: 5 additions & 2 deletions 2.1-4 ControlFlow.md/2.4 Functions.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# 2.4

## Functions

Functions in Python are defined using the def keyword. For example, a function that adds two numbers might look like this:

````python
def add(x, y):
return x + y
````

You can call this function using its name followed by its arguments in parentheses:

````python
print(add(3, 4)) # Outputs: 7
````

````
3 changes: 3 additions & 0 deletions 2.1-4 ControlFlow.md/Exercises.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

# Exercises

1. Write an if-elif-else statement for evaluating a variable called grade.
2. Create a list of your three favorite foods, then write a for loop that prints each food on a new line.
3. Write a while loop that prints the numbers from 0 to 9.
Expand Down
4 changes: 3 additions & 1 deletion 3.1-4DataStructers.md/3.1 Tuples.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 3.1

## Tuples

tuple in Python is similar to a list. The key difference is that tuples are immutable, meaning they cannot be changed after they are created

````python
person = ("Alice", 30, "New York")
````

12 changes: 11 additions & 1 deletion 3.1-4DataStructers.md/3.2 dictionaries.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# 3.2
## Dictionaries


## Dictionaries



A dictionary is a mutable data type that stores keys: values pairs. Here’s an example:


````python
person_dict = {"name": "Alice", "age": 30, "city": "New York"
````

By referring to the key name you can access the items within a dictionary:


````python
print(person_dict["name"]) # Alice
````
8 changes: 7 additions & 1 deletion 3.1-4DataStructers.md/3.3 Sets.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 3.3

## Sets
A set is an unordered collection of unique elements.


A set is an unordered collection of unique elements.
It can be used to remove duplicate values from a list, among other things:


````python

fruits = {"apple", "banana", "cherry", "apple"}
print(fruits) # {'apple', 'cherry', 'banana'}
````
5 changes: 4 additions & 1 deletion 3.1-4DataStructers.md/3.4 Exception Handling.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# 3.4
## Exception Handling

## Exception Handling

Python uses exceptions to handle errors that occur at runtime.
You can use a try/except block to catch exceptions and prevent your program from crashing:

````python
try:
print(10 / 0)
Expand Down
2 changes: 2 additions & 0 deletions 3.1-4DataStructers.md/Exercises.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Exercises

1. Create a tuple containing three elements of different types.
2. Create a dictionary that maps your favorite things to a list of your top three of each.
3. Convert a list with duplicate elements to a set.
Expand Down
2 changes: 2 additions & 0 deletions 4.1-3 File IO.md/4.1 file IO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 4.1

## File I/O

Python provides built-in functions for creating, reading, updating, and deleting files.

Here’s how you might create a new file and write some text to it:
Expand Down
3 changes: 3 additions & 0 deletions 4.1-3 File IO.md/4.2 modules.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# 4.2

## Modules

a file containing a set of functions that you can include in your application. There are numerous built-in modules in Python, which you can import using the import keyword.

Here’s how you might use the random module to generate a random number:

````python

import random
Expand Down
6 changes: 5 additions & 1 deletion 4.1-3 File IO.md/4.3 packages.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# 4.3
## Packages

## Packages

package in Python is a way of organizing related modules into a directory hierarchy. For example, a package might include a collection of modules for handling HTTP requests, processing text, or connecting to a database.

To use a package, you’ll first need to install it (if it’s not part of the Python standard library) using pip:

````python
pip install requests
````

You can then import the package or specific components from it:

````python
import requests
response = requests.get("https://www.example.com")
Expand Down
2 changes: 2 additions & 0 deletions 4.1-3 File IO.md/Exercises.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Exercises

1. Write a short text to a file, then read the file and print its contents.
2. Generate a list of 5 random numbers between 1 and 10 using the random module.
3. Use the requests package to get the content of “https://www.example.com” and print the status code.
7 changes: 6 additions & 1 deletion 5.1-2 objectoriented.md/5.1 Classes and objects.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# 5.1
## Classes and objects

## Classes and objects

almost everything is an object, with its properties and methods. A Class is like an object constructor, or a blueprint for creating objects.

Here’s an example of a class:

````python
class Person:
def __init__(self, name, age):
Expand All @@ -12,9 +15,11 @@ class Person:
def greet(self):
print(f"Hello, my name is {self.name} and I'm {self.age} years old.")
````

The __init__ method is a special method that gets called when an object is created. The self keyword refers to the instance of the class and is used to access variables that belongs to the class.

We can create an object of the Person class like this:

````python
p = Person("Alice", 30)
p.greet() # Prints: Hello, my name is Alice and I'm 30 years old.
Expand Down
5 changes: 5 additions & 0 deletions 5.1-2 objectoriented.md/5.1 classes & objects.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# 5.1

## classes and objects

almost everything is an object, with its properties and methods. A Class is like an object constructor, or a blueprint for creating objects.

Here’s an example of a class:

````python
class Person:
def __init__(self, name, age):
Expand All @@ -12,9 +15,11 @@ class Person:
def greet(self):
print(f"Hello, my name is {self.name} and I'm {self.age} years old.")
````

The __init__ method is a special method that gets called when an object is created. The self keyword refers to the instance of the class and is used to access variables that belongs to the class.

We can create an object of the Person class like this:

````python
p = Person("Alice", 30)
p.greet() # Prints: Hello, my name is Alice and I'm 30 years old.
Expand Down
6 changes: 5 additions & 1 deletion 5.1-2 objectoriented.md/5.2 inheritance.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# 5.2
# Inheritance

## Inheritance

allows us to define a class that inherits all the methods and properties from another class.

The class from which properties and methods are inherited is called the parent class, and the class that inherits from the parent class is called the child class.

Here’s an example:

````python
class Student(Person):
def __init__(self, name, age, grade):
Expand All @@ -14,5 +17,6 @@ class Student(Person):
def introduce(self):
print(f"Hello, my name is {self.name}, I'm {self.age} years old and I'm in grade {self.grade}.")
````

In this example, Student is a child class that inherits from the Person parent class.
The super().__init__(name, age) call is used to call the __init__ method of the parent class.
2 changes: 2 additions & 0 deletions 5.1-2 objectoriented.md/Exercises.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Exercises

1. Create a Car class with properties like brand, model, and year, and methods to perform operations like start and stop.
2. Create an object of your Car class and call its methods.
3. Create a Tesla class that inherits from your Car class. Add an additional property like autopilot and an additional method to activate it.
5 changes: 5 additions & 0 deletions 6.1-3Libraries.md/6.1 Standard Library.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# 6.1

## Python Standard Library

is a collection of modules that provides implementations of common functionalities and allows you to perform a variety of tasks without the need to install any additional libraries.

For example, the math module provides mathematical functions:

````python
import math

print(math.sqrt(16)) # Prints: 4.0
````

The datetime module provides functions for manipulating dates and times:

````python
import datetime

Expand Down
3 changes: 3 additions & 0 deletions 6.1-3Libraries.md/6.2 APIs.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# 6.2

## Working with APIs

Application Programming Interfaces, are a set of rules and protocols for building and interacting with software applications. APIs can be used to interact with other software components.

Here’s a simple example using the requests module to fetch data from a web API:

````python
import requests

Expand Down
3 changes: 3 additions & 0 deletions 6.1-3Libraries.md/6.3 Databases.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 6.3

## Databases

Python provides several libraries to connect to and interact with databases. SQLite is a simple file-based database included in Python’s standard library:

````python
import sqlite3

Expand Down
2 changes: 2 additions & 0 deletions 6.1-3Libraries.md/Exercises.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Exercises

1. Use the math module to calculate the factorial of a number.
Use the datetime module to get the current date and time and format it in the ‘YYYY-MM-DD HH:MM:SS’ format.
2. Use the requests module to fetch data from ‘https://jsonplaceholder.typicode.com/posts’ and print the title of each post.
Expand Down
10 changes: 6 additions & 4 deletions Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ we can use many features such as decorator, annotation, docstrings, default
arguments and so on to define a function. In this cheat sheet, it collects
many ways to define a function and demystifies some enigmatic syntax in functions.


.. contents:: Table of Contents
:backlinks: none

Functions

------------------
Documentation provides programmers hints about how a function is supposed to
be used. A docstring gives an expedient way to write a readable document of
Expand All @@ -29,9 +29,8 @@ format of docstrings.
...
>>> example.__doc__
'This is an example function.'
>>> help(example)
>>> help(example)


Option Arguments
----------------

Expand All @@ -57,7 +56,9 @@ Unpack Arguments
...
>>> foo(*("FOO", "BAR"), **{"c": "baz"})
FOO BAR baz

Keyword-Only Arguments

----------------------

**New in Python 3.0**
Expand All @@ -72,7 +73,8 @@ Keyword-Only Arguments
>>> f(1, 2, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() takes 2 positional arguments but 3 were
TypeError: f() takes 2 positional arguments but 3 were

Annotations
-----------

Expand Down
4 changes: 2 additions & 2 deletions HTML/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Code Guide</title>
<title>Code Guide As CoWik</title>
<link rel="stylesheet" href="./style.css">
<link rel="icon" href="./favicon.ico" type="image/x-icon">
</head>
<body>
<main>
<h1>Welcome to The Code Guide</h1>
<h1>Welcome to The Code Guide As CoWik </h1>
</main>
<script src="index.js"></script>
</body>
Expand Down
4 changes: 1 addition & 3 deletions HTML/Santax.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Syntax
## To sum HTML up in one word I would say ELEMENTS!!
<p>All languanges technicallg have syntax. </p>
# Syntax ALL languanges have syntax. </p>
<p>HTML is a collection of elements. A combination of elements are used to build a webpage.</p>
Loading