blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
4c5fea8990e7c259520f31f4848f22b852a0a9e9 | BazzalSeed/Python_Practices | /class/something.py | 305 | 3.96875 | 4 | #dsdfsdf ds
import math
import turtle
turt=turtle.Turtle()
def circle(turt,radius):
'''draw a circle'''
side= (2.0*math.pi*radius)/360
for x in range(360):
turt.forward(side)
turt.right(1)
def main():
circle(turt,150)
turtle.mainloop()
main()
|
2526289450c6fd4f75fb7edca09e45183d086290 | pateldar/EncryptedMessages | /Views/decrypt.py | 718 | 3.6875 | 4 | word = "hello"
new_word = ""
first_key = 257
key = first_key % 26
length_word = len(word)
for i in range(0,length_word):
if ord(word[i]) - key < 97:
temp = ord(word[i]) - 97
temp1 = key - temp
temp2 = 123 - temp1
new_word+= str((chr(temp2)))
else:
temp3 = ord(word[i]) - key
new_word+= str(... |
8159c3f4c7dc70c389561a43e4db56590756a427 | redpeng96/dev | /GUI/15_notepad.py | 1,681 | 3.546875 | 4 | import os
from tkinter import *
root = Tk()
root.title("Windows Notepad")
root.geometry("800x600+300+100")
filename = "mynote.txt"
def open_file():
if os.path.isfile(filename):
f = open(filename, "r")
txt.delete("1.0", END)
txt.insert(END, f.read())
def save_file():
f = open(filename... |
f2faff198b8018857b4e3c4db5364c32f8fb8b11 | SagarKumar1310/movie_ticket | /MOVIE_TICKET 1.py | 5,171 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 7 17:04:26 2021
@author: sagar kumar
"""
x = 10
booked_seat = 0
price_of_ticket = 0
total_income = 0
row = int(input('Enter the numbers of rows:'))
column = int(input('Enter the number of columns:'))
total_seat = row*column
booked_ticket_person = [[None fo... |
7025174a9fff5222bca58eeb58a5a455219d789b | rbtprograms/algo_practice | /lib/selection.py | 671 | 4.125 | 4 | #a file for a selection sort algo to prime for a quicksort algo
#arrays are good cause you can grab any random element at any time.
#Linked lists can be stored easier, but you need one element to find the next.
#So you need to start from the first to read any of them
def findSmallest(arr):
smallest = arr[0]
... |
e9f831458c7ca18ecc22389b1564407aeca0c39e | freelikeff/my_leetcode_answer | /leet/130answer.py | 1,846 | 3.765625 | 4 | #!D:\my_venv\Scripts python
# -*- coding: utf-8 -*-
# @Time : 2019/9/24 10:34
# @Author : frelikeff
# @Site :
# @File : 130answer.py
# @Software: PyCharm
from typing import List
# 经典BFS,也没啥说的
class Solution:
def solve(self, board: List[List[str]]) -> None:
"""
Do not return anything, mo... |
5696db9cbad8ea6c065e3b6980c183acc51093c1 | Ab2207/Python-Projects | /Problem Solving/Highest sum of list in nested lists.py | 479 | 3.890625 | 4 | """
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank.
Return the wealth that the richest customer has.
A customer's wealth is the amount of money they have in all their bank accounts.
The richest customer is the customer that has the maxim... |
ed1493e01acecc9cb7f85708c5a3a2eee78ec109 | moontree/leetcode | /version1/336_Palindrome_Pairs.py | 1,816 | 3.9375 | 4 | """
Given a list of unique words,
find all pairs of distinct indices (i, j) in the given list,
so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.
Example 1:
Given words = ["bat", "tab", "cat"]
Return [[0, 1], [1, 0]]
The palindromes are ["battab", "tabbat"]
Example 2:
Given words = [... |
b6f9825791f4d130dfdacd8c3cdf5f67e5d8d912 | HarryMead/LeetCode-Problems | /Climbing Stairs.py | 864 | 3.6875 | 4 | class Solution:
stepMemory = {}
#Brute Force Recursive Solution
def climbStairsHelper(self, j: int, n: int) -> int:
if j == n:
return 1
if j > n:
return 0
if j in self.stepMemory:
return self.stepMemory[j]
self.stepMemory[j] = self.climbSta... |
517c0e75023377751289b38655c453ca7d1c0c0f | SwethaVijayaraju/leetcode | /ph_num_reformat.py | 783 | 3.984375 | 4 | # https://leetcode.com/problems/reformat-phone-number/
def split(clean_num):
if len(clean_num) == 2:
return clean_num
if len(clean_num) == 3:
return clean_num
if len(clean_num) == 4:
clean_num = clean_num[:2] + '-' + clean_num[2:]
return clean_num
def reformatNumber(number):
... |
7b02172c20a8dbd5732474dbf902d80960a87005 | WGC575/python_learning | /tutorial/13_function.py | 350 | 4.0625 | 4 | #use def function(): to define a function and use function() to call it
def add(a, b):
return (a + b)
#add(1, 2)
def add(a, b, m):
return ((a + b) * m)
#add(1, 2)
#use return to return a result to the caller
def max(a, b):
if a >= b:
return a
else:
return b
print(a... |
6b55b3123ad3c8c9a3d96a0633e365b3b7593f70 | Frederick-S/Introduction-to-Algorithms-Notes | /src/chapter_09/randomized_select.py | 562 | 3.75 | 4 | from ..chapter_07.randomized_quick_sort import randomized_partition
def randomized_select(numbers, i):
assert i <= len(numbers)
return randomized_select_internal(numbers, 0, len(numbers) - 1, i)
def randomized_select_internal(numbers, p, r, i):
if p == r:
return numbers[p]
q = randomized_p... |
a54cbd78a331efa17194680c55629baa2599021f | arinmsn/My-Lab | /Books/PythonCrashCourse/Ch8/8-1_Message.py | 311 | 3.78125 | 4 | # Write a function called display_message() that prints one sen-
# tence telling everyone what you are learning about in this chapter. Call the
# function, and make sure the message displays correctly.
def display_message(message):
print(message)
display_message("I am learing about functions in Python.") |
a96de7db645c7f3f52fed08615dce5bc3053f155 | zzy1120716/my-nine-chapter | /catagory/BitManipulation/0084-single-number-iii.py | 744 | 3.78125 | 4 | """
84. 落单的数 III
给出2*n + 2个的数字,除其中两个数字之外其他每个数字均出现两次,找到这两个数字。
样例
给出 [1,2,2,3,4,4,5,3],返回 1和5
挑战
O(n)时间复杂度,O(1)的额外空间复杂度
"""
class Solution:
"""
@param A: An integer array
@return: An integer array
"""
def singleNumberIII(self, A):
# write your code here
s = 0
for x in A:
... |
874efa871b25e5d91a5f664ca30e1430c73e2b8e | hmchen47/Programming | /Python/PythonHardway/ex38.py | 1,888 | 4.5 | 4 | #!/usr/bin/env python3
# _*_ coding: utf-8 _*_
# Exercise 38: Doing Things to Lists
"""
Usage: python3 ex38.py
"""
ten_things = "Apples Oranges Crows Telephone Light Sugar"
print("Wait there's not 10 things in that list, let's fix that.")
stuff = ten_things.split(' ')
more_stuff = ["Day", "Night", "Song", "Frisbe... |
f13cd71401064aa3a62fb920443a2764922c8ab3 | AnhquanNguyenn/PythonPracticeScripts | /Minimum Range Needed To Sort/minRange.py | 2,012 | 4.03125 | 4 | # as we go through the list, the numbers should be bigger than the previous, but less
# than the next. If it doesn't satisify either, then that specific value is out of order
# and we need to update the lowIndex and maxIndex
def minRange(numbersRange):
length = len(numbersRange)
maxIndex = length - 1 ... |
831f1154f288b8f78c4c5e759e5b34f97844f144 | charleskausihanuni/B2-Group-Project | /Dropdown with Search.py | 2,159 | 3.546875 | 4 | from Tkinter import *
import sqlite3 as sql
master = Tk()
col = StringVar(master)
col.set("Colour")
option = OptionMenu(master, col,"Any","", "Black", "Blue", "Green", "Red", "Silver", "White")
option.pack()
loc = StringVar(master)
loc.set("Location")
option = OptionMenu(master, loc,"Any","", "Birmingham", "Cardi... |
f409661ead21a3586c89accb317ed539bdbe3ed7 | Mukulphougat/Python | /day2.py | 591 | 4.03125 | 4 | # Not using a middle name
def get_formatted_name(first_name, last_name, middle_name=' '):
if middle_name:
full_name = first_name + ' ' + middle_name + ' ' + last_name
else:
full_name = first_name + ' ' + last_name
return full_name.title()
magician = get_formatted_name('harry','potter')
prin... |
2d8570d292b7d90e016afef67d538e36d396771c | jeffschaper/cs50 | /pset7/houses/roster.py | 530 | 3.734375 | 4 | import sys
from cs50 import SQL
# Error checking
if (len(sys.argv) != 2):
exit(1)
db = SQL("sqlite:///students.db")
house = sys.argv[1]
results = db.execute("SELECT first, middle, last, house, birth FROM students WHERE house = ? ORDER BY last, first", house)
for row in results:
updatedLast = row["last"] + ",... |
d30a38908e008ce2ea77d8f6aa98114830a9ef4b | oscaroceguera/init_python | /23_object_oriented_programming/code.py | 175 | 3.75 | 4 | # dictionary
student = {"name": "oscar", "grades": (89, 90, 93, 78, 90)}
def average(sequence):
return sum(sequence) / len(sequence)
print(average(student["grades"]))
|
05492e8c77dd9314ad70897252eaf007cd531e29 | AileenXie/leetcode | /076_minimum_window_substring_.py | 841 | 4.0625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/12/15 3:57 PM
# @Author : aileen
# @File : 076_minimum_window_substring_.py
# @Software: PyCharm
"""
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
Example:
Input: S = "ADOBECODE... |
eca0bc28da92c710446f09b402ac93b5d8b5749a | zdorow/PythonClassStuff | /Tuition.py | 1,898 | 4.1875 | 4 |
from tkinter import *
# Getting the GUI going.
root = Tk()
root.title("Tuition Calculator")
root.configure(background='black')
root.geometry("395x175")
# Defining the initial label that shows when program starts.
tuitionOutput = Label(root, text="Press Calculate or Alt-c to calculate tuition\n "
... |
80a7f8fd6bda5fac2514a076ed8f9aa8e28abda6 | jty-cu/LeetCode | /Algorithms/021-Merge Two Sorted Lists.py | 1,710 | 4.09375 | 4 | ## 题目类型:链表
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
## 双指针
## 时间复杂度:O(m+... |
925f6575bd8d32ba2d596af25d1fc8691b6824f2 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/hamming/34c3a36a97864135bc30ad6233055673.py | 140 | 3.53125 | 4 | def distance(sec1, sec2):
counter = 0
for (x, y) in zip(sec1, sec2):
if x != y:
counter += 1
return counter
|
17dc7878d24144028fdb5912e4a700918d935e43 | arefmalek/Electoral_census | /geoplots/income_plots.py | 695 | 3.578125 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from statistics import mean
income = pd.read_csv("data_v2\ACSSPP1Y2010.S0201_data_with_overlays_2020-11-14T112132.csv")
income = income.drop(0)
income = income.drop(52)
df = pd.DataFrame({
"State": income["NAME"],
"Median Income": income... |
b3abd5e7627da8827b93fec1518884475b42a40d | bhushangawde/Daily-Coding-Problems | /093/sol.py | 2,759 | 3.671875 | 4 |
from tree import Node
import random
class TreeNode(Node):
def __init__(self, val=None):
super().__init__(data=val)
def insert_node_rnd(self, val):
if self.left is None and self.right is not None:
self.left = TreeNode(val)
elif self.right is None and self.left is not None... |
e24e5bbc51423fd9a7af7ad60ba51c1ef9d21159 | PavanKulkarni/python-code-samples | /code/medium/hamming.py | 392 | 3.75 | 4 |
def hammingdistance( a, b , bits = 32):
a_int = 0
for i in a:
a_int = a_int + ord(i)
b_int = 0
for i in b:
b_int = b_int*10 + ord(i)
def _hamdist(x, bits):
if bits:
return (x & 1) + _hamdist(x >> 1, bits-1)
return x & 1
return _hamdist( a_int ^ b... |
546ed8a50f06ef7be0c129bdab46e8a2d421ee5f | p06039217/270201023 | /lab4/Power.py | 313 | 4.25 | 4 | #Write a Python program that asks the user for two integers a and b and calculates ab without using ** operator and pow function.
a = int(input("type a integer: "))
b = int(input("type a integer: "))
c = 1
if b >= 0:
for i in range(b):
c *= a
elif b < 0 :
for i in range(b, 0) :
c /= a
print(c) |
03427eb03e5ea6111e7329f024410f425fa0ac50 | ecly/pointer_summarization | /tools/calc_stats_tests.py | 2,112 | 3.765625 | 4 | """
Copyright (c) 2019 Emil Lynegaard
Distributed under the MIT software license, see the
accompanying LICENSE.md or https://opensource.org/licenses/MIT
Some basic tests for the edit distance computation in the `calc_stats` module.
Example: `python -m tools.calc_stats_tests`
"""
import unittest
from .calc_stats impor... |
dee02cb9fd5c49b85a4c04b474c057e56274a66b | zhouhaosame/leetcode_zh | /offer/42_连续子数组的最大和.py | 399 | 3.84375 | 4 | def find_maximum_subarray_sum(nums):
if not nums:
return nums
max_sum_list=[0]*len(nums)
max_sum_list[0]=nums[0]
for i in range(1,len(nums)):
if max_sum_list[i-1]>0:
max_sum_list[i]=max_sum_list[i-1]+nums[i]
else:
max_sum_list[i]=nums[i]
return max(max... |
aafd32e0f1f9424f70001385fbae61901b95f556 | hiyouga/PY-Learning | /homework/base.py | 836 | 3.5625 | 4 | class Stack:
def __init__(self):
self._elems = []
def isEmpty(self):
return self._elems == []
def top(self):
if self._elems == []:
raise Exception('Stack is empty when using top()!')
else:
return self._elems[-1]
def push(self, elem):
sel... |
8da774846ea072aa05f7ba55970ce2703f6aaf90 | agustinfernandez/Python_Unsam | /ejercicios_python/Clase 4/estimar_py.py | 319 | 3.53125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 31 20:43:46 2020
@author: agustin18
"""
def generar_punto():
x = random.random()
y = random.random()
return x,y
N=100000
M=0
for i in range(N):
x, y= generar_punto()
if x**2 + y**2 < 1:
M+=1
print(f' pi - {4*M/N}')
|
ce44636f7fc3218284d3889cda52e405baab9a4d | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_95/2089.py | 535 | 3.546875 | 4 | str1="ejp mysljylc kd kxveddknmc re jsicpdrysi rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd de kr kd eoya kw aej tysr re ujdr lkgc jv"
str2="our language is impossible to understand there are twenty six factorial possibilities so it is okay if you want to just give up"
li={}
for i in xrange(len(str1)):
li[str1[i]]=str... |
6905166b46b81915478b2e5e4a706b959c85c081 | janetaz/begin-python | /stackFxnClass.py | 2,536 | 3.515625 | 4 | #! usr/bin/env python3
#attempt to make class to pass arguments to tkinter functions
import tkinter as tk
from tkinter import *
class Functionality:
def __init__(self, master):#include frame here?
self.master = master
self.bC = Button(master, text = 'Commit', command = self.commit)
self.b... |
fcf0daac9222679598e9d7d0626b1998d665e7b3 | BarunBlog/Python-Files | /case_swap_of_string.py | 311 | 4 | 4 |
if __name__ == "__main__":
str = input()
len = len(str)
str2 = ""
for i in range(len):
if str[i].islower():
str2 = str2 + str[i].upper()
elif str[i].isupper():
str2 = str2 + str[i].lower()
else:
str2 = str2 + str[i]
print(str2)
|
f7023be2fd781c64c331d4f36e8ee7dff11e329f | kurniawan2805/hackerrank.py | /stairCase.py | 225 | 4.125 | 4 | # Complete the staircase function below.
def staircase(n):
s=''
for i in range (n):
s+='#'
# print "{0:{1}}".format(n, s)
print ("{:>{width}}".format(s, width=n))
#'{:>n}'.format('*')
|
e85adb752e6bec4e5f36047de6469fb44bdd2aef | ariesduanmu/ctf_challenges | /others/compress/huffmantree.py | 2,654 | 3.515625 | 4 | # -*- coding: utf-8 -*-
from collections import Counter
class BinaryTreeNode():
def __init__(self, value = None, left=None, right=None):
self.value = value
self.left = left
self.right = right
@property
def isLeaf(self):
return self.left is None and self.right is None
class... |
fa0a630939b3f92ecc4d452a62d8c6fd079835d0 | God007999/mdpython | /kingmaker7.py | 148 | 4.03125 | 4 | #!/usr/bin/python3
# guess what the program does??
import random
r=random.randint(1,6) # gives random num
while r<6:
r=r*1
print(r,"won the game") |
62a98f01b0da8ec52eb7485509c9ecc87d78299e | anton-shablyko/checkio_solutions | /incinerator/bird language.py | 408 | 3.703125 | 4 | VOWELS = "aeiouy"
def translate(phrase):
i = 0
result = ''
while i < len(phrase):
if phrase[i] in VOWELS:
result += phrase[i]
i += 3
elif phrase[i] == ' ':
result += phrase[i]
i += 1
else:
result += phrase[i]
... |
667c078d290d2811cc2f3b5b05086e51c225dcac | marcaurele/marcaurele.github.com | /python/exo_5.4.py | 179 | 3.6875 | 4 | # -*- coding:UTF-8 -*-
interest_rate = 0.043 # 4.3%
amount = 100
year = 20
i=0
while i<year :
amount += amount * interest_rate
i += 1
print("End of year ", i, ":", amount)
|
09a05cf94f9ac400df01b043ca4eb8b2d928a979 | Sukhrobjon/leetcode | /easy/344_reverse_string.py | 802 | 4.125 | 4 | """
Write a function that reverses a string. The input string is given as an array
of characters char[].
Do not allocate extra space for another array, you must do this by modifying
the input array in-place with O(1) extra memory.
You may assume all the characters consist of printable ascii characters.
"""
class So... |
09d7f62d28bb1a81f369462076e34312b9f473a1 | Victor22Hugo/Projects | /Caesars Cypher/caesar.py | 1,535 | 4.15625 | 4 | # A Caesar Cypher encription works by shifting the whole alphabet by a given number, making the content of a letter or
# message appears nonsense for the unknow eye
import string
def caesar(text, shift, alphabets):
def shift_alphabet(alphabet):
return alphabet[shift:] + alphabet[:shift]
shifted_alph... |
9f1f2dbc3bc0db93e7803dbe078cd8dde92a3ff9 | metadataR/python-hackerrank | /detsquare_matrix.py | 398 | 4.09375 | 4 | # read in square matrix and print determinant
# Here is the option to use the _ variable, which in reality, is just another variable.
#for _ in range(n):
# do_something()
#Note that _ is assigned the last result that returned in an interactive python session:
#>>> 1+2
#3
#>>> _
#3
import numpy
n=input()
a=numpy.arr... |
16d5cc7f728b6c9fd233b640fe71b12da33225c6 | JoaoVictor-M/exercicios-curso-python | /Módulo 1/Ficha+IMC.py | 307 | 3.609375 | 4 | #Ficha + IMC
nome = input("Digite seu nome: ")
idade = int(input("Digite sua idade: "))
altura = float(input("Digite sua altura: "))
peso = float(input("Digite seu peso: "))
imc = peso / (altura ** 2)
print(f"\n{nome} tem {idade} anos, pesa {peso}kg e mede {altura:.2f} de altura.\nSeu IMC é {imc:.2f}.") |
401345ea2cb054740d030315c8be06da996c8b29 | jobartucz/random_python_programs | /calculate_pi.py | 769 | 3.78125 | 4 | import math
import random
pi = 0
pi2 = 3
for i in range (1,10):
# formula 1
pi = pi + (((-1)**(i+1)*4) / (2*i-1))
# formula 2
pi2 = pi2 + ((-1)**(i + 1) * 4) / ((i*2)*((i*2)+1)*((i*2)+2))
print ("Formula 1:")
print (pi, pi - math.pi)
print ("Formula 2:")
print (pi2, pi2 - math.pi)
radius = 100... |
a0bc63f029732b5bac7fd2304598d7b9411ce7cd | jinyoungHan/Python | /strings/boyer-moore.py | 2,171 | 3.84375 | 4 | '''
Boyer–Moore string-search algorithm is an efficient string-searching algorithm that is the standard benchmark for practical string-search literature.
references: https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm
'''
class last_index(object):
# Generate a dictionary with the last index of... |
a6b5e9bea2a99be57cb5b0852f2c6b8279fd1637 | mcbuehler/ssw-prediction | /code/prediction/prediction_set.py | 7,739 | 3.578125 | 4 | import numpy as np
from core.data_manager import DataManager
from preprocessing.dataset import DatapointKey as DK
class PredictionSetBase:
"""A class that receives as input the processed variables and the definition
that you want classification for and returns the data either in the correct
format for pre... |
17f42a6ca74a22da6fe2be121a3d6f784a9720f9 | natec425/Gas-Pump | /shell.py | 1,579 | 4.03125 | 4 | import core
def print_menu(inventory):
'''Inventory -> None
Prints a menu for the given inventory.
>>> print_menu([['Regular', 2.0], ['Premium', 3.0]])
Gas Costs:
Regular - $2.00
Premium - $3.00
'''
print('Gas Costs:')
for name, cost in inventory:
print('{} - ${:.2f}'.for... |
e66274515ae64d666fd400d92cbbd2d072f84285 | HenryXin/PythonExamples | /tests/callback.py | 309 | 3.75 | 4 | #!/usr/bin/env python
class Callback:
def __init__(self, color):
self.color = color
def __call__(self):
print 'turn ', self.color
def changeColor(self):
print 'turn ', self.color
if __name__ == '__main__':
cb3 = (lambda color='red': 'turn ' + color)
print cb3()
|
d82ad3a88fd8a98db0088c6f0b2f4e613975c840 | Peepow2/Chess-by-PP-James | /chess.py | 1,262 | 3.515625 | 4 | queue = list()
chess = list()
num = int(0)
def pos(x, y):
return (x-1) + (y-1)*8
def not_out_of_area(x, y):
x = int(x); y = int(y);
if(1 <= x <= 8 and 1 <= y <= 8):
return True
return False
def input_queue(x, y, n):
x = int(x); y = int(y); n = int(n);
if(not_out_of... |
31ab76d6a130171b8e7f28fab926eeaa3a2c05f8 | galenwilkerson/City-Lattice | /city_lattice.py | 16,721 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 22 11:59:30 2016
@author: galen
@email: gjwilkerson@gmail.com
City Lattice
Investigate effects of small-world connections on shortest travel time paths
Compare shortest distance path to shortest travel time path
Represent City as Lattice
Set travel speed
Add small ... |
94cb1ece7fbcd2edb060d4373e62e13b0c0c2476 | antoniozahe/Computacion2 | /Practicas/Practica4/NewtonInterpolation.py | 5,027 | 3.59375 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sympy.abc import x
class Depuracion():
def depuracion(self,df,paiscode, yr0, yr1,ejex,ejey):
dffilter=(df[(df.Code == paiscode)])
df_filt=(dffilter[(dffilter.Year >= yr0) & (dffilter.Year <= yr1)])
year=df_filt['... |
18a01289e794b2eacaf182bd65c7cddb595fba4a | ldharo/Internship2012 | /ifF1WAE/secondround/parser.py | 10,347 | 3.90625 | 4 | # There shall be no defensive programing.
# Tests are maintained and print something if they are not passed,
# but we'll let the program crash without raising an error
import treeClass
#######################################
# Reimplementation of some functions from the library #
#####################################... |
dd85e24a1163c976d51b324594a2a4dbf9e4664a | MarsBighead/mustang | /Python/tree/a-sorted-doubly-linked-list.py | 1,954 | 3.75 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
class DoublyLinkedListNode:
def __init__(self, node_data):
self.data = node_data
self.next = None
self.prev = None
class DoublyLinkedList:
def __init__(self):
self.head = None
self.tail = None
... |
49a357343b5be68efd61fee312ab6092ea2439c9 | Tuuleh/python_test | /string_iteration.py | 388 | 3.59375 | 4 | from time import sleep
class RepeatingStr:
def __init__(self, _str):
self._str = _str
self.current = 0
def __iter__(self):
return self
def __next__(self):
index = self.current
if index == len(self._str):
index = 0
self.current = 0
else:
self.current += 1
return self._str[index]
foo ... |
84e61c47ea36bb90c91a63a63cb61e86582a5f0f | RealA10N/KarmaRex | /KarmaRex/database/database.py | 10,594 | 3.90625 | 4 | """
This module contains two main classes: `Data` and `Database`.
The Data object
===============
The main data container. Each instance can contain two types of data:
1. Instant data
2. Not-instant data
Instant data can be any object that is supported by the `json` format (most
basic data structures in Python, e.g... |
049624706bb4b7c1d86939be7fba21c15cd0291b | nata27junior/Curso-de-Python | /Mundo 2/ex048.py | 415 | 3.796875 | 4 | from time import sleep
print('''Exercício Python 048: Faça um programa que calcule a soma entre todos
os números que são múltiplos de três e que se encontram no intervalo de 1 até 500.''')
soma = 0
cont =0
for c in range(1, 501):
if c %2!= 0:
if c %3 ==0:
soma += c
cont += 1
print(... |
45b5e18c7a1816fbd5d81c11476a52c286f48251 | vedmara/ALgorithms_python_lessons_1-8 | /lesson_1/lesson_1_Task_7.py | 919 | 4.21875 | 4 | # По длинам трех отрезков, введенных пользователем,
# определить возможность существования треугольника,
# составленного из этих отрезков.
# Если такой треугольник существует, то определить,
# является ли он разносторонним, равнобедренным или равносторонним.
a = int(input("a = "))
b = int(input("b = "))
c = int(in... |
a35e278c79a82765eab4c5a1c030a6d563f5ce53 | xsong15/WebApp-MBTA | /mbta_helper.py | 2,748 | 3.671875 | 4 | import urllib.request
import json
from pprint import pprint
def get_json(url):
"""
Given a properly formatted URL for a JSON web API request, return a Python JSON object containing the response to that request.
"""
f = urllib.request.urlopen(url)
response_text = f.read().decode('utf-8')
respon... |
15b88b2875d43659bf1b24bd000a9a7ecd718faa | MichaelArslangul/python_Sandbox | /SortLinkedList.py | 1,039 | 4.1875 | 4 | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class SortLinkedList:
"""
Sort a linked list in O(n log n) time using constant
space complexity.
Example 1:
Input: 4->2->1->3
Output: 1->2->3->4
Example 2:
Input: -1->5->3->4->0
Output: -1->... |
009bec48bea5645a67ce4a699ef0feda80893dc9 | ZeeshanJ99/Deloitte-Python | /hangman/Beginning the game.py | 866 | 3.90625 | 4 | import random
from hangman_words import word_list
word = random.choice(word_list)
allowed_errors = 8
guesses = []
done = False
while not done:
for letter in word:
if letter.upper() in guesses:
print(letter, end=" ")
else:
print("_", end=" ")
print("")
guess = in... |
312181fa7c8767060c8b1354694e186d6dae1a54 | varshajoshi36/practice | /leetcode/python/easy/majorityElement.py | 177 | 3.609375 | 4 | """
"""
def majorityElement(nums):
return sorted(nums)[len(nums)/2]
def main():
print majorityElement(map(int, raw_input().split(',')))
if __name__ == '__main__':
main()
|
5c5486f8e1f69a011be4ddaaa4249ed698ef6840 | mraharrisoncs/python-basics | /e2.py | 121 | 3.921875 | 4 | # Mr. H. This program asks your name and says hello
name=input("What is your name?")
print("Hello "+name)
age=input
|
ccc235511b483f982f1bad961f0281cce78f1f34 | Sagar-Chauhan492/delta-EB32 | /car_pedes.py | 2,597 | 3.625 | 4 | n = input("Enter the thing which youu want to detect a (car and pedestrian) or (face) : ")
if n == "car":
import cv2
video = cv2.VideoCapture( '''here provide your file path''' )
# Our pre trained car and pedestrian classifiers
car_tracker_file = 'cars.xml'
pedestrian_tracker_file ... |
35289ebd8c3fb00cbf319b1b89678723e4be64d1 | DataChris24/CSProjects2021 | /Python Projects/Assignment 4/test.py | 257 | 3.734375 | 4 | from LinkedList import LinkedList
list = LinkedList()
list.append(1)
list.append(2)
list.append(3)
list.append(4)
list.append(5)
list.append(6)
list.append(7)
list.append(8)
list.append(9)
list.append(10)
print(list)
data = list.data_index(2)
print(data)
|
f8d72929ad24c08e2380346f9b2b962a582efc03 | MayuriTambe/Programs | /Programs/DataStructures/sets/CreateSet.py | 243 | 3.59375 | 4 | #To create Set
colors={"red","green","yellow","Pink","black"}
print("The set1 is:",colors)
print(type(colors))
numbers={1,2,3,5,7,8,9}
print("The set2 is:",numbers)
Month_year={"januray:2020","february:1996","March:2015"}
print(Month_year)
|
11120e1df5c641e8ddfbc87f86cb7ec14691b1cb | jang010505/Algorithm | /BOJ/6764.py | 236 | 3.90625 | 4 | a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a==b and b==c and c==d: print("Fish At Constant Depth")
elif a<b and b<c and c<d: print("Fish Rising")
elif a>b and b>c and c>d: print("Fish Diving")
else: print("No Fish")
|
04880b34fbe15f93597023e1c11d7ff7bfa49045 | GitPistachio/Competitive-programming | /Contests/LEARNDSA - DSA Learning Series/Contest 1/FCTRL - Factorial/Factorial.py | 570 | 3.765625 | 4 | # Project name : CodeChef: FCTRL - Factorial
# Link : https://www.codechef.com/LRNDSA01/problems/FCTRL
# Author : Wojciech Raszka
# E-mail : contact@gitpistachio.com
# Date created : 2020-05-31
# Description :
# Status : Accepted (33527157)
# Tags : python, number of trailing zeros in... |
f23662240c9f8f10e1c4db695c29ba3ee5c6e457 | sy91217/python-training | /Python-training/test-class.py | 1,229 | 3.75 | 4 | # 類別的定義與使用
# 類別: 可封裝變數或函式(封裝的變數或函式, 統稱為類別的屬性)
# 定義 > 使用
# 要先定義(建立)類別, 然後才能使用類別中封裝的屬性
# 定義類別
# 基本語法
# class 類別名稱: # 類別名稱通常習慣首字大寫
# 定義封裝的變數
# 定義封裝的函式
# 程式範例
# 定義 Test 類別
# class Test:
# x=3 # 定義變數
# def say(): # 定義函式
# print("Hello")
# 使用類別
# 基本語法
# 類別名稱.屬性名稱
# 程式範例
# 定義... |
1954835054f916d76c3df0399ff5dea9c7a59cf0 | BrettMeirhofer/CIS2348 | /Homework2/6.17.py | 323 | 3.65625 | 4 | password = input()
updatedpassword = password.replace("i","!")
updatedpassword = updatedpassword.replace("a","@")
updatedpassword = updatedpassword.replace("m","M")
updatedpassword = updatedpassword.replace("B","8")
updatedpassword = updatedpassword.replace("o",".")
updatedpassword += "q*s"
print(updatedpassword... |
7384eef06d4c7afaba76c8655dcbe1313b5ca604 | zzimits/Highway-Hierarchies-Dijkstra-Implementation | /Code/hexagon_test.py | 824 | 3.546875 | 4 | import matplotlib.pyplot as plt
import numpy as np
def hexagon(center,size):
x_vals = []
y_vals = []
for i in range(7):
deg = (60*i)-30
rad = deg*np.pi/180
x_vals.append(center[0]+size*np.cos(rad))
y_vals.append(center[1]+size*np.sin(rad))
return x_vals,y_vals
def tile_hex(rows,cols):
s... |
9467b65d58d91a87f7652b1db306fa3c632a79dd | engineerfernandogabriel/Python_CursoEmVideo | /Desafio 020.py | 548 | 4.03125 | 4 | #O mesmo professor do desafio anterior quer sortear a ordem de apresentação de trabalhos dos alunos.
#Faça um programa que leia o nome dos quatro alunos e mostre a ordem sorteada
from random import shuffle
nome1 = input('Digite o nome do primeiro aluno: ')
nome2 = input('Digite o nome do segundo aluno: ')
... |
58712bc481580eed49cc58a85cd5b813574884fc | TomiSar/ProgrammingMOOC2020 | /osa03-10_risuaitanelio/src/risuaitanelio.py | 123 | 3.84375 | 4 | leveys = int(input("Leveys: "))
rivit = int(input("Korkeus: "))
while rivit > 0:
print(leveys * "#")
rivit -= 1 |
64ba15f4baffb0aee46b00ff7ea314e424be1f12 | LeynilsonThe1st/python | /algebra/exe1.py | 503 | 3.78125 | 4 | """
1.Construa as seguintes matrizes:
a) A = (aij)2x5, em que aij = 3i - 3j
b) B = (bij)2x3, em que bij = i^2 + j^3
c) C = (cij)3x3, em que cij = i + j
"""
from matriz import Matriz
def alinea_a(i, j):
return 3 * i - 3 * j
def alinea_b(i, j):
return (i ** 2) + (j ** 3)
def alinea_c(i, j):
re... |
fdaae9577fa0821a143ca185cc1019d03bcf5202 | Nathnos/probabilistic_battleships | /game/board_setup.py | 1,920 | 4.1875 | 4 | """
Main game functions
"""
import numpy as np
from game.game_tools import (
get_direction,
get_boat_size,
get_random_direction,
get_random_position,
)
def can_place(grid, boat, position, direction):
"""
grid : numpy array
boats : represented by an integer
position : tuple (x, y)
... |
e3721a9968749c9d1aeab0fae140d2f71722b25c | felipesch92/PythonExercicios | /ex070.py | 857 | 3.84375 | 4 | # Crie um programa que leia o nome e o preço de vários produtos.
# O programa deverá perguntar se o usuário vai continuar ou não. No final, mostre:
# A) qual é o total gasto na compra.
# B) quantos produtos custam mais de R$1000.
# C) qual é o nome do produto mais barato.
n = ''
p = 0
t = 0
c = 0
b_p = 0 # preço produ... |
a98f365377041c7bc09c23bc7a30b47759156ac3 | igor-dulger/learn_algorithms | /Alg1/Permutation.py | 681 | 3.765625 | 4 | # Client. Write a client program Permutation.java that takes an integer k as a command-line argument; reads in a sequence
# of strings from standard input using StdIn.readString(); and prints exactly k of them, uniformly at random. Print each
# item from the sequence at most once.
from RandomizedQueue import Randomize... |
f966deb931d59421b1f38a8b86a6a57315246f57 | iharnoor/PythonicPrograms | /ArrayRotation.py | 365 | 3.6875 | 4 | def array_left_rotation(a, n, k):
for x in range(k):
a.append(0)
swap(a, 0, len(a) - 1)
a.pop(0)
return a
def swap(a, i, j):
temp = a[i]
a[i] = a[j]
a[j] = temp
n, k = map(int, input().strip().split(' '))
a = list(map(int, input().strip().split(' ')))
answer = array_le... |
158a5af552c95dede9537a4fa3ce76025ea587e0 | nivipandey/python | /conditions/ifelse.py | 66 | 3.671875 | 4 | x=10
if x%2==0:
print(x,"is even")
else:
print(x,"isodd")
|
29b728816861af0e80683ef5130f984987692577 | klam260/Rock-paper-scissors-game-in-python | /Rock Paper Scissors.py | 2,646 | 4.375 | 4 | import sys
import random
def computerChoice():
#options for rock paper scissor
choice = ['rock', 'paper', 'scissor']
#randint will choose a number from 0-2, which will be the choice for rock paper or scissors
computerchoice = choice[random.randint(0,2)]
return computerchoice
#tests whether the v... |
d8268199325cb615c6c07b12fad7c2dd9c444736 | JMCCMJ/CSCI-220-Introduction-to-Programming | /HW6/New folder/average_time_by_hour.py | 2,710 | 4.1875 | 4 | # average_time_by_hour.py
# answers to T/F, Multiple Choice and Discussion on p194-196 (30% of hw grade)
# Reads a data file where every line is in the form:
# m/d/yyyy h:mm,response_time ,throw_away
# note: d can be d or dd (i.e. 9 or 13)
# note: h can be h or hh (i.e. 6 or 12)
# note: response_time is in milliseco... |
ca27b3fcb9b9d8d65e500cd0dd3abeedde50f667 | jageradrienn/http-courses | /python/Evi/02_het/06_oop.py | 1,028 | 3.671875 | 4 | # Osztályok és Objektumok
# class
class Dog:
nev = None
kor = 0
__etvagy = 0
def __init__(self, fajta, szin):
self.fajta = fajta
self.szin = szin
def eat(self):
self.etvagy -= 1
def play(self):
self.etvagy += 1
morzsi = Dog('tacsi', 'barna')
print(morzsi._e... |
6d4862762a768f25ec1564eb733dfd2ff7735328 | rmlippin/ten-pin-bowling | /CalcBowlingScore.py | 2,800 | 3.75 | 4 | """
SDE/SDET - Take Home Test
Raquel Lippincott 6/25/19
Python 3.7.2
"""
import sys
from os import path
NUM_FRAMES = 10
def calc_score(roll_list: list) -> int:
"""Calculates the score of an entire game of Ten-Pin Bowling.
Args:
roll_list: A list of all the rolls in the game. Each roll is repres... |
3cb9007a99fddbfd86962a49e8040ab14c007fd2 | bkalcho/hacking-secret-ciphers | /cryptomath.py | 862 | 4 | 4 | # Author: Bojan G. Kalicanin
# Date: 18-Mar-2017
# Description: Finding GCD - greatest common divisor using Euclid's Algorithm,
# and finding modular inverse using Euclid's Extended Algorithm.
def gcd(a, b):
"""Find greatest common divisor using Euclid's Algorithm"""
while a != 0:
a, b = b % a, a
r... |
2dbadce9d4d45885537755e69599f7774af7142a | x4nth055/pythoncode-tutorials | /gui-programming/platformer-game/world.py | 4,383 | 3.5625 | 4 | import pygame
from settings import tile_size, WIDTH
from tile import Tile
from trap import Trap
from goal import Goal
from player import Player
from game import Game
class World:
def __init__(self, world_data, screen):
self.screen = screen
self.world_data = world_data
self._setup_world(world_data)
self.world_... |
bc3e63463e564b1ef84b8ba2d46268abcc979143 | limapedro2002/PEOO_Python | /Lista_02/Vinicius Barbosa/lista2_q1.py | 1,278 | 4.1875 | 4 | '''Utilizando listas crie um programa que faça 5 perguntas para uma pessoa sobre um crime. As
perguntas são:
a. "Telefonou para a vítima?"
b. "Esteve no local do crime?"
c. "Mora perto da vítima?"
d. "Devia para a vítima?"
e. "Já trabalhou com a vítima?" O programa deve no final emitir uma classificação sobre
a partici... |
e17bfa2119b3230d6d6ab430ee6bdb951f0295bc | pooja1506/AutomateTheBoringStuff_2e | /chapter4/list_method_append_insert.py | 540 | 4.4375 | 4 | #method is used to call on a value
spam = ['hello', 'hi', 'howdy', 'heyas']
a = spam.index('hi')
#append - adds the value at the end of the list
spam.append('hey')
print(spam)
#insert - it can be used to add the value anywhere in the list
spam.insert(1,'hey')
print(spam)
#remove the value from the list
spam.remove('... |
dc17383af5894d75cad7187fb9e44f522a623a97 | gowthamgoli/Leetcode | /increasing_triplet_subsequence_334.py | 789 | 4.09375 | 4 | def increasingTriplet(nums):
if len(nums) < 3: return False
stack = []
stack.append(nums[0])
next_greatest = {}
for i in range(1, len(nums)):
while stack:
stack_top = stack[-1]
if stack_top < nums[i]:
next_greatest[stack_top] = nums[i]
... |
21ea564a91a14ab0e4a218a01edc6c194c8fd5a1 | prajwal60/ListQuestions | /learning/BasicQuestions/Qsn74.py | 270 | 3.953125 | 4 | # Write a Python program to hash a word.
word = input('Enter any word ')
changer = [1,2,3,4,5,6,2,3,1,0,4,5,0,2,1,7,6,9,4,5,7,8,6,4,9,3]
word = word.upper()
coded = word[0]
for i in word[1:len(word)]:
i= 65-ord(i)
coded = coded+str(changer[i])
print(coded)
|
ae73bbca984bb00b48e36321fed1b6176f88c8dc | NishantJalasutram/MyPython | /Assignments/Assignment_7.1-FileHandling.py | 167 | 3.9375 | 4 | fname=input("Please enter the file name: ")
try:
fhand=open(fname)
except:
print("File doesn't exist")
quit()
for val in fhand:
print((val.rstrip()).upper())
|
a6964a75a5e79b6f4c6e46b0ec694fe405a27903 | JoshRBrown/functions | /leetspeak.py | 613 | 3.828125 | 4 | text = "hello world"
letters_to_convert = ['A', 'E', 'G', 'I', 'O', 'S', 'T']
numbers = [ 4, 3, 6, 1, 0, 5, 7]
def leet(text):
translation = ""
uppercased_text = text.upper()
for letter in uppercased_text:
counter = 0
letter_to_add_to_translation = ""
for letter_to_convert in letters_to_... |
eca12abc81d745dc474903c076fb11505fe26efa | Bhuvanesh-prog/Alarm-Clock- | /Alarm Clock.py | 674 | 3.921875 | 4 | from datetime import datetime
alarm_time = ("Enter the time of alarm: HH:MM:SS\n")
alarm_hour = alarm_time[2]
alar_minute = alarm_time[3:5]
alarm_second = alarm_time[6:8]
alarm_period = alarm_time[9:11].upper()
print("Setting up alarm:...")
while True:
now = datetime.now()
current_hour = now.strftime("%H")
... |
dc89fda73beee1d7cd424c12b48b540f06e5af32 | slavaider/python | /repeat_from_book/03_list_dic.py | 773 | 3.84375 | 4 | if __name__ == '__main__':
x = [1, 2, 3]
print('Списки')
# list[start:end:step] default list[0==' ', max_length==' ', 1==' ']
print(x[0:])
print(x[1:])
print(x[2:])
print(x[:0])
print(x[:1])
print(x[:2])
print(x[-1])
print(x[-2:])
print('Словари')
y = {1: 2, 3: 4, 5: ... |
33475ef16b8d31a99ad6563df763386b16e72a89 | szazyczny/MIS3640 | /Session05/turtle-demo.py | 3,256 | 4.46875 | 4 | #TURTLE MODULE
# import turtle
# jack = turtle.Turtle() #importing module and using class called turtle
# jack.fd(100) #call a method, this means forward 100 pixels, draw a horizontal line
# jack.lt(90) #lt means left turn 90 degrees
# jack.fd(100)
# jack.lt(90)
# jack.fd(100)
# jack.lt(90)
# jack.fd(100) #to draw a ... |
e27b63f5a0afd483d559af1eb5675d6e19dfff3d | bijeshofficial/coding_solutions | /CodeForces/510A.Fox_And_Snake.py | 403 | 3.6875 | 4 | def func(n):
height = n[0]
length = n[1]
counter = 0
for i in range(height):
if i%2 == 0:
print('#'*length)
elif i%2 != 0 and counter%2 == 0:
print('.'*(length-1) + '#')
counter += 1
elif i%2 != 0 and counter%2 != 0:
print('#' + '.'... |
5083c00e95b56f33aa95116184443827f3e352c2 | msansome/Crypto | /Crypto/CryptoBook/caesarClass.py | 2,217 | 3.875 | 4 | class Caesar():
def __init__(self, message='', key=0, extended_symbol_set=False):
self.message = message
self.key = key
self.extended_symbol_set = extended_symbol_set
self.EXT_SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?.'
self.BASIC_SYMBOLS =... |
a7b3b02d962b10b56bf1ed68152d9310f58e9099 | gabriellaec/desoft-analise-exercicios | /backup/user_275/ch65_2019_10_02_12_51_55_074387.py | 409 | 3.640625 | 4 | def cria_bigramas(T):
bigramas=[]
i=0
n=len(T)-1
while i<n:
B=T[i]+T[i+1]
bigramas.append(B)
i+=1
return bigramas
ex="babador"
print(cria_bigramas(ex))
def acha_bigramas(ex):
lista_final=[]
i=0
B=cria_bigramas(ex)
n=len(B)
while i<n:
if B[i] not in lista... |
1a12b93b9a4c42ad09f8134a18127750d51ac39b | Andrey-V-Georgiev/PythonOOP | /Preparation2April2020/tests/test_advanced.py | 2,025 | 3.828125 | 4 | import unittest
from project.player.advanced import Advanced
class TestAdvanced(unittest.TestCase):
def test_constructor_with_valid_input(self):
advanced = Advanced("a")
self.assertEqual(advanced.username, 'a')
self.assertEqual(advanced.health, 250)
self.assertFalse(advanced.is_d... |
102dd950fab82271f3f554b487e8e3b19979a893 | AlejandroGomez001/Trabajos_Clases | /tarea.py | 1,078 | 3.890625 | 4 | class Tarea:
def __init__(self):
pass
def calcularJornada(self):
ht, he, het=0,0,0
ph, phe, ph=0,0,0
ht = input("Ingrese horas trabajadas: ")
ph = float(input("Ingrese valor hora: "))
if ht > 40:
he = ht-40
if he > 8:
... |
43c180181b9c5a00b81557a065620ded54df8d5f | loggar/py | /py-core/list/list.counter-items.py | 108 | 3.515625 | 4 | from collections import Counter
myList = [1, 1, 2, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3]
print(Counter(myList))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.