with Python create a login page
def login(username, password):
if username == 'root' and password == 'root':
return True
else:
return False
login('root', 'root')
All generations.
def login(username, password):
if username == 'root' and password == 'root':
return True
else:
return False
login('root', 'root')
class Producto:
def __init__(self, codigo, nombre, precio):
self.codigo = codigo
self.nombre = nombre
self.precio = precio
def __str__(self):
return f"Codigo: {self.codigo}, Nombre: {self.nombre}, Precio: {self.precio}"
class Venta:
def __init__(self, codigo, productos):
self.codigo = codigo
self.productos = productos
class Catalogo:
def __init__(self):
self.productos = []
def agregar_producto(self, producto):
self.productos.append(producto)
def borrar_producto(self, codigo):
productos = [p for p in self.productos if p.codigo != codigo]
self.productos = productos
def buscar_producto(self, codigo):
def login(user, password):
if password is not None:
if password == 'admin':
return True
return False
login('admin', 'admin')
import json
def login():
# save data in json file
user = input('Enter user: ')
password = input('Enter password: ')
with open('user.json', 'w') as file:
json.dump({
'user': user,
'password': password
}, file)
def create_login_page():
username = input('Please enter your username')
password = input('Please enter your password')
if (username == 'admin' and password == 'admin')
return 'Login successfull'
else
return 'Login failed'
create_login_page()
def calculate_total (price, tip):
total = price + (price * tip)
print total
return total
def calculate_total (price, tip = 0.15):
total = price + (price * tip)
print total
return total
def login(users, name, passw):
if name in users:
if passw == users[name]:
return True
else:
return False
else:
return False
users = {'jack': 'pass', 'lucy': '1234'} #dictionary
login(users, 'jack', 'pass') #True
login(users, 'jack', '1234') #False
login(users, 'lucy', '1234') #True
def user_login(username, password):
if username == 'admin' and password == 'admin':
return 'welcome, admin!'
else:
return 'username or password is incorrect!'
user_login('admin', 'admin')
def producto():
producto = {}
producto["nombre"] = input("Ingrese nombre del producto")
producto["precio"] = input("ingrese precio del producto")
producto["marca"] = input("Ingrese marca del producto")
producto["codigo de barras"] = input("Ingrese codigo de barras")
producto["existencias"] = input("Ingrese existencias del producto")
return producto
def agregar_producto(productos, producto):
productos.append(producto)
return productos
def eliminar_producto(productos):
nombre = input("Ingresa el nombre del producto a eliminar: ")
for p in productos:
if p["nombre"] == nombre:
productos.remove(p)
print("Nombre eliminado")
return productos
def actualizar_producto(product
def create_login(user, password):
#this function creates a login and json file
#with the information provided
import json
f = open(str(user)+'.json','w')
dict = {}
dict['user'] = user
dict['password'] = password
json.dump(dict, f)
f.close()
create_login('juan', '1234')
import json
import os
# function to create a user
def create_user(username, password):
if os.path.exists(username + ".json"):
print("user already exists")
else:
with open(username + ".json", "w") as file:
json.dump({
"username": username,
"password": password,
"balance": 0
}, file)
# function to validate a user
def validate_user(username, password):
if os.path.exists(username + ".json"):
with open(username + ".json") as file:
data = json.load(file)
if data["password"] == password:
return True
else:
return False
else:
return False
# function to deposit money
def deposit_money(username, amount):
if os.path.exists(username + ".json"):
with open(username + ".json") as file:
data = json.load(file)
data["balance"] =
def login():
username = input('Please enter your username: ')
password = input('Please enter your password: ')
if username == 'admin' and password == 'admin':
print('Welcome!')
else:
print('Wrong username or password')
login()
Generate
More than just a code generator. A tool that helps you with a wide range of tasks. All in one place.
Function from Description
Text Description to SQL Command
Translate Languages
Generate HTML from Description
Code to Explanation
Fix invalid Code
Get Test for Code
Class from Description
Regex from Description
Regex to Explanation
Git Command from Description
Linux Command
Function from Docstring
Add typing to code
Get Language from Code
Time complexity
CSS from Description
Meta Tags from Description
− sponsored −