Skip to content

Instantly share code, notes, and snippets.

View MariusB5's full-sized avatar
🌊
Programming

Marius Liviu Briscut MariusB5

🌊
Programming
View GitHub Profile
@MariusB5
MariusB5 / pip_upgrade_all_packages.md
Last active December 6, 2023 16:01
PIP Upgrade All Packages

To view all installed packages, you can utilize either of the following commands in the Terminal:

pip list

or

pip freeze
@MariusB5
MariusB5 / py_to_exe.md
Last active January 23, 2024 16:58
Convert .py to .exe

To convert a .py file to .exe we will use PyInstaller

  1. Open the terminal and type the following command to install the PyInstaller:
pip install pyinstaller
  1. While in the terminal, navigate to the {file_name}.py file location using the cd command.
@MariusB5
MariusB5 / nth_fibonacci_number.py
Last active October 29, 2022 12:51
Determine the n-th Fibonacci number
def nth_fibonacci_number(n):
a = 0
b = 1
if n < 0:
print("Wrong number... try again")
elif n == 0:
return a
elif n == 1:
return b
else:
@MariusB5
MariusB5 / circle_area.py
Created October 28, 2022 17:52
Calculate the area of a circle with a given radius
import math
def circle_area(r):
pi = math.pi
a = pi * r ** 2
a = round(a, 2)
print(f'The area of a circle with the radius equal to {r} is ~ {a}.')
return a
@MariusB5
MariusB5 / prime_numbers.py
Last active October 28, 2022 17:53
Find the prime numbers in an interval
def prime_numbers(a, b):
i, j, prime = 0, 0, 0
list_ = []
for i in range(a, b + 1):
if i == 1:
continue
prime = 1
for j in range(2, i // 2 + 1):
@MariusB5
MariusB5 / compound_interest.py
Last active October 28, 2022 17:53
Calculate the compound interest
def compound_interest(p, r, t):
print(f"The principal is ${p}.")
print(f"The rate is {r}% per year.")
print(f"The time period is {t} years.")
a = round((p * (1 + r/100) ** t), 2)
print(f"The amount earned is ${a}")
return a
if __name__ == '__main__':
@MariusB5
MariusB5 / simple_interest.py
Last active October 28, 2022 17:53
Calculate the simple interest
def simple_interest(p, r, t):
print(f"The principal is ${p}.")
print(f"The rate is {r}% per year.")
print(f"The time period is {t} years.")
print(f"The amount earned is ${(p * r * t)/100}")
return (p * r * t)/100
if __name__ == '__main__':
p = 1000
@MariusB5
MariusB5 / largest_of_two_numbers.py
Last active October 28, 2022 17:51
Find the largest of two numbers
def largest(a, b):
if a > b:
return a
elif a == b:
return "The numbers are equal"
else:
return b
if __name__ == '__main__':
@MariusB5
MariusB5 / selenium_drag_and_drop_w_seletools.py
Last active October 17, 2022 14:35
Selenium drag and drop in Python with seletools
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from seletools.actions import drag_and_drop
s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s)
driver.get("http://the-internet.herokuapp.com/drag_and_drop")