Refacere repo
This commit is contained in:
6
Python_module_1/README.md
Normal file
6
Python_module_1/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
cd ~ && \
|
||||
mkdir venv && \
|
||||
cd venv && \
|
||||
sudo apt install python3-venv -y && \
|
||||
python3 -m venv it_school_python && \
|
||||
source ~/venv/it_school_python/bin/activate
|
||||
15
Python_module_1/python_001.py
Normal file
15
Python_module_1/python_001.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
# declaram variabile
|
||||
numar = 25
|
||||
numar_2 = 30
|
||||
suma = numar + numar_2
|
||||
|
||||
print("Hello, World! From It_school")
|
||||
print("This is the first Python module. Va saluta Don'Python!")
|
||||
print('hello world ' * 3)
|
||||
print("variabila numar are valoarea:", numar)
|
||||
print("variabila numar_2 are valoarea:", numar_2)
|
||||
print("suma celor doua numere este:")
|
||||
print(suma)
|
||||
print("Afisam si varianta veche: suma celor doua numere este", suma)
|
||||
5
Python_module_1/python_002.py
Normal file
5
Python_module_1/python_002.py
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
varsta = input("Introduceti varsta dumneavoastra: ")
|
||||
nume = input("Introduceti numele dumneavoastra: ")
|
||||
print("Salut,", nume + "!", "Ai", varsta, "ani.")
|
||||
22
Python_module_1/python_003.py
Normal file
22
Python_module_1/python_003.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
text = "De aici incepe si aici se termina!!"
|
||||
print(text)
|
||||
print(text[0])
|
||||
print(text[1])
|
||||
print(text[2])
|
||||
print(text[-1])
|
||||
print(text[-2])
|
||||
print(text[5:11])
|
||||
|
||||
x = "It School"
|
||||
y = "Python"
|
||||
print(x + y)
|
||||
|
||||
print(len(text))
|
||||
print(find := text.find("incepe"))
|
||||
print(replace := text.replace("si", "&"))
|
||||
print(text.upper())
|
||||
print(text.lower())
|
||||
print(text.capitalize())
|
||||
print(text.count("i"))
|
||||
12
Python_module_1/python_004.py
Normal file
12
Python_module_1/python_004.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
ListaNume = ["Ion", "Gigel", "Dorel", "Maria", "Ionut"]
|
||||
print("Punem nume:", ListaNume [4])
|
||||
print("Numarul de nume din lista este:", len(ListaNume))
|
||||
print(ListaNume.count("Ion"))
|
||||
ListaNume.insert(-1, ("Ion"))
|
||||
print("Afisam lista de unme:", ListaNume)
|
||||
ListaNume.reverse()
|
||||
print("Afisam lista inversata:", ListaNume)
|
||||
ListaNume.sort()
|
||||
print("Afisam lista sortata:", ListaNume)
|
||||
7
Python_module_1/python_005.py
Normal file
7
Python_module_1/python_005.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
x = int(input("Introduceti un numar x: "))
|
||||
if x > 5:
|
||||
print("x este mai mare decat 5")
|
||||
else:
|
||||
print("x nu este mai mare decat 5")
|
||||
7
Python_module_1/python_006.py
Normal file
7
Python_module_1/python_006.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
x = int(input("Introduceti o varsta: "))
|
||||
if ((x >= 0) and (x <= 18)):
|
||||
print("Nu poti vota.")
|
||||
else:
|
||||
print("Poti vota.")
|
||||
6
Python_module_1/python_007.py
Normal file
6
Python_module_1/python_007.py
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
i = 1
|
||||
while i <= 10:
|
||||
print("Valoarea lui i este:", i)
|
||||
i += 1
|
||||
9
Python_module_1/python_008.py
Normal file
9
Python_module_1/python_008.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
x = 0
|
||||
while x < 10:
|
||||
if x == 5:
|
||||
print("Am ajuns la valoarea 5, iesim din bucla.")
|
||||
break
|
||||
print("Valoarea lui x este:", x)
|
||||
x += 1
|
||||
18
Python_module_1/python_009.py
Normal file
18
Python_module_1/python_009.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
x = 0
|
||||
while x < 10:
|
||||
if x == 5:
|
||||
print("Am ajuns la 5, iesim din bucla.")
|
||||
break
|
||||
print("Valoarea lui x este:", x)
|
||||
x += 1
|
||||
|
||||
y = 0
|
||||
while y < 10:
|
||||
y += 1
|
||||
if y == 2:
|
||||
print("Sărim peste valoarea 2.")
|
||||
continue
|
||||
print("Valoarea lui y este:", y)
|
||||
print("Am iesit din bucla.")
|
||||
18
Python_module_1/python_010.py
Normal file
18
Python_module_1/python_010.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
lista = [1, 43, 53, 67, 98]
|
||||
for i in lista:
|
||||
print(i)
|
||||
|
||||
for j in range(3):
|
||||
print(j)
|
||||
|
||||
print("-----")
|
||||
|
||||
for v in range(1, 5):
|
||||
print(v)
|
||||
|
||||
print("-----")
|
||||
|
||||
for z in range(0, 10, 3):
|
||||
print(z)
|
||||
23
Python_module_1/python_011.py
Normal file
23
Python_module_1/python_011.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
T = [
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9]
|
||||
]
|
||||
|
||||
print(T[0][0]) # 1
|
||||
print(T[1][2]) # 6
|
||||
print(T[2][1]) # 8
|
||||
|
||||
print("---")
|
||||
|
||||
for i in T:
|
||||
print(i)
|
||||
|
||||
print("---")
|
||||
|
||||
for j in T:
|
||||
for v in j:
|
||||
print(v)
|
||||
print("---")
|
||||
19
Python_module_1/python_012.py
Normal file
19
Python_module_1/python_012.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
Tuplu = ("apa","paine","suc","fructe")
|
||||
for i in Tuplu:
|
||||
print(i)
|
||||
print("--------")
|
||||
mytuples = {"brand", "model", "year"}
|
||||
for j in mytuples:
|
||||
print(j)
|
||||
print("--------")
|
||||
Mydictionary = { "cetatentie": "roman", "datanasterii": "1 Oct 1996", "inaltime": 190}
|
||||
print(Mydictionary)
|
||||
print("--------")
|
||||
for key, value in Mydictionary.items():
|
||||
print(key, ";", value)
|
||||
print("--------")
|
||||
print ("Cetatentia e:", Mydictionary["cetatentie"])
|
||||
print ("Data nasterii e:", Mydictionary["datanasterii"])
|
||||
print ("Inaltimea e:", Mydictionary["inaltime"])
|
||||
22
Python_module_1/python_013.py
Normal file
22
Python_module_1/python_013.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
def functie_test():
|
||||
print("Aceasta este o functie de test")
|
||||
|
||||
def functie_nume(nume):
|
||||
print("Numele meu este:", nume)
|
||||
|
||||
def adunare(a, b):
|
||||
return a + b
|
||||
|
||||
# creeaza o functie care primeste ca parametrii o lista si vrem sa afiseze fiecare element din lista pe o linine noua
|
||||
def afisare_lista(lista):
|
||||
for element in lista:
|
||||
print(element)
|
||||
|
||||
functie_test()
|
||||
functie_nume("Andrei")
|
||||
print("Suma este:", adunare(5, 7))
|
||||
|
||||
lista_de_test = [100, 200, 300, 400]
|
||||
afisare_lista(lista_de_test)
|
||||
15
Python_module_1/python_014.py
Normal file
15
Python_module_1/python_014.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
mynumber = 3
|
||||
mystring = "Salutare"
|
||||
mylist = [10, 20, 30]
|
||||
mytuple =("a", "b", "c",43,54)
|
||||
mydictionary = {"nume":"Andrei", "varsta":43, "oras":"Bucuresti"}
|
||||
bolean_var = True
|
||||
|
||||
print(type(mynumber))
|
||||
print(type(mystring))
|
||||
print(type(mylist))
|
||||
print(type(mytuple))
|
||||
print(type(mydictionary))
|
||||
print(type(bolean_var))
|
||||
12
Python_module_1/python_015.py
Normal file
12
Python_module_1/python_015.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
import math
|
||||
|
||||
rezultat = math.sqrt(16)
|
||||
print("Radical din 16 este:", rezultat)
|
||||
print("Valoarea lui pi este:", math.pi)
|
||||
rezultat_putere = math.pow(2, 5)
|
||||
print("2 la puterea 5 este:", rezultat_putere)
|
||||
|
||||
print("Link catre match module: https://docs.python.org/3/library/math.html")
|
||||
|
||||
13
Python_module_1/python_016.py
Normal file
13
Python_module_1/python_016.py
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
class Student:
|
||||
def __init__(self, nume, varsta, nota):
|
||||
self.nume = nume
|
||||
self.varsta = varsta
|
||||
self.nota = nota
|
||||
|
||||
def display_info(self):
|
||||
print(f"Nume: {self.nume}, Varsta: {self.varsta}, Nota: {self.nota}")
|
||||
|
||||
student1 = Student("Andrei", 20, 9.5)
|
||||
student1.display_info()
|
||||
Reference in New Issue
Block a user