blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
326195a3b3a25e409bc62a64f6b388a250dd3c46 | UPSD1/Temperature-Conversion-on-Python | /BaseTwotoBaseSixteen David Akinboro.py | 570 | 4.3125 | 4 | # Python Program - Convert Binary to Hexadecimal and Octal
print("This is a program converting BASE 2 to BASE 16");
print("Enter 'x' for exit.");
binary = input("Enter a number in Binary Format (1's AND 0's): ");
if binary == 'x':
exit();
else:
# converting binary to Hexadecimal using the hex built-in func... |
c2f6fd8edb701a3eba4cae7463e179c504441eb5 | pythonisfornormies/Picture | /picture.py | 2,383 | 4.125 | 4 | """
picture.py
Author: Kai Darrow
Credit: Mr Dennison, Tutorial provided
Assignment:
Use the ggame library to "paint" a graphical picture of something (e.g. a house, a face or landscape).
Use at least:
1. Three different Color objects.
2. Ten different Sprite objects.
3. One (or more) RectangleAsset objects.
4. One ... |
351e743c0fe5056be22df6e6840014e022b82a7d | johannasantos/python | /metesp.py | 452 | 3.671875 | 4 |
class C:
def __init__(self, n):
self.valor = list(range(n))
def __len__(self):
return len(self.valor)
def __add__(self, other):
return [x + other for x in self.valor]
__radd__ = __add__
def __str__(self):
return f"<ClaseLoca {self.valor}>"
# __new__
# __... |
a2d93eb10db3e9e94049130d1f3a25d15d36a5e0 | mmangelos/cmsc201 | /Labs/lab04/collection.py | 838 | 3.953125 | 4 | # File: collection.py
# Author: Mitchell Angelos
# Date: 2/19/19
# Section: 12
# E-mail: a242@umbc.edu
# Description: tbf
def main():
userNumber = float(input("Enter how many beanie babies you have: "))
while userNumber <= 0:
print("Please enter a number greater than 0.")
... |
c1e12860b100fa3e0850d57bbe9cdd75d10f4828 | mmangelos/cmsc201 | /Homeworks/hw2/hw2_part5.py | 946 | 4.0625 | 4 | # File: hw2_part5.py
0;136;0c# Author: Mitchell Angelos
# Date: 2/18/19
# Section: 12
# E-mail: a242@umbc.edu
# Description: This is a day of the week calculator for a 28 day month
# with the first day starting on Friday (the 1st)
def main():
dayOfTheWeek = int(input("Plea... |
e6cafff17636971d178bb1cd9ed0dc6e0f37200f | mmangelos/cmsc201 | /Homeworks/hw6/hw6_part3.py | 830 | 4.28125 | 4 | # File: hw6_part3.py
# Author: Mitchell Angelos
# Date: 4/20/19
# Section: 12
# E-mail: a242@umbc.edu
# Description: This program performs the mod function, but recursively.
NUM_ONE = "Enter a number: "
NUM_TWO = "Enter another number: "
####################################################... |
918cfb7280a6e9631e5991c81ba1bd972f53f6b7 | mmangelos/cmsc201 | /Homeworks/hw2/hw2_part1.py | 1,148 | 3.8125 | 4 | # File: hw2_part1.py
# Author: Mitchell Angelos
# Date: 2/17/19
# Section 12
# E-mail: a242@umbc.edu
# Description: This program gives feedback afer asking the user what they're
# majoring in.
def main():
print("Please input your major(s). Enter 'NONE' for no response.")
... |
fb85af54621e152e7dcd7945ae6f212d39cb9dd4 | mmangelos/cmsc201 | /Homeworks/hw3/hw3_part5.py | 810 | 4 | 4 | # File: hw3_part5.py
# Author: Mitchell Angelos
# Date: 2/25/19
# Section: 12
# E-mail: a242@umbc.edu
# Description: This program prints numbers from 1 to 110, but prints special
# messages in special cases. (so fizzbuzz?)
END_NUM = 110 #the last number printed out. loop finish... |
ce93dfe7a306dfb3a17da0c516120476ce0a78df | HowDoIGitHelp/CMSC23MDNotes | /Lab Exercise Files/Lab Exercise 16 Decorator Pattern/generalExample.py | 808 | 4.15625 | 4 | from abc import ABC,abstractmethod
class SimpleClass:
def doSomething(self):
print("This is a simple class")
class BaseDecorator(ABC,SimpleClass):
def __init__(self, wrappedObject):
self.wrappedObject = wrappedObject
@abstractmethod
def doSomething(self):
pass
c... |
3d1350b805c2540d6b4c0d584f04c151c5448831 | HowDoIGitHelp/CMSC23MDNotes | /Lab Exercise Files/Lab Exercise 14 Template Pattern/generalExample.py | 1,198 | 3.828125 | 4 | from abc import ABC, abstractmethod
class Template(ABC):
@abstractmethod
def step1(self): #this has to be overridden
pass
def step2(self): #this has a default behavior but can be overridden
print("step 2: do something by default (t)")
def step3(self): #this has a default beh... |
e484293ec250efe5e7a87331759836cb9175d9be | anthuswilliams/euler | /4.py | 795 | 4.15625 | 4 | # PROBLEM: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.
#
# Find the largest palindrome made from the product of two 3-digit numbers.
#
# SOLUTION: brute force!
def is_palindromic(n):
n = str(n)
for i in range(len(n)):
... |
2295b58114b5b6abbe02593c78ae80c24028dfed | Akshay-Murali/100_day_of_python | /Day3/T_4_pizza_order.py | 893 | 4.25 | 4 | # Pizza Order app
print("Welcome to Python Pizza Deliveries!")
# Get's User Input for size , pepperoni and cheese preference.
# Uses .strip() to remove any space added by mistake and .upper to capitalise
size = input("What size pizza do you want? S, M, or L ").strip().upper()
add_pepperoni = input("Do you want peppe... |
b770f7c3fae353b7421b3ce12195eb9d6d375716 | Akshay-Murali/100_day_of_python | /Day2/T_2_BMI_Calculator.py | 386 | 4.46875 | 4 |
# BMI Calculator
print("Welcome to BMI Calculator")
# Collects user Height in Meter and Weight in KiloGram.
height = float(input("enter your height in m: "))
weight = int(input("enter your weight in kg: "))
# Uses the formula Weight/(height*height) to give the BMI
bmi = int(weight/(height**2))
#using f string t... |
c5d5ecb3040d9abe2a16e6628172e35a91353456 | marina133/Introspection-into-python | /lessons/lesson3.py | 240 | 4.03125 | 4 |
def log_function(n: float, m: float):
"""Calculates the integer part of logarithm of m (base n)"""
x = 0
m_copy = m
while(m >= n):
m = m / n
x = x + 1
print(f'n = {n}, m = {m_copy}, result is {x}')
|
d4fe1eaf397802a0832d96ebd654c221f4e403a7 | TeaaPartyy/Basic_Gui_Tutorials_Python | /2_images.py | 1,494 | 4.375 | 4 | #program done by Hamza Slaoui Habib
#Basic program to show how to change an icon in a program and how to upload a picture using tkinter
#beginners guide // functions not optimized
#this guide and the following others in the same file are inspired by the course offered by freecodechamp.org
from tkinter impor... |
4201c2c3dca0052c06285936c6f3a5be71b8f453 | Mittttttto/data_mining | /newtom_regression/newton_reg.py | 549 | 3.828125 | 4 | #coding=utf-8
'''
Created on 2017年11月14日
@author: wenmao
'''
# y = x**2 -3
# 计算机求开根
x_list=[]
y_list=[]
def newton_reg():
x=3.0
x_list.append(x)
loop_time=0
while True:
x=x-(x**2-3)/(x*2)
x_list.append(x)
y_list.append(x**2-3)
if abs(y_l... |
c522faaeaa40b0c098f8dae2e9c814f6b071791c | OwenShade/Python-BlackJack | /project 2.py | 8,872 | 4.0625 | 4 | import random
def welcome():
#Asks user to enter their name so game can personalised throughout#
print("Hello. Please enter your name.")
name = str(input())
#Validates that the name entered is less than 20 characters to stop use of madeup names#
while len(name) > 20:
print("Please ent... |
74b6b4d224d2ccf869e5d4410548f899e22e361e | sam1993316/CS2340_project | /burbger-CS2340-master/space_trader/app/objects/ship.py | 2,182 | 3.53125 | 4 | from .items import get_item_by_name
class Ship:
def __init__(self, ship_type):
self._ship_type = ship_type.copy()
self._curr_health = ship_type['health']
self._curr_space = ship_type['cargo_space']
self._curr_fuel = ship_type['fuel_capacity']
self._curr_cargo = dict()
d... |
60f3560a4809b6deb5423e003f0bf5bb24d79354 | sam1993316/CS2340_project | /burbger-CS2340-master/space_trader/app/objects/market.py | 2,795 | 3.640625 | 4 | from random import choice as randchoice
from random import randint
from .items import ITEMS, get_item_by_name, create_item
from .techlevel import TechLevel
# hack hack hack
def keyify(some_dict):
return some_dict['name']
class Marketplace:
# creates a marketplace depending on the TechLevel
def __init__(se... |
7d654ed889eb321c1d8031b2b3b8da863ab04ffd | hongqin/student.project.archives | /spelman/2012-2013/jean-baptiste-health-disparity2012/Python/FASTAmerge.py | 1,587 | 3.765625 | 4 | #!/usr/bin/env python
Usage="""
seqread.py - version 1
Reads in a file in fasta format into a list and a directory.
The resulting list is formated
[['name1', 'sequence1sequence1sequence1'],
['name2', 'sequence2sequence2sequence2']]
Usage:
seqread.py sequence.fta"""
import sys
#Expects a filename ... |
604f0b75a474445e1b4ec09e2a574c545b499805 | Alcketraz/pythonchallenge | /day4.py | 1,373 | 4.125 | 4 | # Q1)
lst1 = []
n = int(input("Number of elements: "))
for i in range(0, n):
element = int(input("enter the element: "))
lst1.append(element)
print(lst1)
d = int(input("Enter the element which you want to delete: "))
for i in lst1:
if d == i:
lst1.remove(d)
print("elem... |
db85e1aaed7911387dc9ec09454033ceb44e2643 | CitrineInformatics/python-citrination-cli | /citrination/util.py | 1,867 | 3.640625 | 4 | import urllib2
import os
def determine_url(host, project):
"""
Determine the URL to use when connecting to a host.
:param host: Full host name.
:param project: Project name.
:return: String with the URL to use.
"""
host = host if host is None else host.strip()
if host is not None and ... |
68818b87b1bb05a6d57d4c32b3402a901ab7a8d2 | Erislash/Prog-2 | /Sección 1 - Familiarizándose con Python/Practica/9/main.py | 1,695 | 3.984375 | 4 | def add(n: int, m: int) -> int:
return n + m
def sub(n: int, m: int) -> int:
return n - m
def mult(n: int, m: int) -> int:
return n * m
def div(n: int, m: int) -> int:
return n / m
def operation(None):
"""
Performs a basic operation based on an user's input
Parameters:
... |
baa94890faaa157df7128eb4bdd757a7c21a0f8d | NinjaBee/BasicPython3 | /eightball.py | 497 | 3.625 | 4 | import random
magic_answers = ["Of course!", "Sorry... I really am.","Try again. Bad question. You don't want to know.", "Yes, if you stand up right now.", "You should probably ask something else.","It's totally possible.","Maybe, the future is foggy.","Yes."]
running = True
while running == True:
tell_me = input... |
f34c80692908a4f31be560258e5e6fda73f1c06e | msheshank1997/Linked-List-1 | /Reverse_linked_list.py | 322 | 3.546875 | 4 | #Time Complexity : O(N)
#Space Complexity: O(1)
#Yes it ran on leetcode
class Solution(object):
def reverseList(self, head):
prev = None
curr = head
while curr != None:
nxt = curr.next
curr.next = prev
prev = curr
curr = nxt
return pr... |
7b2103e18d2db0683e8ed48046b5580f98553914 | kevsernury/gaih-students-repo-example | /Homeworks/Homework1.py | 328 | 3.921875 | 4 | nums = list(range(21))
even_nums = [i for i in nums if i%2 == 0]
odd_nums = [i for i in nums if i%2 ==1]
#Merging lists
even_nums.extend(odd_nums)
merged_lists = even_nums
#Multipling values
for i in range(21):
merged_lists[i] *= 2
#Sorting list
merged_lists.sort()
for i in merged_lists:
pr... |
5c8f97e909aa91657d241d3c486c59bf6262bfee | dntandan/VTU-Lab-Programs | /SEM-6 (File Structures Laboratory)/3 Varaible Length Records/variable_length_records.py | 2,205 | 3.75 | 4 | details = []
class student:
def __init__(self, usn, name, sem):
self.usn = usn
self.name = name
self.sem = sem
def display_data(self):
print(f"USN -> {self.usn} \nName -> {self.name} \nSem -> {self.sem} \n")
def pack(self, file):
buffer = self.usn + "|" + self.name ... |
e8a92269877a8ba7a6b8f3bfce7d5cb9da7c2175 | Suspious/functions-tryout | /papi giletto 3.py | 4,937 | 3.546875 | 4 |
print(''''
----------------------------------------------
Welkom bij Papi Gelato
---------------------------------------------------------
''')
bol = 0
toppingaantal = 0
toppingprijs = 0
vanille = 0
Chocolade = 0
munt = 0
bak = 0
hoorn = 0
liter = 0
vanille2 = 0
Chocolade2 = 0
munt2 = 0
def bolletje():
g... |
73db0963c17f8c641ab40e1e67a171fd5d88a1a7 | natsr1000/Matematica | /Semana 1/Aulas/Aula 5/aula-5.py | 320 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 8 10:45:41 2021
@author: Miguel Correia
"""
import math
import numpy as np
x = np.deg2rad(30)
n = 0
N = 25
result = 0
sign = 1.0
while n < N:
term = sign*x**(2*n)/math.factorial(2*n)
result = result + term
n +=1
sign = -sign
print(result)
print((np.sqr... |
4c928e9186d03d4c0abfcd04b29d3fd5abfd9d42 | natsr1000/Matematica | /Semana 1/Exercicios/Ex da Aula 4/Exercicio.py | 795 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 7 11:00:53 2021
@author: Miguel Correia
"""
#Check if the sequence converges using python:
import matplotlib.pyplot as plt
def n_seq(a,r,n):
print(a)
print(r)
seq_val=[]
for i in range(1,(n+1)):
seq=a*(r**i)
seq_val.append(seq)
return... |
f9edbc8863ee3536a99b09242bc1505ea5c77649 | JayantDwivedi/Basic-Python-programmes | /number gassing game.py | 233 | 3.9375 | 4 | print("****Number gussing game*****")
x=input("What are you gussed choose a number between the range of 1 to 10\n")
x=int(x)
y=int("3")
if x==y:
print("CONGRATS YOU WON THE GAME")
else:
print("BETTER LUCK NEXT TIME")
|
e5ffa54e0db8a3373e4c3152a19fdd4d62b6240f | JayantDwivedi/Basic-Python-programmes | /string replace.py | 146 | 3.59375 | 4 | name="she is looking so beautiful and i like her so much as she is full of joy"
print(name.replace(" ",""))
print(name.replace("she","aishu"))
|
aa402f850e157d8344478a9205051f6859e24dbb | Sowing/Algo_Trader | /.ipynb_checkpoints/test_insert-checkpoint.py | 669 | 3.5 | 4 | #!/usr/bin/env python3
def useless():
import sqlite3
connection=sqlite3.connect('algoforexdb.db')
cursor= connection.cursor()
cursor.execute('''
INSERT INTO users(
username,password,balance)
VALUES(?,?,?)''',
['nan1','222',100000.00])
print("User %s Successfully created" % 'nan1')
... |
5e888a470da68575ce8e89c8c510bd039a7b3b22 | jvelezb/informatica_industrial_2017 | /segundo_parcial/overloading.py | 460 | 3.75 | 4 | class Alumno:
def decirHola(self, name = None):
if name is not None:
print('Hola ' + name)
self.name = name
else:
print('Hola ')
def estudiar(self):
print("Alumno estudiando")
al1 = Alumno()
al1.decirHola()
# Call the method with a parameter
a... |
67774efa158aeae5070af99e68af506acfddce5d | jvelezb/informatica_industrial_2017 | /segundo_parcial/polimorfismo.py | 1,128 | 3.984375 | 4 | class Automovil:
def __init__(self, nombre):
self.nombre = nombre
def obtenerNombre(self):
return(self.nombre)
def manejar(self):
raise NotImplementedError("la subclase debe implementar el metodo")
def frenar(self):
raise NotImplementedE... |
119bbe0bc7885e33408ca894bfec69f00a383ea8 | jvelezb/informatica_industrial_2017 | /primerParcial/asesoria_3.py | 389 | 3.921875 | 4 | lista = ['Alberto','Zapata','Carlos','Alejandro','Claudia','Mariana',2,1,4,342]
print(lista)
for i in range(0,len(lista)):
print("lista:",lista[i],'i: ',i)
valor = lista[i]
if valor != str:
lista.remove(valor)
if(i<len(lista)):
lista.insert(i,str(valor))
else:
lista.append(str(valor))
print (lista)
#lis... |
0431c67a9ffa50988709c5065160c28b886e846c | robalonsor/raw-data-to-graphml | /Recipe/Edge.py | 1,086 | 3.703125 | 4 | #!/usr/bin python3
# from Vertex import Vertex
class Edge(object):
def __init__(self, vertex1, vertex2, value):
assert vertex1.type_of_vertex != vertex2.type_of_vertex and vertex1 != vertex2
if vertex1.type_of_vertex != "a":
self.vertex1 = vertex2
self.vertex2 = vertex1
... |
103b21367e6672bd83e7410cefde1dfecfe57744 | Army96/AADS | /Ex2/CPUScheduler.py | 3,273 | 3.671875 | 4 | class Job:
__slots__ = "_name", "_waitingTime", "_length"
def __init__(self, name, length):
self._name = name
self._waitingTime = 0
self._length = length
"""
Implements the scheduler. The parameter apq represents an AdaptableHeapPriorityQueue, using the implementation in
the tdp collec... |
551a7487f83f0988df683a3310423340bd00f4ee | jamesliu96/teach | /python/tkwindow.py | 438 | 3.8125 | 4 | #!/bin/env python
# -*- coding: utf8 -*-
from Tkinter import *
tk = Tk()
tk.title("Hello, world!")
hello = Label(tk, text="Hello, world!")
hello.pack()
e = Entry(tk)
e.pack()
def c():
print(e.get())
def i():
e.insert(0, e.get())
def q():
tk.quit()
show = Button(tk, text="SHOW", command=c)
show.pack()
copy... |
d5a8feca7f0702968b5d95d6ab6c0d1f8fb89a9c | ankita-y/PythonProjects | /MilkCalculator.py | 2,914 | 3.625 | 4 | from tkinter import *
from datetime import date
from tkinter import ttk
import time
import datetime as dt
import csv
root = Tk()
root.geometry("800x500")
root.title("Milk Calculator")
#root.resizable(0,0)
# loading image
photo = PhotoImage(file = 'milk.png')
# creating a Label widget to show the image w... |
8f293fc5f632414a14458934e5ab06abf68c96e9 | ankita-y/PythonProjects | /projectusingTurtle.py | 779 | 3.921875 | 4 | import turtle
wn = turtle.getscreen()
wn.bgcolor('black')
colors = ['red','purple','blue','green','orange','yellow','pink']
draw = turtle.Turtle()
draw.pen(pencolor="purple",pensize=5)
#To draw multiple circle
# for x in range(10):
# draw.pencolor(colors[x % len(colors)])
# draw.circle(50)
# ... |
71478a6b2b0ddec38fdaec0d5d2758bcda782f35 | iRoni10002/mahaon_python_lessons | /pack4_1.py | 459 | 4.03125 | 4 | class Point:
count = 0
coord_x = int()
coord_y = int()
def __init__(self, x, y):
self.coord_x = x
self.coord_y = y
Point.count += 1
def __add__(self, point):
x = self.coord_x + point.coord_x
y = self.coord_y + point.coord_y
return [x, y]
point1 = P... |
7d6ff31c3ac5826bbf2c96015a7eca60ce1c090e | iRoni10002/mahaon_python_lessons | /repeating_2_3.py | 259 | 4.09375 | 4 | dict = {'Russia': 'Moscow', 'China': 'Beijing', 'USA': 'Washington'}
print(dict.values())
print(dict.keys())
print(dict.items())
dict_2 = {'France': 'Paris'}
dict.update(dict_2)
print(dict)
print('France' in dict)
for i in dict:
print(i, dict[i])
|
0fc7a347df44f3ed5a89379584f929ec221a31d9 | iRoni10002/mahaon_python_lessons | /repeating_2_2.py | 131 | 4.0625 | 4 | dict = {'a': 1, 'c': 3}
print(dict)
dict['b'] = '2'
print(dict)
del dict['c']
print(dict)
print('c' in dict)
print('b' in dict)
|
1e6472df9bfdfcaeea9c082ebfeb5ffd44705cc3 | QsBBQ/oop_notebook_practice | /todo/todo.py | 1,623 | 3.609375 | 4 | import datetime
last_id = 0
class Todo:
"""
Class represents a Todo/task
"""
def __init__(self, task, task_due, status="open", tags=""):
"""
Initialize a Todo
"""
self.task = task
self.tags = tags
self.task_due = task_due
self.creation_date = da... |
fcf1f3c76cc15ee1d05671409f0ab96d6f1199f9 | sunyumail93/FastaProcessing | /FastaHeaderConcatenator.py | 1,223 | 3.671875 | 4 | #!/usr/bin/python3
#This script simplifies the FASTA header into a single word, without delimitator
#If the header line has already met the criteria, then no change will be made
#If not, then the a _ delimitator will be added to combine all characters (substitute space or tab)
#Version: 2020-04-17, Y.H.S
... |
7b50b2c76c9639e2f7a5298cbd9dbc621befc8ca | Adrianlov/Python_study | /Spanzuratoarea.py | 3,940 | 3.90625 | 4 | import random
import time
print("\nBine ai venit la spanzuratoarea\n")
nume = input("Introdu numele tau: ")
print("Salut " + nume, "Noroc! ")
time.sleep(2)
print("Jocul incepe! \nSajucam")
time.sleep(3)
def main():
global count
global display
global word
global already_guessed
global length
g... |
319aab63a7ed32d61c16c3f394b00e75f78fb358 | Adrianlov/Python_study | /Joc minge.py | 373 | 3.515625 | 4 | import turtle
wn = turtle.Screen()
wn.bgcolor('green')
wn.title("Bila miscatoare")
minge = turtle.Turtle()
minge.penup()
minge.shape("square")
minge.goto(0, 100)
minge.speed(0.5)
minge.dy = 10
gravity = 0.2
while True:
minge.dy -= gravity
minge.sety(minge.ycor() + minge.dy)
if minge.ycor() < -200:
... |
cc541be6ca28ecd2a73dd27eb14325e33323e4df | ibarchakov/MIPT | /Lecture8 - Recursions/task3 - branch (fractal example).py | 513 | 3.78125 | 4 | import turtle
def draw(length, num_of_branches):
n = num_of_branches
if n == 0:
turtle.left(180)
return
x = length / (n + 1)
for i in range(n):
turtle.forward(x)
turtle.left(45)
draw(0.5 * x * (n - i - 1), n - i - 1)
turtle.left(90)
... |
f3f964bb496ccb2a7af781a2c556ad28cc8b6ee0 | ibarchakov/MIPT | /Lecture9 - Sorting Methods O-NlogN/merge sort.py | 981 | 4.15625 | 4 | def merge(a, b):
"""Merging of two sorted lists A and B into list C"""
c = [0] * (len(a) + len(b))
i = k = n = 0
while i < len(a) and k < len(b):
if a[i] <= b[k]:
c[n] = a[i]
i += 1
n += 1
else:
c[n] = b[k]
k += 1
... |
04cd1b7b9d062f67076d196db8900f12ad9aebea | primeschool-it/Y13 | /inheritance.py | 1,275 | 4.09375 | 4 | ## Inheritance
class Student():
def __init__(self, student_name, student_age, student_dob):
print("instanciating member....",student_name)
self.name = student_name
self.age = student_age
self.dob = student_dob
self.session = '2020-2021'
def get_subjects(self):
p... |
3ac65c67679b79a149aaeacd2fbe75fa58181a83 | hansliu/leetcode | /7.Reverse-Integer.py | 457 | 3.671875 | 4 | def reverse(x):
"""
:type x: int
:rtype: int
"""
neg_limit = -0x80000000
pos_limit = 0x7fffffff
if x > 0:
ans = int(str(x)[::-1])
if ans > pos_limit:
return 0
else:
return ans
elif x < 0:
ans = 0-int(str(0-x)[::-1])
if ans <... |
c80d023c9387955d870fa7d5a9e51586d8a4454b | hansliu/leetcode | /155.Min-Stack.py | 1,049 | 4.03125 | 4 | class MinStack(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.queue = []
self.min_queue = []
def push(self, x):
"""
:type x: int
:rtype: void
"""
self.queue.append(x)
if len(self.min_queue) ... |
0413c2536239e3e671f81315c6d5c372c39bc04d | Fernando720/random_things | /exemplo.py | 347 | 3.59375 | 4 | import sqlite3
db = sqlite3.connect("exemplo2.db")
cursor = db.cursor()
cursor.execute("""
CREATE TABLE artist(
artistid INTEGER PRIMARY KEY,
artistname TEXT
);
""")
cursor.execute("""
CREATE TABLE track(
trackid INTEGER,
trackname TEXT,
trackartist INTEGER,
FOREIGN KEY(trackartist) REFERENCE... |
add2b12b845701b21e66d7254082f15cf5418d21 | irtery/spheremailru | /ml_intro/hw2/ackermann.py | 449 | 3.609375 | 4 | def compute_ackermann(m, n):
ackermann.counter += 1
if m == 0:
return n + 1
if m > 0 and n == 0:
return compute_ackermann(m - 1, 1)
return compute_ackermann(m - 1, compute_ackermann(m, n - 1))
def ackermann(m, n):
ackermann.counter = 0
return compute_ackermann(m, n)
if __name__ == '__main__':
p... |
b2027f1eaaebfaf552a3dd410c54bee94f1906cb | irtery/spheremailru | /info_search/spellchecker/simple_spellchecker.py | 2,911 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import numpy as np
def levenshtein(a, b):
"""Return the Levenshtein edit distance between two strings *a* and *b*."""
if a == b:
return 0
if len(a) < len(b):
a, b = b, a
if not a:
return len(b)
previous_row = range(le... |
b04d30754e85ca1dc0dd96aa73fc6e17cbf5ced6 | Khmer495/atcoder | /abc134/c.py | 307 | 3.625 | 4 | def main():
n, *a = map(int, open(0).read().split())
sorted_a = sorted(a)
max_a = sorted_a[-1]
next_max_a = sorted_a[-2]
for cur_a in a:
if cur_a == max_a:
print(next_max_a)
else:
print(max_a)
return()
if __name__ == '__main__':
main()
|
0e367b739c69b7e7725aba46d0f2cb94d7953d63 | Khmer495/atcoder | /abc142/d.py | 795 | 3.703125 | 4 | def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
prime_divisors = []
for i, _divisors in enumerate(divisors[::-1]):
for _remain_diviso... |
008b1154bc454c64997eb47e8196be1bcdef7ebf | facuramirez/dirMod | /main.py | 300 | 3.53125 | 4 | from resolucion import ejercicio
def main():
# Inicio el input para que el usuario pueda tipear una palabra o una frase
palabra = input('*** Tipear una/s palabra/s para realizar la respectiva conversión: ***\n===> ')
ejercicio.resolucion(palabra)
if __name__ == "__main__":
main() |
66b66c51de22b59b1b2d6ffcb6ab8a0c4ebb8368 | tripleaceme/Python-Data-Structures-Course-On-Cousera | /Week-6/assignment_10_2_re_version.py | 1,233 | 3.75 | 4 | # Write a program to read through the mbox-short.txt
# and figure out the distribution by hour of the day
# for each of the messages. You can pull the hour out
# from the 'From ' line by finding the time and then
# splitting the string a second time using a colon.
#
# From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16... |
a63e9b5f56994044d9a32ee529561383a0d3d0a0 | JalenDurr9/Module-7 | /Problem 2.py | 559 | 4.21875 | 4 | Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import math
>>> def rangeNumber(n):
if int(num) in range(1, 10):
print ("You entered a number in the range of 1 to 10")
elif int(num) not ... |
0c9df6c80beb71017e568c37204e759af0473f88 | phylp/AlgoDojo | /problems/arrays/three_number_sum/solution.py | 587 | 3.828125 | 4 | def three_number_sum(array, targetSum):
final = []
sorted = array.copy()
sorted.sort()
for i in range(0, len(array)):
left = i+1
right = len(array)-1
while left < right:
currentSum = sorted[i] + sorted[left] + sorted[right]
if currentSum == targetSum:
... |
e7a366c554b6bc97ed0f69d389594501b5ea0332 | CDidier80/Code-Challenges-Algos-Interviews-Cool-Solutions | /challenges-and-interview-problems/STANDARD/isograms/isograms.py | 495 | 4.21875 | 4 | # An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a
# function that determines whether a string that contains only letters is an isogram. Assume the
# empty string is an isogram. Ignore letter case.
# isIsogram("Dermatoglyphics") == true
# isIsogram("aba") == false
# isI... |
0b0e6c1ea1355d1a187373d0618a3f0d46314bd8 | yuezaixz/PythonStudy | /leetcode/sort/insertionSort.py | 1,246 | 4.15625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# @param head, a ListNode
# @return a ListNode
def insertionSortList(self, head):
if not head or not head.next: return head
dummy = ListNode(0)
... |
04734fb4bce09c2afae1ce5e540f151f9868ee45 | yuezaixz/PythonStudy | /leetcode/String/reverseWords.py | 725 | 3.671875 | 4 | class Solution:
# @param s, a string
# @return a string
def reverseWords(self, s):
# default split by space and trim multi space
return " ".join(s.split()[::-1])
def old_reverseWords(self, s):
stack = []
word = []
for temp in s:
if temp.isspace():
... |
d3a433e849fc41bcae247b544dfe4e57b837daad | johnrcruzado/test_product | /test.py | 181 | 4.03125 | 4 | def wage_for_day(hr: int, rate: float) -> float:
if hr<=8:
return hr * rate
elif hr>8:
return 8*rate + (hr-8)*1.5*rate
print(wage_for_day(9,250))
print("test") |
f461155197e2a161aa96eec46e906563b288aa33 | DO-CO/CouseraDataScienceToolkit | /first-of-my-python.py | 267 | 4.0625 | 4 | # # PRINT "Hello World!" as a test
# Print function is used to print elements on the screen
# Define a string x
# A string in Python is a sequence of characters
# String in python are surrounded by single or double quotation marks
print("I say 'Hello World !' " )
|
fe5eeb64da600842318ddb5578855d7ec38ad31b | Masum06/Bangla-Digit-Recognition | /extract/squares.py | 2,855 | 3.546875 | 4 | #!/usr/bin/env python
'''
Simple "Square Detector" program.
Loads several images sequentially and tries to find squares in each image.
'''
# Python 2/3 compatibility
import sys
PY3 = sys.version_info[0] == 3
if PY3:
xrange = range
# import sys
# sys.stdout = open('log.txt', 'w')
import functools
import numpy a... |
aff1cea01b67cf3a6d5f6e529a9325ede81eaebd | vector8188/racktest | /customer.py | 2,162 | 3.796875 | 4 | class Customer:
def __init__(self, customerType, arrivalTime, items, customerNumber):
self.items = items
self.customerType = customerType
self.arrivalTime = arrivalTime
self.customerNumber = customerNumber
class CustomerA(Customer):
def enqueCustomer(self, registers):
cu... |
fa19d305920c7cdbd97f451cb3ccc4b9eb6f0134 | henryzt/ENGF0002 | /Assignments/assignment1/model_answers/cipher.py | 2,517 | 4.1875 | 4 | import random
test_text = "The number Pi is a mathematical constant. Originally defined as the ratio of a circle's circumference to its diameter, it now has various equivalent definitions and appears in many formulas in all areas of mathematics and physics."
# convert a string to uppercase and remove all the spaces, ... |
5a27f9c9399c9d55d90461d227dbafea640f3fd8 | bayueba/PythonCloud8 | /qyy_1117_02/demo02.py | 274 | 3.828125 | 4 | #coding=utf-8
computer=1
p=input('剪刀(0)、石头(1)、布(2)')
if ((p==0) and (computer==2)) or \
((p==1) and (computer==0))or \
( (p==2) and computer==1):
print("太low了你")
elif p==computer:
print("再来")
else:
print('ai,好惨') |
5c805514090ec55e25a70263b6c48c0ef33846bf | subenakhatun/python | /problem-06.py | 196 | 3.953125 | 4 | '''
write a python program to sum of all numbers if they are odd and if they are even
Sample input:
L = [1,2,3,4,5,6,7,8,9]
Sample output:
sum_odd_numbers = 25
Sum_even_index = 20
''' |
cf335f9c626a6613f8c5935d26dd1e3be3752ba1 | subenakhatun/python | /problem-01.py | 140 | 4.0625 | 4 |
# l = [1,2,3,4,5] write a program to sum all the items of a list .
l = [1,2,3,4,5]
sum = 0
for i in l:
sum = sum + i
print(sum) |
4155357a7f8912781ad273aed28c5fe683b2db5b | AmericanEnglish/Academic-Conclusions | /old/helper.py | 6,504 | 3.53125 | 4 | #LABEL THING THING NAME_NAME
from random import randint
def convert_to(original, output):
with open(original, 'r') as filein:
with open(output, 'w') as fileout:
string = filein.read()
for char in string:
if char == ' ':
fileout.write('_')
... |
2f9ed4891d301d514f4c66ab498b59a0be403743 | huazhige/EART119_Lab | /hw1/submissions/duongmatthew/duongmatthew_24972_1251114_HW_1_2_area_polygon.py | 1,317 | 3.65625 | 4 | #python2.7
"""
Created on Sat April 13, 2019
This script does the following:
Solve for the area of an irrgular polygon using for loops.
@author: maduong
"""
#==============================================================================
# Parameters
#==========... |
70656e55d54d78a2af15a4d0d61c31e79bf1c009 | huazhige/EART119_Lab | /hw4/submissions/daltonkatie/daltonkatie_34647_1304249_HW4_problem3.py | 2,668 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Modify the function we developed in class for Newton’s method
so that the iteration (while loop) stops if the following
convergence criterion is met
"""
#------------------------------------------------------------------------------
# ORIGIONAL FUNCTION
... |
da33b9ab5e2bb806d8b588216ce137cce3a14db5 | huazhige/EART119_Lab | /extra/cookclaire/Extracred/Extracred.py | 1,558 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 16 19:03:41 2019
Discretize the following functions between xmin, xmax using N=1000 sample points.
Compute the mean value of the function in the given domain and compare it to the
integral of the function over the same domain. You can compute the integral
numerical... |
c7ff3f15bf9bbd342854a6c71c4f586bf0dad6f1 | huazhige/EART119_Lab | /mid-term/tamrazcamellia/tamrazcamellia_35157_1312306_Midterm #2 | 753 | 3.828125 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Midterm Question #2
"""
"""
#A
import numpy as np
import matplotlib.pyplot as plt
x = linspace(-10, 9, 2) #creating an array for the interval
y = x**5 +2/5*x**2 -2 #inputting th equation
i = 0 #creating a while loop w a true/false statement
while y[i... |
3f79f4544a147d1ebfc7ae314cdfd35027f4a5dd | huazhige/EART119_Lab | /hw4/submissions/leeric/leeric_33229_1304835_Secant_method.py | 1,210 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 2 19:01:57 2019
Homework 4 Problem 4
@author: eric_
"""
import numpy as np
import matplotlib.pyplot as plt
def my_Secant( fct, x0, x1, tol = 1e-4, N = 20):
x0 = float( x0)
x1 = float( x1)
i = 0
while abs( fct( x1)) > tol and i < N: # could... |
2b857b0ef81b4db5f64da0bba65e75d3f709772f | huazhige/EART119_Lab | /hw1/late/gradylogan_12314_1248762_area_polygon_vec.py | 397 | 4 | 4 | # -*- coding: utf-8 -*-
import numpy as np
x = [1,3,4,3.5,2]
x1 = [2,1,3,4,3.5]
y = [1,1,2,5,4]
y1 = [4,1,1,2,5]
def area(x, y):
return 0.5 * (np.dot(x1, y) - np.dot(x, y1))
print (str(area(x,y)) + " units squared")
"""x = np.array([1,3,4,3.5,2])
y = np.array([1,1,2,5,4])
i ... |
5fbd22f2163ba7a028c62f3f21ab0a28dca086d9 | huazhige/EART119_Lab | /extra/lopezbruno_20628_1340428_Extra Credit Hw Problem 2.py | 2,584 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 17 15:39:10 2019
@author: bruno
"""
import numpy as np
from scipy import integrate
#Defines the function sin(x)
def fx(x):
return np.sin(x)
#Defines the function 2xe^x^2
def fx1(x):
return 2 * x * np.exp(x**2)
def midpoint( fct_x, x0, xn, N... |
db9d97a1f3dae4c88bcfa4042c069b472cb9fa15 | huazhige/EART119_Lab | /hw4/submissions/minerajason_36406_1304823_HW_2.py | 1,564 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
@author: Jason Minera
#2 find the intersection between two functions given and
find the value of the f(t) and g(t)
"""
#import matplotlib.pyplot as plt
#import numpy as np
import opt_utils as ou
def f_t(t):
return (1.1*(t - 2.5)**2)
def df_t(t):
return 2*1.1*(... |
c4ea89777b258bbad7968754f820bbda0da6dc12 | huazhige/EART119_Lab | /hw1/late/villanuevachiaradane_25785_1250249_HW 1 Problem 2 Part a.py | 856 | 3.90625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# Function for area of a polygon
# The arguments include the x vector components and y vector components
def polygon_area(x, y):
# Initializing the area
area = 0
# Setting how many vertices there are to the length of x (or y, assuming they are the same ... |
421e26cef17c7c32e6204bf8e3856244b56710d1 | huazhige/EART119_Lab | /hw1/late/gradylogan_12314_1248763_circle_rectangle_area.py | 258 | 3.625 | 4 | # -*- coding: utf-8 -*-
import math
#========================
r = 12.6
a_circ = (math.pi)*r**2
print a_circ
#========================
a = 1.5
b = 0
a_rect = a*b
while a_rect < a_circ:
b = b + 1
a_rect = a*b
print b
|
d3a5247418eb99e22b937743cc01a91063fdc3ed | huazhige/EART119_Lab | /hw1/submissions/guptanavika/hw1/area_polygon.py | 593 | 3.859375 | 4 | import math
import sys
import array
import numpy as np
print("How many vertecies?")
#numV=input()
num = input()
x= np.empty((num))
y= np.empty((num))
#x[0]=3;
#
#x = array
for i in range(num):
print ("x corrdinate "+str(i+1)+":")
x[i]=input()
print ("y corrdinate "+str(i+1)+":")
y[i]=input()
print(x)
prin... |
e080a1ca9f234923883169d8071f48e08ec53e81 | huazhige/EART119_Lab | /hw4/submissions/duongmatthew/duongmatthew_24972_1303227_HW_4_3-1.py | 1,462 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat May 4 13:35:08 2019
- A new function, "my_Newton", that solves for a root depending on how small
the difference between the current and last fct value is, rather than how small
the fct value, itself, is.
author: maduong
"""
import numpy as np
#=... |
c7af7b5ecf3b43534ae3fc7b929e84a5396df954 | huazhige/EART119_Lab | /hw1/submissions/villanuevachiaradane/villanuevachiaradane_25785_1250248_HW 1 Problem 1.py | 507 | 3.96875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# Function for area of a rectangle
# The arguments include the width (b) and length (c) of the rectangle
def a_rect(b, c):
# Equation of finding the area of a rectangle
A = b*c
# Returns the area
return A
# Function for area of a triangle
# The arg... |
c63b26246f781d2b6a94508f96e385ccf2ba9971 | huazhige/EART119_Lab | /hw1/late/cookclaire_15272_1251143_HW_Q1.py | 663 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 10 21:55:04 2019
Area of a Rectangle and Triangle
"""
#==========================================================
# parameters
#==========================================================
b = input('input length') #length of shape
c = i... |
3bfe7a0bcae038da2bf759aaa0a0d30d4a71ad4c | huazhige/EART119_Lab | /hw4/submissions/kooiandreas/kooiandreas_31749_1303395_HW4_P2_akooi-5.py | 3,382 | 3.71875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
NOTE: I did edit opt_utils and the 2_1 file a bit, so I attached them alongside with the homework.
Created on Sun May 5 11:39:14 2019
@author: andreaskooi
Find the intersection (cross-over point) between the following two functions using
Newton’s or the Secant met... |
57bd8400c3d2381723855cfcd73254ed8c565ca5 | huazhige/EART119_Lab | /hw1/submissions/matteinieric/matteinieric_33412_1250674_area_polygon_vec.py | 626 | 3.609375 | 4 | """
Astr/Earth-119, Homework-1, problem 2
Finding the area of a polygon using vectors
"""
import numpy as np
#================================================
# (x,y) coordinates =====================================
x_crdnts1 = np.array([1, 3, 4, 3.5, 2])
y_crdnts1 = np.array([4, 1, 1, 2, 5])
x_crdnts2 = np.a... |
42cb4c3873e98f75851d4b3875523a16776182e2 | huazhige/EART119_Lab | /hw1/submissions/chapmanbrendan/chapmanbrendan_26691_1250649_temp.py | 2,231 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Brendan Chapman
EAR119
HW1
"""
#========================================================================================================================
" Question 1"
"Program computing the area of a rectangle"
#=======================================================================... |
4b1b4c518a4ee4d3def840b702e462a30da4cb54 | huazhige/EART119_Lab | /hw1/submissions/lopezbruno/lopezbruno_20628_1249075_Hw1number3.py | 2,308 | 3.890625 | 4 | # -*- coding: utf-8 -*-
#Python 2.7, Anaconda 2
"""
Created on Sat Apr 13 17:04:51 2019
@author: bruno
Two different programs to find the area of a polygon, given two vectors(xi,yi)
One of the methods will use a for loop, the other will use vectorization
"""
import numpy as np
# The X axis of the arr... |
815ffc85b26a23d3a821ab3d15fa196b0bec9524 | huazhige/EART119_Lab | /hw1/submissions/martinezverenise/martinezverenise_22776_1250548_Problem#1.py | 469 | 4.0625 | 4 | """
Problem #1
Computing the area of rectangle and the area of a triangle
"""
b= int(input('base '))
c= int(input('hieght '))
A = b*c #Area of Rectangle
print('Area of Rectangle', A)
##Part B##
h0= int(input('height '))
b= int(input('base for triangle '))
A_tri= 0.5*h0*b
... |
4f8a397ea38c082e751e0479cea8c873bcba3f71 | huazhige/EART119_Lab | /hw1/submissions/lagunacesar/lagunacesar_26639_1250220_HW_1_3.py | 825 | 4.03125 | 4 | # -*- coding: utf-8 -*-
'''
Cesar Laguna
Python 3.6
'''
import numpy as np
'''
# 3
Finding the minimum value of side b of a rectangle that will give us the
the a number as close to but less than the area of the circle
'''
radius = 12.6
area_cir = np.pi*(radius**2)
a_rec = 1.5
b_rec = 0
while a_rec*b_rec < area_cir: ... |
26e2aff4a2fb13cfd9fb3304aab02df54cbe6eaf | huazhige/EART119_Lab | /hw4/submissions/alarconvanessa/alarconvanessa_35946_1305026_2.py | 2,966 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat May 4 21:24:42 2019
python/anaconda 3.7
HW week 5, problem 1
Comparing the Newton method to the method we used in week 2 to find cross
over points
@author: Nessa
"""
import numpy as np
import matplotlib.pyplot as plt
import opt_utils as opt
#=============... |
62df56572a77ef0e6c177b74426f261c514532b7 | huazhige/EART119_Lab | /hw1/submissions/babbejames/119_hw#1.4.py | 1,046 | 3.65625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 12 16:02:30 2019
@author: jtbabbe
Write radioactive decay eqn.
"""
import math
#================================
# Define Variables
#================================
# Vars. for parts a and b
N = 1 # quantity
tao = 5730
t1 = 10000 # year... |
fa168bbc57aaac82d51d32d21d8918eef6ec904a | huazhige/EART119_Lab | /hw4/submissions/duncantaylor/q4.py | 1,016 | 3.671875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sun May 5 10:31:29 2019
@author: taylorduncan
"""
import math
def secant(f, x0, x1, eps):
f_x0 = f(x0)
f_x1 = f(x1)
iteration_counter = 0
while abs(f_x1) > eps and iteration_counter < 100:
try:
denominator = float(f_x1 ... |
d018c073d52f4c52880023e9adbe5a70418c70d7 | huazhige/EART119_Lab | /mid-term/silbermanshayna/silbermanshayna_24289_1312477_MT_Q_2-1.py | 2,043 | 3.78125 | 4 | # -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
#=====================================
# functions
#=====================================
def f1( x):
return x**5 + (2/5)*x**2 - 2
def f2( x):
return np.exp(-x/10) + x
def f3( x):
return 10*np.sin(x/4) + .1*(x + 12... |
99cb46ec765d057591ada518f8aaa2126d7a92c1 | huazhige/EART119_Lab | /hw1/submissions/weichienchu/weichienchu_35082_1250739_hw102.py | 1,175 | 3.765625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 11 19:17:52 2019
@author: charity
"""
import numpy as np
def PolygonSort(corners):
n = len(corners)
cx = float(sum(x for x, y in corners)) / n
cy = float(sum(y for x, y in corners)) / n
cornersWithAngles = []
for x, y in corne... |
1382c9e58d7a6890e1def17bf82c3c7f5cdd6eea | huazhige/EART119_Lab | /hw1/late/kupkelara_32169_1250722_Problem1.py | 434 | 3.890625 | 4 | #! Python 2.7
'''Problem #1 on Hw#1'''
#Test case inputs
b = 8
c = 15
height = 4
#functions
def area_of_rectangle(b,c):
area = b*c
return area
def area_of_triangle(height,b):
area = 0.5*height*b
return area
#print statements
print('Area of rectange with side lengths:',
b,',',c,'=',area_of_recta... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.