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 |
|---|---|---|---|---|---|---|
5a00da3045482870d8c5ab19b300e8584fd82527 | ibrahimkamal7/Data-Structures | /Josephus Problem/Josephus.py | 2,143 | 3.578125 | 4 | class Node:
def __init__(self,value,next = None):
self.__value = value
self.__next = next
def __str__(self):
return "[ "+str(self.__value)+" ]"
def getNext(self):
return self.__next
def setNext(self,n):
... |
34f4b29aac2ccff01a271390041814546617ad3e | RogerXu1048/VandyHack | /solar_template.py | 2,357 | 3.515625 | 4 | #solar.py
#This uses the first four planets of the solar system and the sun
from codinglib import*
from body_template import Body
from system_template import System
from math import sqrt
'''import all of codinglib, the System class from system program, and the Body class from your body program (3 lines)
the window widt... |
a4eddae42b365b5884a465424f2a6ca1203f358f | iliankostadinov/hackerrank-python | /write-a-function.py | 537 | 4.15625 | 4 | #!/usr/bin/python
def is_leap(year):
leap = False
if year % 400 == 0:
leap = True
elif year % 100 == 0:
leap = False
elif year % 4 == 0:
leap = True
return leap
if __name__ == '__main__':
year = int(raw_input())
if year < 1900:
print "You should enter y... |
8b60b54e844e182044b3a69792e27b9e379b1f90 | Cimmanuel/weather_terminal | /weather_terminal/core/forecast.py | 2,862 | 3.53125 | 4 | # This is a class representing the weather
# forecast data that the parser returns.
from datetime import date
from .forecast_type import ForecastType
class Forecast:
def __init__(
self, current_temp, wind, humidity, dew_point=None, pressure=None, visibility=None,
high_temp=None, low_temp=None, d... |
01c6c06f6f4e4e988230ee6b22edb32098fd9854 | GelouKaroll/LPy_day2 | /homework1_1.py | 639 | 4.09375 | 4 | def age_detector(in_age):
if in_age.isdigit():
in_age = int(in_age)
if in_age <= 0:
return "Please insert your reale age"
elif 0 < in_age <= 7:
return "go to the kindergarten!"
elif 7 < in_age <= 18:
return "you are only schoo... |
2851fbf8557b508c73ef5cc90688f77fc8666eb3 | programmingdevil101/learningAlgorithmAndDataStructure | /test.py | 485 | 3.765625 | 4 | import random
def euclidGCD(num1, num2):
while num1 != num2:
if num1 > num2:
num1 -= num2
else:
num2 -= num1
return num1
def majority(arr):
m = None
i = 0
for j in range(len(arr)-1):
if i == 0:
m = arr[j]
i = 1
elif m == arr[j]:
i += 1
else:
i -= 1
return m
#arr = [1, 3... |
410b63abc41d55a376e059222b43e145ecc44ee3 | talsky1/Python3-course | /dictionaries/alien.py | 855 | 3.796875 | 4 |
alien_0 = {'color': 'green', 'points': '5'}
print(alien_0['color'])
print(alien_0['points'])
alien_0['x_pos'] = 0
alien_0['y_pos'] = 25
alien_0['speed'] = 'medium'
print(f"Alien`s original position is {alien_0['x_pos']}.")
# print(alien_0)
# print('\n')
# print(f"The alien`s color is {alien_0['color'].upper(... |
33fb93a2bda6c8c23a1879a392346e7c86e71295 | talsky1/Python3-course | /working_with_lists/4.6_odd_numbers.py | 312 | 4.0625 | 4 | #4.6 odd numbers
numbers = list( range(1,21,2) )
print(numbers)
#4.7 Threes
numbers = [number * 3 for number in range(3,31)]
print(numbers)
#4.8 Cubes
numbers = []
for number in range(1,11):
numbers.append(number ** 3 )
print(numbers)
#4.8.1
numbers = [number ** 3 for number in range(1,11)]
print(numbers) |
89f58c7acfb6c618fcc2ef8572b562bc36f66480 | talsky1/Python3-course | /if/not_empty_list.py | 293 | 3.53125 | 4 | requested_toppings = []
if requested_toppings:
for requested_topping in requested_toppings:
print(f'{requested_topping.title()} has been added to your pizza')
print('Finished making your pizza')
else:
print('Are you sure that you want you pizza blank?') |
7f631e6c8885887cad558595cdade50dc1f3372a | talsky1/Python3-course | /dictionaries/user.py | 223 | 4.03125 | 4 | user_0 = {
'username': 'talsky',
'first_name': 'tal',
'last_name': 'zohar',
}
print(user_0)
for key, value in user_0.items():
print(f"\nThe key is: {key}")
print(f"The value is: {value}") |
c9b65f1b9f9f93dfc8c93d27ee8e61fb3c6d7aa9 | talsky1/Python3-course | /dictionaries/6-2_favorite_numbers.py | 436 | 3.6875 | 4 | favorite_numbers = {
'tal': '10',
'ofri': '15',
'yahel': '3',
'sky': '5',
'tofi': '7',
}
print(f"Tal`s favorite number is {favorite_numbers['tal']}")
print(f"Ofri`s favorite number is {favorite_numbers['ofri']}")
print(f"Yahel`s favorite number is {favorite_numbers['yahel']}")
print(f"... |
41644ac59f37b74d92216b498b8a0024f22f30ec | elias19-meet/YL1-201718 | /project/Ball.py | 1,457 | 3.8125 | 4 | from turtle import Turtle
import turtle
import time
import random
##class Ball(Turtle):
## def __init__(self,x,y,dx,dy,r,color):
## self.x=x
## self.y=y
## self.dx=dx
## self.dy=dy
## self.r=r
## self.color=color
## Turtle(self):
## self.color(color)... |
58ae2e32d10f0a0e23900e284ae21a4f31a80bd3 | adriana19-meet/yl201718 | /lab5/collisions.py | 513 | 3.828125 | 4 | from turtle import*
import random
class Ball(Turtle):
def __init__(self,radius,color,speed):
turtle.__init__(self)
self.shape("circle")
self.shapesize(raduis/10)
self.raduis = raduis
self.color = color
self.speed = speed
Ball1 = Ball(10,"blue", 10)
Ball2 = Ball(20,"yellow",20)
def check_collision(ball1... |
5c0a731e81ed84ae8aeff4f158f811f8a433bd18 | tsupei/leetcode | /python/98.py | 2,181 | 3.9375 | 4 | # Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def less(self, root, value):
is_less = True
if root.left:
is_less = is_less and self.less(root.left, ro... |
60a448de408edd25459d9683a38f76ea584705e2 | tsupei/leetcode | /python/208.py | 1,985 | 4 | 4 | class Node(object):
def __init__(self, x):
self.val = x
self.children = []
self.leaf = False
def add(self, x):
self.children.append(x)
class Trie(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.root = Node(... |
9b911f89226d2cf3c2a05ec1c0cf2f7896c396e4 | tsupei/leetcode | /python/103.py | 1,012 | 3.734375 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def zigzagLevelOrder(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
... |
e94c6c6d8d8313c24ee29a4d4fea7a7e0a42f8c2 | tsupei/leetcode | /python/116.py | 715 | 3.90625 | 4 | """
# Definition for a Node.
class Node(object):
def __init__(self, val=0, left=None, right=None, next=None):
self.val = val
self.left = left
self.right = right
self.next = next
"""
class Solution(object):
def connect(self, root):
"""
:type root: Node
:rty... |
0576072b7bab6fedda8c9c834e4235a63e607ff0 | tsupei/leetcode | /python/99.py | 2,905 | 3.890625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def find_max(self, root, maximum, max_node):
if not root:
return maximum, max_node
if root.v... |
c2b1062f9f025bf114b0a0ab4fe21e21f706a071 | tsupei/leetcode | /python/74.py | 1,338 | 3.609375 | 4 | class Solution(object):
def binary_search(self, arr, target, offset):
if not arr:
return offset
mid = len(arr) // 2
if target < arr[mid]:
return self.binary_search(arr[:mid], target, offset)
if target > arr[mid]:
return self.binary_search(arr[mid+1... |
15cd63ae8152520346763e648dacd9887079c045 | Shailendra1118/pythonapps | /itertools.py | 219 | 3.78125 | 4 | from itertools import product
# towork with Iterables
# e.g. takewhile, chain, accumulate
a = {1,2}
print(list(product(range(3),a)))
print(len(list(product(range(3),a))))
print("range")
for b in range(2):
print(b) |
026ac2fa1e3346b11ac31b64734809c0e33fd145 | kyon0304/backup_Learn | /python/num.py | 328 | 4.09375 | 4 | #! /usr/bin/env python
# file: num.py
# date: 2012-8-23
num_str = raw_input('Enter a number: ')
num_num = int(num_str)
fac_list = range(1, num_num+1)
print "BEFORE:", fac_list
i = 0
while i < len(fac_list):
if num_num % fac_list[i] == 0:
del fac_list[i]
i = i - 1
i = i + 1
print "AFTER:", f... |
b489bb976b4378a3863582d3502ebebbc76821d6 | kyon0304/backup_Learn | /python/leapyears.py | 441 | 3.6875 | 4 | #! /usr/bin/env python
# file: leapyears.py
# date: 2012-09-13 author: kyon
def judge(year):
if year%4 == 0:
if year%100 == 0:
return False
else:
return True
else:
return False
def getLeap():
years = [n for n in range(1900,2012)]
# leapyears = filter(judg... |
5b4131f14b575c5751d61e5ce5636efd79db992d | kyon0304/backup_Learn | /python/ospathex.py | 1,731 | 3.609375 | 4 | #! /usr/bin/env python
# file: ospathex.py
# date: 2012-08-25
def pathex():
import os
for tempdir in ('/home/wangying/Learn/python', r'c:\tmp'):
if os.path.isdir(tempdir):
break
else:
print 'no temp directory available'
tempdir = ''
if tempdir:
... |
e2b93edf2bcaaddcb90052227a70171fd407afc0 | kyon0304/backup_Learn | /python/change.py | 449 | 3.5 | 4 | #! /usr/bin/env/ python
import sys
sys.setrecursionlimit(1000000000)
def getChange(amount, changes):
if amount == 0:
return 1
elif amount < 0 or len(changes) == 0:
return 0
else:
return getChange(amount-changes[0], changes)+getChange(amount, changes[1:])
def main():
amount = 10... |
2137166e1713043f177968eca9b6351c56e51bba | NeonOrange/UwU | /UwU.py | 3,098 | 3.9375 | 4 | ### UWU MATH OPERATIONS ###
### BY: @NEON_ORANGE ###
### February 11, 2020 ###
class bcolors:
YELLOW = '\033[93m'
GREEN = '\033[92m'
RED = '\033[91m'
MAGENTA = '\033[35m'
CYAN = '\033[36m'
BLUE = '\033[34m'
WHITE = '\033[37m'
print(bcolors.GREEN + "\n*** -------------------- ... |
25360bc15a2b6eaa41c69b4966ca33a27bedfb92 | duvan-molina/python | /conversor.py | 669 | 3.890625 | 4 | menu = """
Bienvenido al conversor de moneda 💰
1 - Pesos colombianos
2 - Pesos argentinos
3 - Pesos mexicanos
Elige una opción: """
option = int(input(menu))
def converter(pesos, value_dollar):
dollar = pesos / value_dollar
dollar = round(dollar, 2)
dollar = str(dollar)
return dollar
def showMessage(messa... |
af9b45adc4b371b41dcd39bf371a88faef11d775 | RoboCupULaval/StrategyAI | /Util/role.py | 384 | 3.53125 | 4 | from enum import Enum
class Role(Enum):
"""Enum representing the role of one of our player playing on the field"""
GOALKEEPER = 0
MIDDLE = 1
FIRST_DEFENCE = 2
SECOND_DEFENCE = 3
FIRST_ATTACK = 4
SECOND_ATTACK = 5
@classmethod
def as_list(cls):
return list(cls.__members__.v... |
37bdb07a05683f17929e6288fca2ba5ccf053d89 | rodrigo-meyer/python_exercises | /hypotenuse_distance_a_b.py | 462 | 4.03125 | 4 | from math import hypot
print('\033[4;30;43m Calculate the Hypotenuse or the distance between two points (vertical, horizontal). \033[m')
ver = float(input('Vertical distance (use same scale): '))
hor = float(input('Horizontal distance (use same scale): '))
distance = hypot(ver, hor)
print('The distance between the ... |
8cb108ab7d77ee8f7d7e44b68b2d0b0fdd77849b | rodrigo-meyer/python_exercises | /odd_numbers_selection.py | 340 | 4.3125 | 4 | # A program that calculates the sum between all the odd numbers
# that are multiples of 3 and that are in the range of 1 to 500.
# Variables.
adding = 0
counter = 0
for c in range(1, 501, 2):
if c % 3 == 0:
counter = counter + 1
adding = adding + c
print('The total sum of {} values is {}'.forma... |
504acac4dee4a6f1102b3c44e994acea0220c8a0 | rodrigo-meyer/python_exercises | /market_system.py | 1,261 | 3.84375 | 4 | # Market System.
market_name = 'Mega Shop'
# Euro
cipher = '€'
# Pound
# cipher = '£'
# American Dollar
# cipher = 'US$'
# Real
# cipher = 'R$'
# Generich Cipher
# cipher = '$'
line = 44
counter = 0
special_count = 0
special_price = float(1000.00)
shipest_price = 0
shipest_price_x = 0
shipest_name = ''
total =... |
c9edfc315cf450b950bc59cd596296d038ca9404 | rodrigo-meyer/python_exercises | /analyzing_segments_for_triangle_plus.py | 705 | 4.03125 | 4 | #Analyzing segments for Isosceles Triangle.
print('\033[0;30;43m Analyzing segments for a triangle. \033[m')
print(' ')
seg1 = float(input('Insert the first segment: '))
seg2 = float(input('Insert the second segment: '))
seg3 = float(input('Insert the second segment: '))
print(' ')
if seg1 < (seg2 + seg3) and seg2 <... |
2d10b5ab77db2bcf124caca39ccebbe6ad017960 | rodrigo-meyer/python_exercises | /game_guess_the_number.py | 630 | 3.921875 | 4 | #Game - Guess the Number!
from random import randint
computer_number = randint(0, 5)
line = 25
print('\033[0;30;43m=-=\033[m' * line)
print('\033[1;38;43m GUESS THE NUMBER! \033[m')
print('\033[0;30;43m=-=\033[m' * line)
print(' ')
print('I am thinking in a n... |
25f7315fac0da6450ac9d49821a05da4e5dfba00 | rodrigo-meyer/python_exercises | /plural_or_singular_automatic.py | 317 | 4.09375 | 4 | # Treating singular or plural according to the number of items.
print('Treating singular or plural according to the number of items.')
print('')
num = int(input('Enter the amount of books you have (for Example: 0, 1, 2, 53): '))
print('You have {} book'.format(num), end='')
print('' if num == 1 else 's', end='.')
|
b289bcb8137e388bb89cedf13af8cd6e7325ef21 | BobWang21/algorithm | /3 双指针/2 str.py | 3,366 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import defaultdict
# 字符串不能原处更改
# 判断是否为回文
def is_palindrome(s):
if not s:
return True
l, r = 0, len(s) - 1
while l < r:
if not s[l].isalnum(): # isalnum() 数字或字符串
l += 1
continue
if not s[r].is... |
022284001a50cb8d9bdfe688f729b4f901cdb2c9 | BobWang21/algorithm | /2 分而治之/3 quick_sort.py | 4,353 | 3.796875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def partition1(nums, l, r): # 原地修改
pivot = nums[l] # pivot可以随机选择
while l < r:
# 从右向左遍历
while l < r and nums[r] >= pivot:
r -= 1
nums[l] = nums[r] # 替换已保存nums[l]
# 从左向右遍历
while l < r and nums[l] <= pivot: # 左... |
c42a8bc573a86b1c141a59f9c8f567ce2120069d | BobWang21/algorithm | /12 高级数据结构/trie.py | 2,028 | 4 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 前缀树
class Trie(object):
def __init__(self):
self.dic = {} # 嵌套字典
def insert(self, word):
dic = self.dic
for c in word:
dic.setdefault(c, {}) # 如果不在字典中 新建一个key
dic = dic[c]
dic['#'] = '#' # 结束标志
# ... |
70d6e8b544b210332207c8aca15c801583eb6601 | BobWang21/algorithm | /7 链表/tmp.py | 16,887 | 3.609375 | 4 | import heapq as hq
import random as rd
class ListNode():
def __init__(self, val):
self.val = val
self.next = None
class Node:
def __init__(self, x, next=None, random=None):
self.val = int(x)
self.next = next
self.random = random
def construct_list_node(nums):
he... |
a595cb0019d696be055f85bc247947ee93af0064 | pmack1/seismos-NFP-stability-prediction | /model/acg_read.py | 1,023 | 3.5 | 4 | # CAPP 30254: Machine Learning for Public Policy
# ALDEN GOLAB
# ML Pipeline
#
# File read functions
import pandas as pd
def load_file(filename, index = None):
'''
Reads file with column index and returns a Pandas dataframe. If index
name is missing for UID, use [0] to refer to the first column even if ... |
2d82e37df23a1763ea219fbe0648be5a942ced91 | jimlinntu/antipodal_pairs | /antipodal_pairs.py | 2,882 | 3.609375 | 4 | import math
import numpy as np
import cv2
def distance(p1, p2, p):
''' The distance from p to a line formed by p1 and p2 '''
return abs(((p2[1]-p1[1])*p[0] - (p2[0]-p1[0])*p[1] + p2[0]*p1[1] - p2[1]*p1[0]) /
math.sqrt((p2[1]-p1[1])**2 + (p2[0]-p1[0])**2))
def find_antipodal_pairs(points, point_names):... |
6c447182cb18292767e1033797a6e0f1915cff0a | tchu01/570lab1_tictactoe | /src/tictactoe.py | 7,471 | 3.859375 | 4 | import copy
import math
class TicTacToe:
PLAYERX = 'X'
PLAYERO = 'O'
PLACE_FAIL = 0
PLACE_SUCCESS = 1
GAMEOVER = 2
TIE = 3
VICTORY = 4
PLAY_ON = 5
def __init__(self):
self.board = [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']]
self.location = {'1' : (0, 0),
... |
fc9bc681a487654e1808f99f7922712c50da88d2 | HunterJohnson/Interviews | /project_euler/python/005.py | 571 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 2 10:49:46 2016
@author: HJohnson
2520 is the smallest number that can be divided by each
of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible
by all of the numbers from 1 to 20?
"""
def isD... |
5de91bc637bf0257bbc6eff4facd221981c20644 | HunterJohnson/Interviews | /project_euler/python/009.py | 427 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 2 13:35:23 2016
@author: HJohnson
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
for i in range(1,700):
for j in range(1,700):
for k in range(1,700):
if i + j + k == 1000:
... |
6c9f7d78b39eef8f8387e8b508e4b6ab32d93e53 | DinaMusalam/Pythonobjektorienterad | /view.py | 1,462 | 3.796875 | 4 | # -*- coding: cp1252 -*-
import controller
class UI:
def main_menu(self):
print """\t WELCOME TO PRODUCT COMPANY
----------------------------------------
1. Add product.
2. Show product list.
3. Show (one) product.
4. Save Product list to a text file.
5. Show product list... |
2865082dc52f77149a08cf5753800a117595571b | sunilkum84/golang-practice-2 | /revisiting_ctci/chapter4/MinimalTree_4_2.py | 1,426 | 3.78125 | 4 | """
Given a sorted array with unique integer elements
write an algorithm to create a binary dearch tree with
minimal height
"""
from graph import Node, Graph
class BalancedNode():
def __init__(self, data=None):
#this stores the data found at the given node
self.__data = data
#this stores the adjacent edges in t... |
2dfea64853bd6a80f9c96925d70e4cc4d9a643ea | sunilkum84/golang-practice-2 | /revisiting_ctci/chapter3/StackMin_3_2.py | 324 | 3.859375 | 4 | """
get the minimum value in a stack
"""
from stack import Stack
def MinStack(s):
lowest = s.Data[0]
for i in s.Data[1:]:
if i < lowest:
lowest = i
return lowest
if __name__ == '__main__':
test = Stack()
for i in [9,3,1,4,7,5,5,]:
test.Push(i)
print(test)
print('Minimum:\n')
print(MinStack(test... |
b04b13fffc01f746d2e6795682fe9d993702b865 | sunilkum84/golang-practice-2 | /revisiting_ctci/chapter3/MultiStack_3_1.py | 1,314 | 4.25 | 4 | """
use one array to implement three stacks.
i.e.
array := []Stack{3}
have functions to call the array position
and perform the stacks command on the given position
"""
from stack import Stack
class MultiStack():
def __init__(self):
self.__stack_list = [Stack(), Stack(), Stack()]
self.__pos_err = 'MultiSta... |
e0e119659f38ad2775e0a5c21899b78d8a358f45 | joseph-guidry/project11-python-bank | /bank.py | 8,630 | 4.15625 | 4 | #! /usr/bin/env python3
"""
Module: bank.py
Author: Joseph Guidry
Date : 07/09/2017
Description: This module contains the functions and class to operate
the bank object.
================== =================================================
FUNCTION DESCRIPTION
====... |
209b415fdf2e15a501994c8ef1fb4425532849cf | codingXllama/Face-Recognition | /Number of faces in a picture/faceReg.py | 956 | 3.78125 | 4 | # Importing the python face recognition library
import face_recognition
from PIL import Image # importing the python image library
# loading the images we want to recognize
image1 = face_recognition.load_image_file("team2.jpg")
# finding the face locations for the image we want to recognize
face_locations = face_reco... |
877b8d909567910f0330c2bfd0734f40f8ad2773 | AkankshaKaple/Python-OOP-Django-Angular-Nginx | /OOP_with_python/Inventory Management/Data_Management.py | 756 | 3.859375 | 4 | import json
from OOP_with_python.utility.My_utility import *
class DataManagement:
def __init__(self):
pass
# Function to calculate price for total quantity of item present in inventory
def total_price(self, inventory, item):
quantity_availabe = inventory[item]['weight']
item_pric... |
b6ef8a01ffffd8b69986dfadcb9ed4199ed3e4f1 | diver-below/python | /ML_uni/TOBD/sems/old_solutions/students_solutions/ДенисПанин/sem4_multiprocessing/counters.py | 664 | 3.640625 | 4 |
from collections import Counter
def count_chars_in_book(filename):
chars = Counter()
alphabet = set("абвгдеёжзийклмнопрстуфхцчшщъыьэюя")
path = "text/" + filename
with open(path, "r") as txt:
for line in txt:
for char in line.lower():
if char in alphabet:
... |
b61f3bb39c51f24848e660ae3f2656ff8e500bd4 | SteveDLosk/Python_Stuff | /ColorDraw.py | 3,580 | 4.15625 | 4 | ## Simple color dot drawing program
# This one is all me. My kids call it the drawing circle game
import simplegui
# Globals
active_color = "Red"
active_size = 16
CANVAS_WIDTH = 600
CANVAS_HEIGHT = 450
CANVAS_TITLE = "Circle Drawing"
ball_list = [] #stores a list of balls, including pos, size, color
color_dict = ... |
54fae12322821a869b2e6c187213c2e0f16c8d74 | KXVicky/egg_catcher | /egg_catcher.py | 518 | 3.765625 | 4 | from itertools import cycle
from random import randrange
from tkinter import Canvas, Tk, messagebox, font
#setting the canvas
canvas_width = 800
canvas_height = 400
root = Tk()
c = Canvas(root, width = canvas_width, height = canvas_height, background = 'deep sky blue')
c.create_rectangle(-5, canvas_height - 100, canva... |
34c3bec34c7d4c18596381f3ac1c7164a183091f | gulnarap1/Python_Task | /Task3_allincluded.py | 2,822 | 4.1875 | 4 | #Question 1
# Create a list of the 10 elements of four different types of Data Types like int, string,
#complex, and float.
c=[2, 6, 2+4j, 3.67, "Dear Client", 9, 7.9, "Hey!", 4-3j, 10]
print(c)
#Question 2
#Create a list of size 5 and execute the slicing structure
my_list=[10, 20, ["It is me!"], 40, 50]
#Slicing
S... |
f8c66693e07fdb5be15cbf27ee00a25bd05c2bf7 | jflowaa/datastructures | /bst/bst.py | 1,998 | 3.875 | 4 | import re
class Node:
def __init__(self):
self.item = ''
self.p = [None, None]
class BinarySearchTree:
def __init__(self):
self.root = None
self.found = []
def insert(self, word):
"""
Creates the root node, then uses _insert after any additional node
... |
21eb375065e459062818dc47d4ad4a2ee85ba369 | Twinday/Quarda_game | /example.py | 253 | 3.796875 | 4 | n = 3
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
a = [[x[i] for x in a] for i in range(1, n)]
b = list()
for j in a:
b.append(j[-1::-1])
print(a)
print(b)
original = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
rotated = tuple(zip(*original[::-1]))
print(rotated) |
de712350e2dbbe5d3dbc1657ae2819fa2834bfde | cjmerzbacher/understanding-systems-code | /annotating-graphs/digraph_structure.py | 775 | 3.546875 | 4 | class DirectedEdge:
def __init__(self, v, w, weight):
self.v = v
self.w = w
self.weight = weight
def toString(self):
return '{} -> {} {}'.format(self.v, self.w, self.weight)
class EdgeWeightedDigraph:
def __init__(self, V):
self.V = V
self.E = 0
... |
7945a42d75259c3e809389654797f3881e6ccd20 | faradzhev/python-baby | /lab9_1.py | 732 | 3.625 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
demo1 = [2, 3, 4, 5, 6, 'J', 'T']
demo2 = [2, 3, 4, 5, 6, 'J', 'J', 'J', 'J', 'J']
demo3 = [2, 3, 4, 'J', 'A']
demo4 = ['A', 'A', 'A', 'A']
def Blackjack(cards) :
if not checkcards(cards) : print("Duplicated cards!"); exit
source = {2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, ... |
9f7bafe35255682304f1123d16e64369ad8c1e28 | faradzhev/python-baby | /lab8_3.py | 417 | 3.9375 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
arr = [65, 3, 3, 53, 523, 6, 63, 2, 8, 6, 3, 23, 0]
def median(array) :
array.sort()
length = len(array)
mid = int(length / 2)
med = array[mid] if length % 2 != 0 else (array[mid-1] + array[mid]) / 2
return med
def mean(array) :
return sum(array) / len(array)
de... |
e1938e6e9423f7d434be46d5ee3ccce42969ece6 | faradzhev/python-baby | /lab_6_3.py | 577 | 4.09375 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
import math
def interest(p, r, n=12, t=1):
return p*(1+r/(100*n))**(n*t)
def calculate_years(p, a, r, n):
y = 1
while interest(p, r, n, y) < a:
y += 1
return y
p = float(input("Enter Current Savings: "))
a = float(input("Enter Amount of Interest... |
51499651fbbf0754bd7e9e511872e9d402508b28 | faradzhev/python-baby | /vasia_and_doors.py | 369 | 3.84375 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
w = float(input("Введіть door w: "))
h = float(input("Введіть door h: "))
a = float(input("Введіть box a: "))
b = float(input("Введіть box b: "))
c = float(input("Введіть box c: "))
print( (w>a and h>b or w>b and h>a) or (w>a and h>c or w>c and h>a) or (w>b and h>c or w... |
65f5541d6c32617b59f754c990ae98d54043ed43 | Akshara2820/Python_Magic_Square | /magic_square_list.py | 478 | 3.9375 | 4 | square = [
[8, 3, 4],
[1, 5, 9],
[6, 7, 2]
]
col=0
row=0
i=0
l=len(square)
while i<l:
j=0
diagonal=0
diagonal1=0
while j<l:
col+=square[j][i]
row+=square[i][j]
diagonal+=square[j][j]
diagonal1+=square[len(square)-j-1][j]
j+=1
i+=1
print(row)
print... |
5d0c4fcdc86ff06dec873de8ebb13be8491455ab | yyassif/ProjectEuler-Toolkits | /divisors-factors.py | 395 | 3.703125 | 4 | def divisors(n, extremum= False):
divisors = []
inf = 1 if extremum else 2
for i in range(inf, int(n**0.5)+1):
q, r = divmod(n, i)
if r == 0:
if q >= i:
divisors.append(i)
if q > i:
divisors.append(n//i)
return sorted(diviso... |
b76498815e4fd9dfc7fc69aac1df61fa64bac842 | Nick13342/Fox_II_Website | /emailAddress.py | 4,269 | 3.625 | 4 | #!/usr/bin/env python3
from debug import Debug
#------------------------------------------------------------------------------------
# Class Name: email
# Written By: Nick Glanville
# Date: 03-07-2017
#
# Class to create an instance of an email object. At this stage the primary
# function of the class is to val... |
7aebca64fb29047f7bbbdd872fd49d8e104e647d | zhang23/Laboratory | /【Test】Neural Network/Base Neural with Back Prop/Neural/neural.py | 1,595 | 3.75 | 4 | import numpy as np
# Build a neural network
# Build a class
class NeuralNetwork():
def __init__(self,n_input,n_layer,n_output):
# Build W values for 2 layers
# First W n_input x n_layer
# Second W n_layer x n_output
self.weight_1 = np.random.random_sample((n_input,n_layer... |
46f0f7ed004db78260c547f99a3371bb64ce6b08 | MemeMasterJeff/CP1-programs | /9-8-payroll-21.py | 2,572 | 4.125 | 4 | #William Wang & Sophia Hayes
#9-8-21
#calculates payroll for each employee after a week
#defins the employee class
try:
class employee:
def __init__(self, name, pay):
self.name = name
self.pay = pay
#inputted/calculated values
self.rate = float(inp... |
f10e434036350d9a134af8eb02be83798525d9a9 | StuntmanMel/NN_HW_digit_recognizer | /main.py | 6,934 | 3.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 18 20:28:13 2019
@author: kevin
"""
import numpy as np
import matplotlib.pyplot as plt
def loadimg(name):
return (plt.imread(name)).flatten()
def showimg(array):
img = np.reshape(array,(28,28))
plt.imshow(img)
def randomimg():
re... |
b7c53f9f71b18e7b850c9d6327507cd6590a43e3 | gomezquinteroD/GWC2019 | /Python/survey.py | 557 | 4.1875 | 4 | #create a dictionary
answers = {}
# Create a list of survey questions and a list of related keys that will be used when storing survey results.
survey = [
"What is your name?",
"How old are you?",
"What is your hometown?",
"What is your date of birth? (DD/MM/YYYY)"]
keys = ["name", "age", "hometown", "... |
a4600d05b41a00624bc40deaea7c738dc87813a9 | gomezquinteroD/GWC2019 | /Tests/testj.py | 254 | 3.78125 | 4 | import json
myDictionary = {"name" : "Alex", "age" : 23, "school" : "Rutgers" }
#open the json file, use 'w' for write mode
f = open("newj.json", "w")
#dump your list/dictionary into the file object
json.dump(myDictionary, f)
#close the file
f.close()
|
4cc4032aa66b8a87fc06d00c0ba84df8c3d2a4ce | gomezquinteroD/GWC2019 | /Python/MafiaPrep.py | 3,298 | 3.953125 | 4 | from random import *
import os
names = ["Aadya", "Adriana", "Annie", "Brianna", "Catherine", "Gabrielle",
"Jade", "Jennifer", "Jolina", "Joyce", "Kelsey", "Maggie", "Maria", "Megan",
"Natalie", "Ruth", "Saira", "Sam", "Sana", "Taitu"]
absent = []
mafia = []
nurses = []
sheriffs = []
print("Let's Play Mafia!"... |
82767523911cc9a91a37a33534f27d73150f2b73 | nagyistge/PySpark_MLlib | /test2.py | 2,601 | 3.78125 | 4 | # PySpark features extraction, transformation and selection testing
# code will be executed on databricks, so there is no need to setup spark environment
import pyspark
# import dataframe from s3
filepath = 's3a://somefilepathhere'
df = spark.read.parquet(filepath)
df.printSchema()
# features and corresponding datat... |
4c3059cf099cdd218c589e0245c2028dac743800 | thyagogm/meusarquivos | /mostrar_numero_inteiro_de_um_valor.py | 155 | 3.9375 | 4 | from math import floor
# Armazena Valores
a = float(input('Digite um Numero!\n'))
print('O Numero = {}\nTem a Parte Inteira = {}'.format(a, floor(a)))
|
43f36f967cd4c184da673676c7b81ba64de64343 | thyagogm/meusarquivos | /se_pode_forma_triangulo_ou_nao.py | 428 | 4 | 4 | # Armazenando Valores!
r1 = float(input('Primeiro Segmento!\n'))
r2 = float(input('Segundo Segmento!\n'))
r3 = float(input('Terceiro Segmento!\n'))
# se a soma de dois valores forem menor que um valor forma um triangulo caso contrario não!
if r1 < r2 + r3 and r2 < r1 + r3 and r3 < r1 + r2:
print('Os Segmentos... |
b69965d47cbdc6f809bf6e50893c8a648a1e8581 | thyagogm/meusarquivos | /escolhas_aleatorias.py | 377 | 3.90625 | 4 | # Importação da Função Choice
from random import choice
# Armazenando Valores
a = str(input('Digite 1 Nome!'))
b = str(input('Digite 2 Nome!'))
c = str(input('Digite 3 Nome!'))
d = str(input('Digite 4 Nome!'))
# Utilizando a Função Choice
sorteio = choice([a, b, c, d])
# Imprimindo na Tela
print('O Aluno Sort... |
aa4d29e47a91901f191dcece0a02ba9bf74e553c | thyagogm/meusarquivos | /aumento_de_salariov2.py | 301 | 3.734375 | 4 | # Armazena Valores!
salario = float(input('Digite o Valor do Salario!'))
if salario <= 1250:
aumento = salario + (salario * 15 / 100)
else:
aumento = salario + (salario * 10 / 100)
print('o Valor do seu Salário é = R${}\nCom o Aumento do Salário é = R${}'.format(salario, aumento))
|
0c997239e5fd497a3da4f535ae7fe7a3fbdaffb5 | zack28/Algorithms | /Searching/linear_search.py | 383 | 3.640625 | 4 | def search(a,key):
i=0
while i< len(a):
if a[i] == key:
return True
globals()['pos']=i
i=i+1
return False
a=[]
n=int(input("Enter No Of Elements in the list: "))
for i in range(0,n):
ele=int(input())
a.append(ele)
print(a[0])
key=int(input("Enter The No To Be Searched: "))
if searc... |
2aded4ef79e6cd803b179bfe0811874480f212f6 | pedroeml/t1-fcg | /CrowdDataAnalysis/graph/edge.py | 1,154 | 3.5 | 4 | from collections import deque
class Edge:
def __init__(self, source, target, weight):
self.source = source
self.target = target
self.weight = weight
self.weight_history = deque()
self.weight_history.append(self.weight)
def change_weight(self, weight):
if weight... |
c92c30981d72ba366fda7225a9613ddc4c5053e7 | albertfougy/leetcode | /leetpy/easy/test_roman_to_integer.py | 1,005 | 3.859375 | 4 | def romanToInt(s):
numerals = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000}
numeric = [numerals.get(char) for char in s]
total = 0
for index, n in enumerate(numeric):
if index < (len(numeric) - 1) and numeric[index + 1] > n:
total -= n
else:
to... |
425206929f894ceb2eeb7d64e09b6a7694428f67 | albertfougy/leetcode | /graph/clone_graph/clone_graph.py | 4,248 | 4.125 | 4 | # 133. Clone a Graph
#
# Python 3
# A Pythonic Detailed step-by-step explanation in BFS (below)
# https://www.youtube.com/watch?v=Jx3Cz_A60Oc&t=256s
"""
# Definition for a Node.
class Node:
def __init__(self, val = 0, neighbors = []):
self.val = val
self.neighbors = neighbors
"""
class Solution:... |
09b622ab6b80837af3d218ec32455289f31d0716 | albertfougy/leetcode | /dynamic_programming/unique_paths/unique_paths_detailed.py | 1,086 | 3.671875 | 4 | class Solution(object):
def uniquePaths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
if m == 1 or n == 1:
return 1
#have a list of lists to represent the grid, initilized with 0's
diffPaths = [[0]*n]*m
... |
9210366dbd9def954d05ec90913b9871c4dca2a6 | pmvanker/pmvankerPython | /Program/threading/activeThread.py | 616 | 3.546875 | 4 | import time
from threading import *
def mythread():
print(current_thread().getName())
time.sleep(3)
print(current_thread().getName())
t1 = Thread(target=mythread,name='th1')
t2 = Thread(target=mythread,name='th2')
t3 = Thread(target=mythread,name='th3')
print('actvie threads :',active_count())
t... |
87232aa7fd32176debe7e6fb6209729235cfa1d1 | pmvanker/pmvankerPython | /Program/over_load_ride/variable.py | 204 | 3.5625 | 4 | class Test:
def sum(self,*a):
total = 0
for x in a:
total = total + x
return total
t = Test()
print(t.sum(10,20))
print(t.sum(10,20,30))
print(t.sum())
|
ec5570c99f6fcb4b3e16abe96c1ec3d7d97a8ecc | nateshmbhat/Hackerrank | /Equal_Stacks.py | 909 | 3.78125 | 4 | #https://www.hackerrank.com/challenges/equal-stacks
stacks = [[int(i) for i in input().strip().split()] for _ in range(len(input().split()))]
height = [sum(i) for i in stacks]
while(len(set(height))!=1):
index = height.index(max(height));
height[index]-= stacks[index].pop(0)
print(height[0])
"""
Read the fir... |
8fe99d1fbbbebfcfcd68ce5018cff488260ccc08 | nateshmbhat/Hackerrank | /The_Hurdle_Race.py | 272 | 3.5 | 4 | #https://www.hackerrank.com/challenges/the-hurdle-race/problem
#!/bin/python3
import sys
n,k = input().strip().split(' ')
n,k = [int(n),int(k)]
height = list(map(int, input().strip().split(' ')))
# your code goes here
print("0" if k>max(height) else max(height)-k) ;
|
07c1a7d4e7b22ee2bcbee6e4a69726d1ffe527ba | jackhuang75/python | /if_else.py | 298 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
height = 1.75
weight = 80.5
bmi = weight/height**2
if bmi > 32:
print('严重肥胖')
elif bmi > 28:
print('肥胖')
elif bmi > 25:
print('过重')
elif bmi > 18.5:
print('正常')
elif bmi <= 18.5:
print('过轻')
else:
pass
|
7a9d5ad1f562c695a7eea1a8bfb3bf788c1334df | Lonewolfiz/Higher_lower | /main.py | 1,016 | 3.5625 | 4 | import art
import game_data as gd
from replit import clear
import random as rn
print(art.logo)
def random_func():
return rn.choice(gd.data)
def compare_func(compare_a,compare_b):
if compare_a>compare_b:
return 'A'
else:
return 'B'
def final_func(Answer,Guess):
if Answer==Guess:
return True
else:... |
7cb329fdff742e3b07bd93455cc2357fb6b5a0e9 | New-Be-Maker/Introduction-to-Python | /Part2_Small Projects/Codes/dealing_with_missing _data_Death_Valley.py | 1,905 | 3.546875 | 4 | # _*_ coding: utf-8 _*_
"""
Dealing with missing data_Death Valley
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This exercise is from textbook <Python Crash Course>
:copyright: by Eric Matthes
:enhanced detail editor: by Yifeng
"""
import csv
from datetime import datetime
import matplotlib.pyplot as plt
... |
b3715a7e93503771c295aa8efca2b945048af812 | marcuscarr/UCB_cs61a | /hw/hw4/hw4.py | 8,995 | 4.15625 | 4 | # Name:
# Email:
def str_interval(x):
"""Return a string representation of interval x.
>>> str_interval(interval(-1, 2))
'-1 to 2'
"""
return '{0} to {1}'.format(lower_bound(x), upper_bound(x))
def add_interval(x, y):
"""Return an interval that contains the sum of any value in interval x and... |
502b3a4f29acb152f2ed1432a08820b3f70dbeb8 | Adriel-Alves-Moreira/mlitary-service-sistem | /mlitary-service-sistem.py | 715 | 3.890625 | 4 | from datetime import date
import webbrowser
from time import sleep
current = date.today().year
birth = int(input("Year of birth: "))
age = current - birth
print("Who was born in {} is {} years old in {}". format(birth, age, current))
if age == 18:
print("You are already 18 years old, and it's time to enlist... |
7d78fcf831aa7a899f851c29805a8d1a8fc9b704 | VuThiThuyB/vuthithuy-fundamental-c4e22 | /session1/bai6.py | 90 | 3.640625 | 4 | from turtle import *
shape ("turtle")
for i in range(1):
circle(100)
mainloop() |
78fa6b0a6193341a0a34d48106a90b28682d8dec | VuThiThuyB/vuthithuy-fundamental-c4e22 | /session4/update.py | 152 | 3.59375 | 4 | person = {
'name':'Thuy',
'age': 21,
}
print(person['age'])
person['age'] = 23 #person['age'] += 2 coi person['age'] nhu 1 bien
print(person) |
cf539671105b46eb364ebcb63d0bc2950d96cde1 | VuThiThuyB/vuthithuy-fundamental-c4e22 | /session2/maze.py | 229 | 3.71875 | 4 | from turtle import *
speed(0)
#d = 100
for i in range(50):
forward(i+10)
#forward(d)
#d = d+10 # d += 10
left(90)
mainloop()# để turtle chạy xong thì cửa sổ sẽ đứng yên mà k bị tắt đi mất |
2591182f3d0049bef275b6acc68b646e95498d5b | VuThiThuyB/vuthithuy-fundamental-c4e22 | /session2/session_homework/Multiplication.py | 91 | 3.828125 | 4 | n = int(input("Enter a number : "))
s = 1
for i in range(n):
i=i+1
s = s*i
print(s) |
118fd8dade1af389afcbb794fbff683c9588d1e5 | VuThiThuyB/vuthithuy-fundamental-c4e22 | /session1/age.py | 130 | 3.6875 | 4 | yob = input("Your year of birth ? ")
#yob = int(input("your year of birth ? "))
#age = 2018 - yob
age = 2018 - int(yob)
print(age) |
4e808368dcb9f4e791aca828f31a17b47c6947dc | macrespo42/Bootcamp_42AI | /day00/ex03/count.py | 1,009 | 4.375 | 4 | import sys
import string
def text_analyzer(text=None):
"""
This functions count numbers of upper/lower letters, punctuation spaces
and letters in a string
"""
upper_letters = 0
lower_letters = 0
punctuation = 0
spaces = 0
text_len = 0
if (text == None):
print("Wh... |
cf2c844404cae83aed897fd6bbc694bef55ea715 | macrespo42/Bootcamp_42AI | /day00/ex09/guess.py | 812 | 3.984375 | 4 | import random
import sys
nb_to_guess = random.randrange(1, 100)
game = True
turn = 1
print("This is an interactive guessing game!")
print("You have to guess a number between 1 and 99 enter 'exit' for leave")
while (game == True):
response = input("What's your guess between 1 and 99?\n")
if (response == "exit"):
pr... |
a0c4c0c92dc079d00d849e49a9c3fe562a75aa58 | neihousaigaai/word-stress-exercise | /get_stress_word_main.py | 3,474 | 3.515625 | 4 | from sys import argv
import get_stress_word_cambridge_dictionary
import get_stress_word_how_many_syllables_com
import get_stress_word_dictionary_com
def stress_on(word, word_type):
res1 = get_stress_word_dictionary_com.stress_on(word, word_type)
if res1 != -1 and res1 != 0:
return res1
res2 = get_str... |
164101f7c9c10d9133d764ae310f3355fb24b9be | ssemotom/Python-Project | /Tic tac toe board game.py | 4,402 | 4.21875 | 4 | #A Two Player Tic-Tac-Toe game in Python.
# The dictionary is used create the Tic-Tac-Toe board. The empty space field after every move,the value changes depending on the player's choice of move.
ticTacToeBoard = {'7': ' ' , '8': ' ' , '9': ' ' ,
'4': ' ' , '5': ' ' , '6': ' ' ,
'1': ' ' , '2': ' ' , '... |
ff3f9bc00635684637acd7e54c875d58ddde1a53 | nathanwolfe/hanabi | /archives/conservative.py | 4,396 | 3.609375 | 4 | from card import Card
from deck import Deck
from action import Action
import random
"""
This is an example player file. AI developers should be able to specify their own players later.
"""
class Player:
def __init__(self, n): # n = player number
self.number = n
def move(self, state): # state = cu... |
f36d4dfb767b6b0c9eb5a186f13b0e1614fd4daa | weipanchang/project | /complementary_binary.py | 909 | 3.890625 | 4 | #!/usr/bin/env python
import math
def decimal_to_binary(n):
i = 0
while math.pow(2, i) <= n:
i += 1
i -= 1
binary_string = ""
accumulator = n
for k in range(i, -1, -1):
power = int(math.pow(2, k))
if power <= accumulator:
accumulator -= power
... |
e546f4114feb89b6a8d481c8d1e20c5b36290814 | weipanchang/project | /segement.py | 894 | 3.765625 | 4 | #!/usr/bin/env python
def smallest_segment(l): #O(N)
small_sum = l[0]
sum_value = sum(small_sum)
for i in range(1, len(l)):
if sum(l[i]) < sum_value:
small_sum = l[i]
sum_value = sum(small_sum)
return small_sum
def segement_list(l): #O(N^2)
m = []
for i in rang... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.