blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
1964ea049b6addd9c94d88e994013880548cb4e3 | alexmerryman/debbit | /src/utils.py | 508 | 3.9375 | 4 |
# converts cents int to formatted dollar string
# 4 -> '0.04'
# 50 -> '0.50'
# 160 -> '1.60'
# 12345 -> '123.45'
def cents_to_str(cents):
if cents < 10:
return '0.0' + str(cents)
elif cents < 100:
return '0.' + str(cents)
else:
return str(cents)[:-2] + '.' + str(cents)[-2:]
# Rem... |
eb6434d2376ca8049bffaa7915ad0fb9b3f1616d | drishti-agarwal/school-database-software | /mainwindow.py | 2,361 | 3.65625 | 4 | from tkinter import*
from PIL import ImageTk,Image
import registrationform
import details
mainwindow=Tk()
mainwindow.geometry('600x600')
path=r'C:\Users\drishti agarwal\Documents\GitHub\school-database-software\wallpaper-3.jpg'
background=ImageTk.PhotoImage(Image.open(path))
#labels
wallpaper=Label(mainwin... |
22121e8a4ced64e2a4238b62b092d62eaae8384b | purecall/my_leetcode | /160 相交链表.py | 1,083 | 3.609375 | 4 | #
# @lc app=leetcode.cn id=160 lang=python3
#
# [160] 相交链表
#
# @lc code=start
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# listA 作为一个集合,再去遍历listB
def getIntersectionNode(self, headA: ListNode, headB: Lis... |
b6bb152dc17af5ffc19dc1a6786c57bb7da80abe | ombanna/mama | /180pyramidpatt.py | 330 | 4.15625 | 4 | # 180 pyramidd Pattern Printing
n = int(input("How Many Number You Want To Print Pattern\n"))
def pyramidpatt(n):
k = 2 * n -2
for i in range(0,n):
for j in range(0,k):
print(end=" ")
k = k -2
for j in range(0,i + 1):
print("*",end=" ")
print("\r")
pyram... |
fc1d3ba12a5e13e8e002d503e2a5e1f9e16e4736 | RLuckom/python-graph-visualizer | /abstract_graph/Edge.py | 1,026 | 4.15625 | 4 | #!/usr/bin/env python
class Edge(object):
"""Class representing a graph edge"""
def __init__(self, from_vertex, to_vertex, weight=None):
"""Constructor
@type from_vertex: object
@param from_vertex: conventionally a string; something unambiguously
represent... |
8aece94e6960f07ce6c6fe4b1c67abb69c6f1ee5 | stratofax/sitecheck | /src/sitecheck/chatgpt_original_spider.py | 1,020 | 3.515625 | 4 | # This code was originally generated by ChatGPT with the following prompt:
# "write a web spider in python that identifies all the unique internal links on a page"
# This code doesn't work very well, because even if a page is returned with a 200 OK code,
# the program will display the "page not fetched" error if no int... |
3dced430fb9ecc407051fef1d7cd07a0f3ee1f06 | CoderVader/Project-Euler | /pe4.py | 216 | 3.625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 3 15:03:41 2018
@author: sam
"""
for num1 in range(0,100):
for num2 in range(0,100):
pdt = num1 * num2
while pdt != 0:
|
4b5f6fa99ee08310e1329e6d9e6fa0fc1f57f5d4 | CoderVader/Project-Euler | /pe13.py | 210 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 15 13:14:31 2018
@author: sam
"""
num = [3,7,1,0,7,2,8,7,5,3,3,9,0,2,1,0,2,7,9]
add = 0
for i in range[11]:
add += num
print(add) |
7ed4f55de2104f5b9cf029106bed1a08dab279ef | CoderVader/Project-Euler | /pe10.py | 669 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 25 23:54:57 2018
Description: Program to find the sum of primes that
1 to 2 million
@author: sam
"""
# number to find summation of all primes below number
lim = 2000000
# create a set excluding even numbers
numbers = set(range(3, lim + 1, 2))
fo... |
d72440974b7f130d22b5d02a68d63688d2f37387 | matheusphalves/algorithm-toolbox | /week02 - algorithmic_warmup/07lastDigitSumRange.py | 851 | 3.9375 | 4 | from functools import reduce
listFib = [0,1]; #list with fib results
def fib(n):
sizeList = len(listFib)
if n<sizeList:
return listFib[n]
else:
for i in range(n -(sizeList-1)): #I don't calculate all 'n' terms. I need to know how many terms (index) must be increased.
listFib.ap... |
15bd2040d809079aa9aab0b01c60f1cfc26fd570 | matheusphalves/algorithm-toolbox | /week02 - algorithmic_warmup/04lcm.py | 320 | 3.640625 | 4 | #Last common multiple
def lcf(a,b):
result =1;
counter = 1;
if(a<b):
shorter = a;
else:
shorter = b;
while(result%a!=0 or result%b!=0):
result = shorter*counter
counter += 1
return result;
numbers = input("").split()
print(lcf(int(numbers[0]), int(numbers[1]))) |
8991a1c6fd8d01c3f052378eb0729296a34b4823 | matheusphalves/algorithm-toolbox | /week02 - algorithmic_warmup/05fibNumberAgain.py | 1,211 | 3.953125 | 4 | listFib = [0,1]; #list with fib results
def fibList(n):
sizeList = len(listFib) #
if n<sizeList:
return listFib[n]
else:
#(sizeList-1) the last index value
# n is the index than i need to know
#the, i must calculate result = n - sizeList-1
for i in range(n -(sizeLis... |
55a47697b88fc527fe9ddc6b46b64bbb80a0f0ab | DatBiscuit/Flappy_Bird | /Flappy_Bird_2.py | 1,009 | 3.859375 | 4 | import pygame
pygame.init()
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
yellow = (255,255,0)
#screen size variables
dw = 600
dh = 476
#player position
x = dw/2
y = dh/2
screen = pygame.display.set_mode([dw, dh])
pygame.display.set_caption('Flappy Bird')
pygame.... |
b2d4a5510e5558659cc5d356c40c27bb7e790c8c | Duaard/CityProfit | /main.py | 1,318 | 3.921875 | 4 | import numpy as np
from src.load_data import load_file
import src.plot as plt
from src.compute_cost import cost_function
from src.gradient_descent import descent
from src.predict import predict
def main():
# First load our data to X and Y
[X, Y] = load_file("./data/data.txt")
# Visualize data using matplo... |
3bd18b9f7d159bf1c4f38139e7170e2f60d47efe | bluetib/scripts | /123/3.py | 198 | 3.5625 | 4 | #!/usr/bin/env /python
# -*- coding:utf-8 -*-
a = [u"北极",u"日本"]
a = ["北极","日本"]
print type(a[0])
print repr(a[0].decode('utf8')).replace(r'\u',r"%u")
#for i in a:
# print type(i)
|
6095446164dca0ea81951ec5c6cd57bcabe0c17a | bluetib/scripts | /123/2.py | 510 | 3.890625 | 4 | import matplotlib.pyplot as plt
plt.figure(1) # the first figure
plt.subplot(211) # the first subplot in the first figure
plt.plot([1,2,3])
plt.subplot(212) # the second subplot in the first figure
plt.plot([4,5,6])
plt.figure(2) # a second figure
plt.plot([4,5,6]) # creates a subplot(111) by default
plt.figure(1) # fi... |
3ec35a29694eabdff4a035f2eeae961eebc982b9 | noor-gate/advent-of-code-20 | /solutions/day3/partone.py | 272 | 3.53125 | 4 | f = open("input.txt", "r")
lines = f.readlines()
pos = 3
trees = 0
for c, line in enumerate(lines):
if c == 0:
continue
while pos >= len(line):
line = line.rstrip('\n') + line
if line[pos] == '#':
trees += 1
pos += 3
print(trees)
|
bfa4d4b9c4fe250cffa7cfae889c7f0589dd548a | npchien751/Data-Structures | /Queue.py | 568 | 3.828125 | 4 | from Deque import Deque
class Queue:
def __init__(self):
self._dq = Deque()
def __str__(self):
return(str(self._dq))
def __len__(self):
return(len(self._dq))
def enqueue(self, val):
self._dq.push_back(val)
def dequeue(self):
return(self._dq.pop_front())
if __name__ == '__main__':
... |
2430358f4748bc650595724c715f1d8268f73ee0 | jkredz/GitHub | /Python GUI Files/multicolorlinegraphtest.py | 2,355 | 3.5625 | 4 | #!/usr/bin/env python
'''
Color parts of a line based on its properties, e.g., slope.
'''
import numpy as np
'''
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib.colors import ListedColormap, BoundaryNorm
x = np.array((1, 2, 3, 4, 5, 6, 7))
y = np.array((2, 4, 5, 6, 7... |
6b44696cc0155e7f800e0c5aa52b4dd4b2453642 | Xnkr/py-vigilant-barnacle | /StackOverflow/52329718.py | 521 | 3.953125 | 4 | import re
def is_like(text,pattern):
if '%' in pattern:
pattern = pattern.replace('%','.*?')
if re.match(pattern,text):
return True
return False
a = "This is another text here"
b = "This%another%here"
print(is_like(a,b))
a = "Thisis sometext"
b = "This % text"
print... |
5604db7345d13c790c154c82e5992c74c997a5bd | Xnkr/py-vigilant-barnacle | /StackOverflow/52148667.py | 1,726 | 3.5 | 4 | from collections import defaultdict
import csv
def spliter(row):
left_team, right_team = row
return {
'left': left_team[:-2].strip(),
'left_score': int(left_team[-2:].strip()),
'right': right_team[:-2].strip(),
'right_score': int(right_team[-2:].strip())
}
dat... |
f4d3987c64a4a5799752f7fe3b00639e599bf856 | Xnkr/py-vigilant-barnacle | /StackOverflow/55779541.py | 547 | 4.0625 | 4 | import os
folder_path = "C:\\Users\\Shankar\\Desktop\\Test"
def expand_folders(folder_names):
result_dict= {}
for name in folder_names:
folder = os.path.join(folder_path, name)
result_dict[name] = os.listdir(folder)
return result_dict
print("Folders List")
print(os.listdir(folder_path))
... |
86a79c712943f1543a55f40f32863a03fe7d8844 | Xnkr/py-vigilant-barnacle | /interactivepython/mergesort.py | 904 | 3.625 | 4 | def mergesort(alist):
print alist
if len(alist) > 1:
mid = len(alist) // 2
lefthalf = alist[:mid]
righthalf = alist[mid:]
mergesort(lefthalf)
mergesort(righthalf)
i = j = k = 0
while i < len(lefthalf) and j < len(righthalf):
if lefthalf[i]... |
887b196aaf893fd065ac4598bbfd92bed2cc946e | Xnkr/py-vigilant-barnacle | /codecademy/bitwise_and.py | 560 | 3.578125 | 4 | def bit_wise_and(n1,n2):
n1_str = list(str(n1))[2:]
n2_str = list(str(n2))[2:]
result = ['0','b']
n1_bit_len = len(n1_str)
n2_bit_len = len(n2_str)
if n1_bit_len!=n2_bit_len:
if n1_bit_len>n2_bit_len:
for i in range(n1_bit_len-n2_bit_len):
n2_str.insert(2,'0')
else:
for i in range(n2_bit_len-n1_bit_... |
36cb9e288ab3bea31c8b4a57f1aec9effaff7c85 | Xnkr/py-vigilant-barnacle | /interactivepython/parsetree.py | 987 | 3.546875 | 4 | from bintree import BinaryTree
from stackds import Stack
eq = '(3+(4*5))'
def parseTree(eq):
op_list = ['+','-','*','/']
eq_list = list(eq)
cStack = Stack()
eTree = BinaryTree('')
cStack.push(eTree)
cTree = eTree
for i in eq_list:
if i == '(':
cTree.insertLeft('')
cStack.push(cTree)
cTree = cTree.... |
e6a76dab6108dfe399974892a52cc360aba59e38 | Xnkr/py-vigilant-barnacle | /hackerrank/dfs.py | 989 | 3.6875 | 4 | def dfs_rec(adjLists, visited, v, goal, path):
visited[v] = True
path.append(v)
if v == goal:
return True
for w in adjLists[v]:
if(not visited[w]):
boo = dfs_rec(adjLists, visited, w, goal, path)
if boo:
return True
path.pop()
# Usual... |
67d26a51553fe5c067045ce27da56e4d5c3c7737 | Xnkr/py-vigilant-barnacle | /StackOverflow/52332281.py | 199 | 3.765625 | 4 | a = [1,2,3]
b = [2,3,4]
y = 5
x = 1
try:
a[x] = b[y]
except IndexError:
try:
a[x]
print('b out of index')
except IndexError:
print('a out of index')
|
4e359e7b1eab5113527f2c22ed8e625efdce6fc1 | bush-man92/python_scripts | /list_of_the_day_backup.py | 6,268 | 3.53125 | 4 | from Tkinter import *
import sqlite3
import tkMessageBox
import datetime
class GUI1:
def __init__(self, master):
self.master = master
master.title("LIST OF THE DAY")
self.username()
self.password()
self.confirm()
def username(self):
self.USERNAME = Label(text="... |
cce46574adec3dbd18d10280bac41580bf699ca9 | rveeblefetzer/literallyp1 | /literallyp1/nyt.py | 2,300 | 3.71875 | 4 | #!/usr/bin python3.6
"""Scrape the New York Times website for Page One stories.
This module scrapes the nytimes.com webpage for front-page stories in the
printed edition, returning for details up to six articles. It grabs the
headline, byline and deck, as well as the text for the edition date.
"""
import requests
fro... |
7ccb83743060b18258178b414afdd1ba418acd3c | lyndsiWilliams/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 901 | 4.28125 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
# TBC
# Set a base case for recur... |
afac8adeb46bbb349d9bcbe227887cde4fec781c | yzx814/pre-learn | /pre-learn/inherit.py | 749 | 3.78125 | 4 |
class Animal:
def __init__(self, name):
self.name = name
def show(self): #不要self name 参数都有,要一个自身就行
print(self.name)
class Cat(Animal):
def __init__(self, name):
super().__init__(name) #在父类的基础上加什么东西,加名字所以name,而不是self
cat1 = Cat("big white")
cat1.show() #show 继承了父类show的方法,即... |
1d8995e7f6dfcb6e67225be6a04cd780aba36f39 | GarrettGunnell/cs261-Binary-Search-Tree | /test_bst.py | 8,399 | 3.828125 | 4 | import unittest
from bst import BinarySearchTree
class TestBinarySearchTree(unittest.TestCase):
'''
Initialization
'''
def test_instantiation(self):
'''
A Binary Search Tree exists.
'''
try:
BinarySearchTree()
except NameError:
self.fai... |
1a864e2fe6a3820224a4b3fd86b947d1fc7f8cb7 | kaitoyokohamaa/cs50 | /Week6/pset6/mario/less/mario.py | 384 | 3.875 | 4 | from cs50 import get_int
def main():
t = get_positive_int()
for i in range(t):
for f in range(t-i-1):
print(" ", end="")
for j in range(i+1):
print("#", end="")
print("")
def get_positive_int():
while True:
n = get_int("Positive Integer: ")
... |
86731fb0db8015f3b327b367690f3dc8ba360b12 | bzimor/AdvancedPython | /Assignment 6/task2.py | 8,116 | 3.828125 | 4 | import sys
class Parser:
'''
use 'exit' to terminate the program
'''
def __init__(self):
self.string = ''
self.index = 0
self.saved_result = []
def set_value(self, string):
self.string = string
self.index = 0
def getValue(self):
value = self.p... |
4bdcb6d08cf703d34a29db63f39d786d2d5f5a4a | darienjh/Chapter_9 | /Challenge2.py | 606 | 3.890625 | 4 | #Darien Hayes
#Challenge 2
from random import randint
class Player1(object):
"""Player 1's random card"""
def hand1(self, name):
name = input("Name? ")
print("The card", Name , "got is ")
print(randint(0,100))
return;
class Player2(object):
"""Player 2's random card"""
... |
1d05a84eed4a783996779cc9abe70a131995d3c5 | fahimfaisaal/Hello-Python | /fundamentals_of_python/3_loop-project.py | 299 | 4.21875 | 4 | # Odd Numbers
odd_number = int(input("Enter your number for Odd: "))
for i in range(0, odd_number + 1):
if i % 2 != 0:
print(i)
# Even number
even_number = int(input("Enter your number for even: "))
for i in range(0, even_number + 2):
if i % 2 == 0:
print(i)
|
f500e657a0a3410f4719a18fc6d469ef7ea41546 | aarthymurugappan101/operators | /string_concat.py | 115 | 3.796875 | 4 | fruit ="banana"
print(fruit)
fruit = fruit + fruit
print(fruit)
fruit = "banana "
fruits = fruit*10
print(fruits) |
d8a845268a0457ddc6ef03f4a4b0f0f289350780 | LukeSkyRed/30-Days-of-Python | /Day7 - Split, Join, and Slices .py | 3,368 | 4.1875 | 4 | #Day 7: split, join, and Slices
'''
user_numbers = input("Please enter 5 numbers separated by commas: ") # 1,2,3,4,5
numbers_list = user_numbers.split(",")
print(type(numbers_list))
print(user_numbers)
print(numbers_list) # ['1', '2', '3', '4', '5']
#--------------------------------------------------------... |
c91b75bc70179a2a79dc00c0f4f9f3f43722d7f3 | LukeSkyRed/30-Days-of-Python | /Day6 - Project - Fizz Buzz Game.py | 953 | 3.984375 | 4 | #Day 6 Project: Fizz Buzz
#Fizz Buzz Game
#Rules:
#One player starts by saying the number 1.
#Each player then takes it in turns to say the next number, counting one at a time.
#If the number is divisible by 3, instead of saying the number, the player should say, "Fizz".
#If the number is divisible by 5, instea... |
988355a97434835f008480d8b018e08734ee836b | fseda/CS50-2020 | /pset6/cash/cash.py | 665 | 3.734375 | 4 | # Calculate the minimum number of coins required to give a user change
from cs50 import get_float
from math import floor
def main():
# User input for change owed in dollars (require positve)
while True:
dollars = get_float("Change owed: ")
if dollars < 0:
continue
else:
... |
c8a2c89e463f61c9da8e383f036694ae422d1fcc | kkristof93/AoC-2017 | /Day-04/day04-part2.py | 355 | 3.609375 | 4 | #!/usr/bin/python
valid = 0
with open("input.txt") as file:
for line in file:
phrases = line.replace("\n", "").split(" ")
sorted_phrases = list(map(lambda x: ''.join(sorted(x)), phrases))
sorted_phrases_set = set(sorted_phrases)
if len(sorted_phrases) == len(sorted_phrases_set):
... |
809834aff4733e0c31c5ac9718839e4faa2db4b1 | Kruneet/Artificial-Intelligence | /Iterative Deepening Astar with heuristics/15puzzle_idastar.py | 5,774 | 3.53125 | 4 | #CS 411 - Assignment 7 Solution
#Iterative Deepening A star Search on 15 Puzzle
#2018 Fall
import random
import math
import time
import psutil
import os
from collections import deque
from heapq import *
#This class defines the state of the problem in terms of board configuration
class Board:
def __init__(self,tiles... |
d7c8c3cde3d62e711a3aaac0cb30b4e0c837d9cf | hongaik/mycustomscripts | /secretary.py | 1,950 | 3.859375 | 4 | #This script is a simulation of the Secretary Problem.
#imagine an administrator who wants to hire the best secretary out of n rankable applicants for a position. The applicants are interviewed one by
#one in random order. A decision about each particular applicant is to be made immediately after the interview. On... |
3d491bf5193d974410fffb775238eb9e19cb6023 | KarinShimel/Hopfield-Reconstruction | /main.py | 7,529 | 3.625 | 4 | import random
from typing import List
import numpy as np
import matplotlib.pyplot as plt
def get_digits_from_txt(filename, num_of_letters):
with open(filename) as f:
content = f.readlines()
number = ""
all_numbers = []
i = 0
for line in content:
line = line.rstrip("\n")
nu... |
d3b1c28159bd929e0e09b744cbf22ea69c8d8bef | devaspirant0510/codefight | /intro/shapeArea.py | 411 | 3.515625 | 4 | #========================================================
# blog : https://blog.naver.com/nova020510/222087081788 #
#========================================================
# case 1
def shapeArea(n):
return n*n+(n-1)*(n-1) #택시기하학
#========================================================
# case 2
def shapeArea(n):... |
daa4fe0386e478796cb93ecda15ce889a3b7a9b4 | mateen91/python-bootcamp | /P4_Casting.py | 161 | 3.671875 | 4 | # TYPE CASTING
x = '10.5'
print(x)
print(type(x))
x = float(x)
print(x)
print(type(x))
x = int(x)
print(x)
print(type(x))
x = str(x)
print(x)
print(type(x))
|
9553b328bdd29b65feeacae5d1b0e656c7f9eb82 | Aalap4/EEE-591-Python-for-Rapid-Engineering | /GUI_Tkinter/hw4.py | 3,932 | 3.5625 | 4 |
#Aalap Paragbhai Doshi
#ASU ID 1217130629
# Retirement Savings calculator
import numpy as np
from tkinter import * # import everything from tkinter
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
fields_GUI = ('Mean Return(in %)', 'Std Dev R... |
7712f63d4278df1e6ef5ecdd6aee8ea2a6591b45 | mkcacchione/Self-taught-programmer-exercises | /Chapter 1-3 practice challenges.py | 787 | 4.0625 | 4 | #question 1 page 6
checklist = ("shower", "get ready", "school", "home", "coder class", "sleep")
print(checklist)
#question 1 page 11
print ("my name is MK. I am excited to learn python")
#question 1 page 44
print("three", "different", "strings")
#question 2 page 44
x=20
if x<10:
print("x is less than 10")
else... |
eeff9691ae85002438ebf4440d5374e102a65e4b | ivy-liu/mypython | /python_re_study/five_0408.py | 1,723 | 3.734375 | 4 | ##############################
# 5.类
##############################
#以继承objec的方式来定义1个类
class Human(object):
#类属性,所有类实例都共享
species="H.sapiens"
#基本的构造函数,当类实例化的时候会自动被调用
#注意双下划线开头和结尾的变量是python保留的
#你不应该自己定义类似风格的变量
def __init__(self,name):
#将参数里name赋值个同名的实例属性
self.name=name
... |
3a2d5f04ac2d3fc8d498335ab744caa752df7fde | balasubramanianramesh/Python_Training | /forLoop.py | 302 | 4.4375 | 4 | for letter in 'Python': # First Example
print ('Current Letter :', letter)
fruits = ['banana', 'apple', 'mango']
for fruit in fruits: # Second Example
print ('Current fruit :', fruit)
for index in range(1,3):
print ('fruits[%d]: %s'% (index, fruits[index]))
print ("Good bye!") |
3726d43a96c8013b95451ed8af7814935e8f9287 | SmitRao/Games-Interface | /strategy.py | 812 | 3.546875 | 4 | """
Back-end code implementation for game_interface.
CSC148 Winter, Assignment 1.
January 30, 2018.
"""
from typing import Any
import random
from interface_set_up import Game
# TODO: Adjust the type annotation as needed.
def interactive_strategy(game: Game) -> Any:
"""
Return a move for game through intera... |
bfb43b79463db4ff326483cf6690dee7c7f14a5f | highschooljavascript/highschooljavascript.github.io | /tele.py | 1,725 | 3.78125 | 4 | # asks for your phone number in digits, outputs in alphabet combintations
# comment 2
humanInput = input("What's your phone number?")
digit = 0
v = 0
v1 = 0
v2 = 0
v3 = 0
v4 = 0
v5 = 0
v6 = 0
v7 = 0
a = 0
b = 0
c = 0
d = 0
e = 0
f = 0
g = 0
i = 0
# for each of 7 digitis
for i in range(0, 7):
digit = humanInput[i]
... |
9d4d2de69e1260139bbd3c33baf97f03edaa60f9 | IvanBaroni/AulasUSP | /L6Ex4.py | 990 | 3.875 | 4 | #Lista 6 Exercício 4
# Escreva a função remove_repetidos que recebe como parâmetro uma lista
# com números inteiros, verifica se tal lista possui elementos repetidos
# e os remove. A função deve retornar uma lista correspondente à primeira
# lista, sem elementos repetidos. A lista retornada deve estar ordenada.
... |
bd262b88ee531fb778e5e415851e5beb75de8c56 | IvanBaroni/AulasUSP | /L2Ex1.py | 771 | 3.90625 | 4 | ### Semana 2, Exercício 1
# Bibliotecas
import math
#Pede as parada
a = int(input("Digite o valor do termo A: "))
b = int(input("Digite o valor do termo B: "))
c = int(input("Digite o valor do termo C: "))
delta = b**2 - 4*a*c
# Devolve com todos os possíveis casos
if delta < 0:
print("esta equaç... |
43e3864bec9d6b38a36d0f52601f3eeb2101ea6a | IvanBaroni/AulasUSP | /L3Ex5.py | 567 | 3.984375 | 4 | ### Ex.5 Escreva um programa que receba um número inteiro positivo na entrada e verifique se é primo.
### Se o número for primo, imprima "primo". Caso contrário, imprima "nao primo".
num = int(input("Digite um número inteiro: "))
divisivel = False
i = num - 1
sobra = 0
numMenor = num - 1
if num =... |
fbcad04b9b0bdfd905a4163405b971820b1177c7 | IvanBaroni/AulasUSP | /L4Ex1.py | 577 | 4 | 4 | ### Lista 4 Ex1
# 'Fizz' se o número for divisível por 3 e não for divisível por 5;
# 'Buzz' se o número for divisível por 5 e não for divisível por 3;
# 'FizzBuzz' se o número for divisível por 3 e por 5;
def fizzbuzz(num):
div3 = num % 3
div5 = num % 5
if div3 == 0 and div5 != 0:
return "Fizz... |
d3919b3a5b91af1d7bf710866b1c59e98374173f | IvanBaroni/AulasUSP | /L7Ex1.py | 902 | 3.984375 | 4 | # Lista 7 Exercício 1
# Escreva uma função imprime_matriz(matriz), que recebe uma matriz
# como parâmetro e imprime a matriz, linha por linha. Note que NÃO
# se deve imprimir espaços após o último elemento de cada linha!
#def imprime_matriz2(matriz):
# for linha in matriz:
# for num in linha:
# ... |
3e081906f78c28af81ae473bdd1b853871b603e3 | rkpillai1995/Big-Data-Analytics | /Otsu Thresholding/otsu_binarize.py | 7,003 | 3.921875 | 4 | __author__ = 'Rajkumar Pillai'
import matplotlib.pyplot as plt
import numpy as np
"""
CSCI-720: Big data analytics
Author: Rajkumar Lenin Pillai
Description: This program implements the otsu method to compute the threshold speed to binarize the given data
"""
def weight(hist, bins, start, end, total_e... |
a6301d037f498c3fd69e78e18a25b6c9334c7ba4 | phenomenalprince/Python_Programs | /swap.py | 184 | 4.09375 | 4 | def swap(a,b):
print("Before swap")
print(a,b)
a,b = b,a
print("After Swap")
print(a,b)
a = int(input("Enter a no. :: ))
b = int(input("Enter a no. :: ))
swap(a,b)
|
3b2a142c12d3195f4eb5490c5bd7411f58c48de4 | nneuro/reagent_with_Nika | /app/order/calculator.py | 341 | 4.03125 | 4 |
molar_conc = float(input("Введите молярную концентрацию: "))
volume = float(input("Введите объём: "))
molar_mass = float(input("Введите молярную массу в единицах гр/моль: "))
mass = molar_conc * volume * molar_mass
print(f' Масса равна {(mass):.{2}f}')
|
251c4c2da70405800bd2896dc813db82d5ca556f | dimadm/fromMyWork | /python6.py | 326 | 3.5625 | 4 | import sys
def is_prime (i):
if i < 10:
res = "True"
else:
res = "False"
return res
#------------------------------------------------------------
i = 0
while i <= 1000:
if is_prime (i) == "True":
print ("Число ", i, "простое")
i += 1
else:
print ("Число ", i, "составное")
i += 50
|
5ee99fa2f2ab0e46ed37970e8a7f749af54cfcc8 | Kiricon/ProjectEuler | /15:Lattice paths/main.py | 207 | 3.546875 | 4 |
branches = 0
w, h = 21,21
Matrix = [[1 for x in range(w)] for y in range(h)]
for x in range(1, w):
for y in range(1, h):
Matrix[x][y] = Matrix[x][y-1]+Matrix[x-1][y]
print Matrix[w-1][h-1]
|
1727bea1da6831b579d93882ba05f672ffe799d8 | Mortif3767/Python-practice | /1st.py | 78 | 3.546875 | 4 | print "hello world"
name=raw_input("what's your name")
print"hello,"+name+"!"
|
2cad560742558a7f36c24622b62af15f7dc69dd1 | rhenderson2/python1-class | /Chapter03/hw_3-4.py | 313 | 4 | 4 | # homework assignment section 3-4
guest_list = ["Abraham Lincoln", "President Trump", "C.S.Lewis"]
print(f"Hello {guest_list[0]},\nYou are invited to dinner at my house.\n")
print(f"Hello {guest_list[1]},\nYou are invited to dinner at my house.\n")
print(f"Hello {guest_list[-1]},\nYou are invited to dinner at my house.... |
1d270a8cb6d117d46465e99252a2c7302489eed6 | rhenderson2/python1-class | /chapter05/hw_5-10.py | 444 | 3.9375 | 4 | # homework assignment section 5-10
current_users = ['rick', 'bob', 'bill', 'scott', 'joe']
new_users = ['George', 'Travis', 'Bill', 'BOB', 'Mary']
for new_user in new_users:
if new_user.lower() in current_users:
print(f"Sorry {new_user},\n\tyou will need to use"
" a different\n\tusername as tha... |
b4dc1ff28af4c58fc360147bbdb37308c53a09be | rhenderson2/python1-class | /chapter05/hw_5-8.py | 323 | 4.03125 | 4 | # homework assignment section 5-8
usernames = ['Rick', 'Bob', 'Bill', 'Admin', 'Joe']
for username in usernames:
if username == 'Admin':
print("Hellow Admin,"
" would you like to see a status report?")
else:
print(f"Hello {username}, thank you for logging"
f" in again."... |
1e1ded5c792e1807e78c38c17891cb31d6e12d77 | rhenderson2/python1-class | /chapter06/hw_6-6.py | 390 | 4.0625 | 4 | # homework assignment section 6-6
favorite_languages = {
'jen': 'python',
'sarah': 'c',
'edward': 'ruby',
'phil': 'python',
}
take_poll = ['ted', 'jen', 'bill', 'bob', 'mary', 'sarah']
for name in take_poll:
if name in favorite_languages.keys():
print(f"\nThanks {name.title()}, I see you took my poll!")
else... |
761184045db21f220fec3944baa74b7e18d6fd51 | rhenderson2/python1-class | /chapter06/hw_6-7.py | 418 | 4.125 | 4 | # homework assignment section 6-7
friend = {'first_name': 'john', 'last_name': 'wendler', 'city': 'colorado springs'}
wife = {'first_name': 'niki', 'last_name': 'henderson', 'city': 'fort wayne'}
child = {'first_name': 'carrissa', 'last_name': 'griffith', 'city': 'london'}
people = [friend, wife, child]
for person in... |
64742533ee6dd3747a8e1945a0ae3d74dd00bee7 | rhenderson2/python1-class | /Chapter03/hw_3-5.py | 627 | 4.25 | 4 | # homework assignment section 3-5
guest_list = ["Abraham Lincoln", "President Trump", "C.S.Lewis"]
print(f"Hello {guest_list[0]},\nYou are invited to dinner at my house.\n")
print(f"Hello {guest_list[1]},\nYou are invited to dinner at my house.\n")
print(f"Hello {guest_list[-1]},\nYou are invited to dinner at my house.... |
7dd5eee5955c93046eea111062b1c79d307aec2a | rhenderson2/python1-class | /chapter08/hw_8-4.py | 306 | 4.03125 | 4 | # homework assignment section 8-4
def make_shirt(size= 'Large', text= 'I love Python.'):
print(f"You have ordered a {size} shirt with a"
f" message that reads: \n\t'{text}'")
make_shirt()
print("\n")
make_shirt(size= 'Medium')
print("\n")
make_shirt(size= 'Small', text= 'Different Message')
|
271d7bfec00f8541e2b2fe672e5707a08146fb1a | rhenderson2/python1-class | /chapter04/hw_4-6.py | 120 | 4.125 | 4 | # homework assignment section 4-6
odd_numbers = list(range(1,21,2))
for odd_number in odd_numbers:
print(odd_number) |
18a6c95366363fbef4fb4a1b9a59bfd08bbae05e | rhenderson2/python1-class | /chapter06/hw_6-2.py | 221 | 4.09375 | 4 | # homework assignment section 6-2
favorite_numbers = {'John': 7, 'Mike': 4, 'John L': 2, 'Niki': 8, 'Mary': 4}
for key,value in favorite_numbers.items():
print(f"\nName: {key}")
print(f"Favorite Number: {value}")
|
31a2592d1d1b50157f2657d6c69977bc4cb5b4bf | gingkg/happyleetcodeeveryday | /sword_to_offer/56/main.py | 940 | 3.796875 | 4 | """
剑指 Offer 56 - I. 数组中数字出现的次数
一个整型数组 nums 里除两个数字之外,其他数字都出现了两次。请写程序找出这两个只出现一次的数字。要求时间复杂度是O(n),空间复杂度是O(1)。
示例 1:
输入:nums = [4,1,4,6]
输出:[1,6] 或 [6,1]
示例 2:
输入:nums = [1,2,10,4,1,4,3,3]
输出:[2,10] 或 [10,2]
限制:
2 <= nums.length <= 10000
"""
from typing import List
class Solution:
def singleNumbers(self, nums: Li... |
7b3389bd539ba96253d62de7e363af07183f2291 | figgybit/alogrithms | /splay_tree/SplayTree.py | 3,750 | 3.875 | 4 | # import SplayTree
# tree = SplayTree.SplayTree(10)
# tree.add(2)
# tree.add(11)
# tree.add(10)
# tree.add(20)
# tree.add(1)
# tree.add(8)
# tree.add(9)
# tree.print_tree()
from PIL import Image, ImageDraw, ImageFont
class Node():
def __init__(self, value=None, parent=None, left=None, right=None):
self.value = ... |
aa9ebba0d4c3291ac98248599d03e013deee97d3 | rbarden3/machine_learning | /AI/square_puzzle.py | 11,198 | 3.78125 | 4 | # Course: CS4242
# Student name: Raleigh Barden
# Student ID: 000-86-1747
# Assignment #: #1
# Due Date: 09/25/2020
# Description: Create a program to solve an 8 Square Puzzle using an A* algorythm. It should accept any input, goal pairs.
# Developer Environment: VS Code
#%%
import copy
import random
import numpy ... |
2e98ee08decbe7f8411ca72334bdbd82ceccdf6f | IniobongUdom7/PONGGAME | /paddle.py | 551 | 3.890625 | 4 | from turtle import Turtle
from ball import Ball
class Paddle(Turtle):
#creating clas paddle from turtle
def __init__(self, position):
super().__init__()
self.shape("square")
self.color("black")
self.shapesize(stretch_wid=6,stretch_len=1)
self.penup()
self.goto(positi... |
dcbab3122f7cdbc029c649de37bc4677e54394fd | RobertElias/AlgoProblemSet | /Easy/fibonacci.py | 752 | 3.796875 | 4 | #First Solution
#O(2^n) time | O(n) space complexity
def getNthFib(n):
if n == 2:
return 1
elif n == 1:
return 0
else:
return getNthFib(n-1) + getNthFib(n - 2)
#Second Solution
# O(n) time | O(n) space complexity
def getNthFib(n, memoize =-{1: 0, 2: 1}):
if n in memoize:
... |
2f84d347adabaa3c9788c2b550307e366998fc6f | RobertElias/AlgoProblemSet | /Easy/threelargestnum.py | 1,169 | 4.4375 | 4 | #Write a function that takes in an array of at least three integers
# and without sorting the input array, returns a sorted array
# of the three largest integers in the input array.
# The function should return duplicate integers if necessary; for example,
# it should return [10,10,12]for inquiry of [10,5,9,10,12].
#... |
3ffaca01ef3539b50082de91e8ad6de819519441 | albinvestin/AOC2018 | /day_8/main.py | 1,279 | 3.828125 | 4 |
def read_file(input):
with open(input, 'r') as file:
for line in file:
sequence = list(map(int, line.split(' ')))
return sequence
class Node:
def __init__(self, no_children, meta_data_length):
self.no_children = no_children
self.meta_data_length = meta_data_... |
dcbe618da968ad523b20f55a90e23348a2cbfa6b | Shriya2409/project110 | /class 110/project.py | 923 | 3.71875 | 4 | import statistics
import pandas as pd
import csv
import random
import plotly.figure_factory as ff
df=pd.read_csv("data.csv")
data=df["average"].tolist()
population_mean=statistics.mean(data)
population_deviation=statistics.stdev(data)
print(population_mean)
print(population_deviation)
def random_set(co... |
5ad6a983185811944fcd24dee7a72e5f01a5f77b | abrahammurciano/homework | /4th-Year/Intro-to-AI/hw4/dataio.py | 1,043 | 4.0625 | 4 | from typing import List, Tuple
from vector import Vector
from gender import Gender
import csv
def read(filename: str) -> Tuple[List[Vector], List[str]]:
"""Read vectors from a CSV file
Args:
filename (str): The name of the file to read.
Returns:
Tuple[List[Vector], List[str]]: A list of vectors in the file a... |
555472562812356abe209f9af55505d3fc9d06b4 | abrahammurciano/homework | /4th-Year/Intro-to-AI/hw4/distance.py | 804 | 3.734375 | 4 | from typing import Callable, Sequence
from vector import Vector
DistanceFunction = Callable[[Sequence[float], Sequence[float]], float]
class Distance:
def __init__(
self, start: Vector, vector: Vector, distance_func: DistanceFunction,
):
"""Construct a distance object for the distance to `vector` from `start`.... |
a29bd1487cbd3bb1af10ab9e52375e96ec77a417 | abrahammurciano/homework | /3rd-Year/Intro-to-IT-Security/HW2---Encryption/HW2Q3.py | 397 | 3.71875 | 4 | from HW2Q1 import char_shift
def ceaser_cypher(message, offset, first='a', last='z'):
return "".join([char_shift(char, offset, first, last) for char in message.lower()])
if __name__ == "__main__":
message = input("Enter a message to encrypt:\n")
offset = int(input("Enter an offset to use in your ceaser cypher:\n")... |
fa6c28bb7b589a701aa8b8868f814affc2b791cd | abrahammurciano/homework | /4th-Year/Intro-to-AI/hw4/step_2.py | 2,428 | 3.828125 | 4 | from distance import DistanceFunction
from scipy.spatial.distance import euclidean, hamming, cityblock
from classify import classify_file
def classify_mytest(
k: int, distance_func: DistanceFunction,
):
"""Classify all the vectors in mytest.csv using the given distance function and k.
The classified data is store... |
060b043e11b67ad11e5ecc8dc2076dacd6efa1cf | WebSofter/lessnor | /python/1. objects and data types/types.py | 695 | 4.21875 | 4 | """
int - integer type
"""
result = 1 + 2
print(result, type(result))
"""
float - float type
"""
result = 1 + 2.0
print(result, type(result))
"""
string - string type
"""
result = '1' * 3
print(result, type(result))
"""
list - list type
"""
result = ['1','hello', 'world', 5, True]
print(result, type(result))
"""
tu... |
ad91bcc25b5f9aa12bae6941240207d18e6f575f | KRHS-GameProgramming-2018/JP-madlibs | /getInput.py | 7,962 | 4.1875 | 4 | import screens
import sys
import EasterEgg
def getMenuInput():
goodInput = False
while not goodInput:
response = raw_input(" > ")
if (response == "1"
or response == "One"):
response = "1"
goodInput = True
elif (response == "Q"
or respon... |
d637c3d16a75d46164416e65e290ed15c7a59a45 | Do-Hoon-Kim/test1 | /ex4.py | 65 | 3.984375 | 4 | num1 = 3
if num1 % 2 ==0:
print 'even'
else:
print 'odd'
|
2eceb543d411425462d2368e12d16a09a30f2b59 | Do-Hoon-Kim/test1 | /ex5.py | 254 | 3.75 | 4 | # -*- coding: utf-8 -*-
num1 = 21
if num1 %3 == 0 and num1 %7 == 0:
print '3의 배수이면서 7의배수'
elif num1 %3 == 0:
print '3의 배수'
elif num1 %7 ==0:
print '7의 배수'
else:
print '3의배수도 7의배수도 아니다'
|
2fed73eea5d488ef244e378719effe81816275ac | vungocbinh2009/pytexexam | /pytexexam/answer.py | 532 | 4.03125 | 4 | class Answer:
"""
This class is used to store 1 answer in a question.
"""
def __init__(self, answer_key: str, answer: str, is_true_answer=False):
"""
This method initializes an Answer object.
:param answer_key: Answer
:param answer: Answer to the question.
:param... |
2280fcfb7233a2435c5f4a4be6d8b232895d855e | tricklynch/CS4341_Assignment_2 | /puzzles/population.py | 3,997 | 3.796875 | 4 | import random
import copy
class Population:
def __init__(self, options, mutation_chance, size, individual_class, survivors):
# Size is the number of individuals in the population
self.size = size
# invdividual_class is the class to use when constructing an individual
self.individua... |
a11accc23a2809ce8d17b1072a063c64fcc0346f | haymanguddanti/ML_Lab | /ML_Lab/5.py | 669 | 3.703125 | 4 | totalRecords = 10
numberGolfRecreation = 4
probGolf = numberGolfRecreation/totalRecords
print("Unconditional probability of golf: = {}".format(probGolf))
# conditional probability of `single' given `medRisk'
# bayes Formula
# p(single|medRisk)=p(medRisk|single)p(single)/p(medRisk)
# p(medRisk|single)=p(medRisk ∩... |
288ce1a9dfb0da2c0b587799f5c9984740ebf95b | mwagrodzki/codecool_dojos | /minMaxAvg.py | 1,263 | 3.859375 | 4 | def minimum(list):
k = list[0]
iteration = 1
while iteration < len(list):
if k > list[iteration]:
k = list[iteration]
iteration += 1
print("Minimum "+str(k))
#https://www.draw.io/#G1kovDyIns99OfjnCnf15F8nxLYobvYJG2
def maximum(list):
k = list[0]
iteration = 1
... |
a73038884d319677324fc42c0e32768604b0f66d | mwagrodzki/codecool_dojos | /gdc.py | 362 | 3.671875 | 4 | import sys
firstNumber = int(sys.argv[1])
secondNumber = int(sys.argv[2])
while secondNumber != 0:
if firstNumber > secondNumber:
firstNumber = firstNumber - secondNumber
else:
secondNumber = secondNumber - firstNumber
print("Greatest common divisor of "+sys.argv[1]+" and "+sys.argv[2]+" is "... |
42f0dd12e80adbf732c8cef53f1deff43826049f | mwagrodzki/codecool_dojos | /poker_hand.py | 995 | 4.15625 | 4 | def poker_hand(table):
'''
Write a poker_hand function that will score a poker hand. The function
will take an array 5 numbers and return a string based on what is inside.
python3 -m doctest poker_hand.py
>>> poker_hand([1, 1, 1, 1, 1])
'five'
>>> poker_hand([2, 2, 2, 2, 3])
'four... |
e2f04c145a4836d14f933ae04557dd6598561af2 | blfortier/cs50 | /pset6/cash.py | 1,657 | 4.1875 | 4 | from cs50 import get_float
def main():
# Prompt the user for the amount
# of change owed until a positive
# number is entered
while True:
change = get_float("Change owed: ")
if (change >= 0):
break
# Call the function that will
# print the amount of coins that
... |
1b279fc019086ef08f7d213b5a716ec9685c9fbf | joreilly25/rock-paper-scissors-python | /rps.py | 2,183 | 4.0625 | 4 | import random
playerScore = 0
compScore = 0
def computerPlay():
compSelections = ["rock", "paper", "scissors"]
compSelection = random.choice(compSelections)
return compSelection
def userPlay():
while True:
playerSelection = input("Please enter Rock, Paper, or Scissors: ").lower()
if... |
4164c5ecc2da48210cb32028b01493a06b111873 | amymou/Python- | /masterticket.py | 2,298 | 4.34375 | 4 | SERVICE_CHARGE = 2
TICKET_PRICE = 10
tickets_remaining = 100
# Outpout how many tickets are remaining using the ticket_remaining variable
# Gather the user's name and assign it to a new variable
names = input("Please provide your name: ")
# Prompt the user by name and ask how many tickets they would like
print("Hi {}... |
bb3aaa340d088cc4c1638cb4729ad3a92686d146 | ascaniopy/python | /exerciciosModuloIII/ex085-listasComParesImpares.py | 382 | 3.78125 | 4 | num = [[], []]
valor = 0
for c in range(1, 8):
valor = int(input('Digite o {}º valor: '.format(c)))
if valor % 2 == 0:
num[0].append(valor)
else:
num[1].append(valor)
print('=' * 50)
num[0].sort()
num[1].sort()
print('Os valores pares digitados foram: {}'.format(num[0]))
print('Os valores í... |
f0e10f61b8608d95cd09912b85e6b725db6afb87 | ascaniopy/python | /Funcoes/ex099-descobreMaior.py | 582 | 3.828125 | 4 | from time import sleep
def maior(* num):
cont = maior = 0
print('=' * 45)
print('\nAnalizando os valores passados... ')
for valor in num:
print('{} '.format(valor), end='', flush=True)
sleep(0.3)
if cont == 0:
maior = valor
else:
if valor > maior:... |
2fa9a8d7c4f432b72b81255380420987524183dc | ascaniopy/python | /Telas/05-widgetButton.py | 1,006 | 3.578125 | 4 | import tkinter as tk
from tkinter import messagebox
class Tela:
def __init__(self, master):
self.nossaTela = master
#sef.coisa = tk.NomeDoWidget(widgetPai, opcoesDeConfiuracao)
self.lbl = tk.Label(self.nossaTela, text="Abrir caixa", font=("Verdana", "16"), relief="raised")
self.lb... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.