Skip to content

Commit af88033

Browse files
committed
Initial commit
1 parent f876dc1 commit af88033

File tree

3,195 files changed

+442177
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,195 files changed

+442177
-11
lines changed

Generic programming/CAT/001.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
total = 0
3+
4+
for num in range(1, 4):
5+
total += num
6+
7+
print(total)
8+
9+
for num in range(0, 20, 5):
10+
num += num
11+
12+
print(num)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
3+
"""
4+
Python classes small notes
5+
6+
sytax
7+
class ClassName:
8+
block of code
9+
10+
The self parameter method defination is required in after declaring a class name
11+
It is an equivalent of 'this' in Java
12+
13+
Initializer method, It is an equivalent of a constructor in Java
14+
systax => def __init__ (self)
15+
"""
16+
17+
# Example
18+
19+
import random
20+
21+
def main():
22+
23+
c = Card()
24+
c.selectAtRandom()
25+
print(c)
26+
27+
class Card:
28+
29+
def __init__(self, rank="", suit=""):
30+
31+
self._rank = rank
32+
self._suit = suit
33+
34+
def selectAtRandom(self):
35+
ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9]
36+
37+
self._rank = random.choice(ranks)
38+
self._suit = random.choice(["Red", "Blue", "Green", "Yellow", "Orange"])
39+
40+
def __str__(self):
41+
42+
return (f"{self._rank} of {self._suit}")
43+
44+
main()

Generic programming/Lab1/001.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
determines whether all the numbers are different from each other.
55
'''
66

7+
# Define a function
8+
def sequence_of_numbers():
9+
list_of_numbers = [1, 2, 3, 4, 5, 5]
710

8-
def is_all_number_unique(numbers):
9-
print(len(numbers) == len(set(numbers)))
11+
if len(list_of_numbers) == set(list_of_numbers):
12+
print("Numbers are unique")
13+
14+
else:
15+
print("Numbers are not unique")
1016

11-
12-
sequence = [1, 2, 3, 4, 5, 2]
13-
14-
is_all_number_unique(sequence)
17+
# Call the function
18+
sequence_of_numbers()

Generic programming/Lab1/002.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,3 @@
1616

1717
for word, frequence in words_frequencies.items():
1818
print(f"{word}: {frequence}")
19-
20-
21-
22-
23-

Projects/Calculator/icon.png

40.2 KB
Loading

Projects/Calculator/logo.png

13.6 KB
Loading

Projects/Calculator/main.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from kivy.app import App
2+
from kivy.uix.boxlayout import BoxLayout
3+
from kivy.uix.button import Button
4+
from kivy.uix.textinput import TextInput
5+
6+
class CalculatorApp(App):
7+
def build(self):
8+
self.operators = ["/", "*", "+", "-"]
9+
self.last_was_operator = None
10+
self.icon = "icon.png"
11+
12+
# Main layout
13+
layout = BoxLayout(orientation='vertical')
14+
15+
# Display
16+
self.input_box = TextInput(
17+
multiline=False,
18+
readonly=True,
19+
halign='right',
20+
font_size=55,
21+
background_color=(0.2, 0.2, 0.2, 1),
22+
foreground_color=(1, 1, 1, 1)
23+
)
24+
layout.add_widget(self.input_box)
25+
26+
# Button layout
27+
buttons = [
28+
['7', '8', '9', '/'],
29+
['4', '5', '6', '*'],
30+
['1', '2', '3', '-'],
31+
['C', '0', '=', '+']
32+
]
33+
34+
for row in buttons:
35+
h_layout = BoxLayout()
36+
for label in row:
37+
button = Button(text=label, pos_hint={'center_x': 0.5, 'center_y': 0.5}, font_size=32)
38+
button.bind(on_press=self.on_button_press)
39+
h_layout.add_widget(button)
40+
layout.add_widget(h_layout)
41+
42+
return layout
43+
44+
def on_button_press(self, instance):
45+
current = self.input_box.text
46+
button_text = instance.text
47+
48+
if button_text == 'C':
49+
self.input_box.text = ''
50+
elif button_text == '=':
51+
try:
52+
self.input_box.text = str(eval(current))
53+
except Exception:
54+
self.input_box.text = 'Error'
55+
else:
56+
if current and (self.last_was_operator and button_text in self.operators):
57+
return
58+
elif current == '' and button_text in self.operators:
59+
return
60+
61+
new_text = current + button_text
62+
self.input_box.text = new_text
63+
self.last_was_operator = button_text in self.operators
64+
65+
if __name__ == "__main__":
66+
app = CalculatorApp()
67+
app.run()
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Authors & Contributors of the Kivy Framework
2+
============================================
3+
4+
Core Developers
5+
---------------
6+
7+
* Mathieu Virbel <mathieu __at__ kivy.org>
8+
* Gabriel Pettier / tshirtman <gabriel __at__ kivy.org>
9+
* Akshay Arora <akshay __at__ kivy.org>
10+
* Thomas-Karl Pietrowski <thopiekar __at__ gmail.com>
11+
* Ben Rousch <brousch __at__ gmail.com>
12+
* Jacob Kovac <kovac1066 __at__ gmail.com>
13+
* Alexander Taylor <alexanderjohntaylor __at__ gmail.com>
14+
* Matthew Einhorn <moiein2000 __at__ gmail.com>
15+
* Richard Larkin / ZenCODE <zenkey.zencode __at__ gmail.com>
16+
* Ryan Pessa <dkived __at__ gmail.com>
17+
* Sebastian Armin <dessant __at__ kivy.org>
18+
* Peter Badida <keyweeusr __at__ gmail.com>
19+
20+
21+
Contributors
22+
------------
23+
24+
* Ilya Cassina <ilya.cassina __at__ gmail.com>
25+
* Jay Bradley <j.bradley __at__ napier.ac.uk>
26+
* Nathanaël Lécaudé <lecaude __at__ gmail.com>
27+
* Sharath Patali <sharath.patali __at__ gmail.com>
28+
* Tommaso Piazza <tommaso.piazza __at__ gmail.com>
29+
* Trevor Lockley <thatsyouremail __at__ gmail.com>
30+
* bernt
31+
* Terje Skjaeveland (bionoid)
32+
* George Sebastian (georgs)
33+
* Gabriel Ortega
34+
* Arnaud Waels (triselectif)
35+
* Thomas Hirsch
36+
* Joakim Gebart
37+
* Rosemary Sebastian
38+
* Jonathan Schemoul
39+
* Sam Brotherton (sbrother)
40+
41+
42+
Graphics
43+
--------
44+
45+
* Vincent Autin <autinvincent __at__ gmail.com>
46+
47+
48+
Special Thanks
49+
--------------
50+
51+
* Alex Teiche <xelapond __at__ gmail.com>
52+
* Felipe Moura <felipe.celer __at__ gmail.com>
53+
* Riley Dutton <rileydutton __at__ gmail.com>
54+
* Uday Karan <uday.karan __at__ gmail.com>
55+
* Damien Marchal <damien.marchal __at__ lifl.fr>
56+
* Tommy Bjorling <tommy.bjorling __at__ gmail.com>
57+
58+
59+
Past Core Developers
60+
--------------------
61+
62+
* Thomas Hansen <thomas __at__ kivy.org>
63+
* Christopher Denter <christopher __at__ kivy.org>
64+
* Edwin Marshall <edwin __at__ kivy.org>
65+
* Jeff Pittman <geogeff __at__ geogeff.org>
66+
* Brian Knapp <knapp __at__ kivy.org>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2010-2024 Kivy Team and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

0 commit comments

Comments
 (0)