-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpysnippets.html
129 lines (112 loc) · 3.47 KB
/
pysnippets.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<a href="index.html">Home</a>
<a href="page2.html">Page 2</a>
<a href="pysnippets.html">Python Snippets</a>
</head>
<body>
<a href="page2.html">Page 2</a>
<a href="pysnippets.html">Pysnippets</a></li>
</ul>
</nav>
<h1>Pysnippets</h1>
<p>At Pysnippets, we believe that sharing code is a powerful tool for teaching and learning. Our snippets are designed to be easy to use and share, making them a great resource for beginners and experienced coders alike. Whether you're a beginner or an experienced programmer, we have something for everyone. With our snippets, you can learn from scratch, experiment, and share your knowledge with others. Join us on our journey to create the future of easy to use code snippets!<p>
</body>
<p>In Pysnippets you can find code snippets that you can use in your python code you can also share your snippets with others and collaborate with others. </p>
<footer>
<p>Copyright © 2023 Pysnippets</p>
</footer>
<h1>Code Snippets</h1>
<ul>
<li>
<h2>Code Snippet 1</h2>
<h6>Print</h6>
<pre><code>print("Hello, world!")</code></pre>
<h2>Code Snippet 2</h2>
<h6>Adding two numbers</h6>
<code>num1 = 5
num2 = 10
sum = num1 + num2
print(sum)</code>
<h2>Code Snippet 3</h2>
<h6> Input</h6>
<code>name = input("What is your name? ")
print("Hello, " + name + "!")</code>
<h2>Code Snippet 4</h2>
<h6>If Statement</h6>
<pre><code>num = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is even.")
</code></pre>
<h2>Code Snippet 5</h2>
<h6>Else</h6>
<pre><code>num = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is even.")
<h2>Code Snippet 5</h2>
<h6>Else If</h6>
<pre><code>num = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")</code></pre>
<h2>Code Snippet 6</h2>
<h6>Loop</h6>
<pre><code>for i in range(1, 5):
print(i)</code></pre>
<h2>Code Snippet 7</h2>
<h6>While Loop</h6>
<pre><code>i = 1
while i <= 5:
print(i)
i += 1</code></pre>
<h2>Code Snippet 8</h2>
<h6>List</h6>
<pre><code>fruits = ["apple", "banana", "cherry"]
print(fruits)</code></pre>
<h2>Code Snippet 9</h2>
<h6>Dictionary</h6>
<pre><code>fruits = {"apple": "red", "banana": "yellow", "cherry": "red"}
print(fruits["apple"])</code></pre>
<h2>Code Snippet 10</h2>
<h6>Function</h6>
<pre><code>def add(x, y):
return x + y
result = add(5, 10)
print(result)</code></pre>
<h2> Code Snippet 11</h2>
<h6>Class</h6>
<pre><code>class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def speak(self):
print("Hello, my name is " + self.name + " and I am " + str(self.age) + " years old.")
</code></pre>
<h2> Code Snippet 12</h2>
<h6>Class Inheritance</h6>
<code>class Animal:
def __init__(self, name):
self.name = name
def speak(self):
print("I am an animal and my name is " + self.name + ".")
def eat(self):
print("I am eating.")
class Dog(Animal)
def __init__(self, name, breed):
super().__init__(name)
def bark(self):
print("Woof woof!")
dog = Dog("Max", "Labrador")
dog.speak()
dog.eat()
dog.bark()</code>
<h2> Code Snippet 13</h2>
<h2> Code Snippet 14</h2>
*Coming Soon*
<h2> Code Snippet 15</h2>
*Coming Soon*
<h2> Code Snippet 16</h2>
*coming soon*