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
732997d77e5c6eeaea724cde2f5cc796801cf943
Mahesh-ha/Socket-Programming-and-Networking
/client.py
6,933
3.65625
4
# importing Tkinter and math from tkinter import * import math from socket import * # calc class class calc: def send(self): serverName = '127.0.0.1' serverPort = 1206 clientSocket = socket(AF_INET, SOCK_STREAM) clientSocket.connect((serverName, serverPort)) se...
ad6f0d4b3bde1d269cd128d7d35166f880e3fadd
ColeWyeth/Neural-Networks
/NeuralNet.py
879
3.890625
4
#This is a rudimentary neural network. I believe that I could solve more difficult problems by following the same format. import Random n1 = [Random.rand,Random.rand] n2 = [Random.rand,Random.rand] neurons= [n1, n2] trainingSet = input("How many training vectors would you like to input?") for i in range(0,in...
7ecef19b0c8f66e0210d635beb4e4d4e39fa0501
Athindu/Cipher
/Cipher.py
5,027
3.671875
4
import time alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] print("~~~~~~~~~~~~~~~WELCOME~~~~~~~~~~~~~~~\n") time.sleep(0.5) print("e---...
c9323126a1d3c26e91fe4832da490c3db32b2950
KaneMontgomery/cp1404practicals
/prac_01/shop_calculator.py
514
3.953125
4
items = int(input("Please input number of items: ")) total = 0 if items <= 0: print("Invalid number") items = int(input("Please input number of items: ")) for i in range(0, items, 1): price = float(input("Please enter price of item: ")) print("Price of item: {:.2f}".format(price)) total += price ...
b87dd9a3a7f05d1f06b842c4a2d28dd85edf0f70
akosENagy/application-process
/query.py
4,598
3.5
4
from utilities import run_select_query # QUERY FUNCTIONS #################################################################### # OUTPUT: QUERY RESULTS AS LIST OF TUPLES. TUPLE = ROW # #################################################################### def get_mentors(): ''' On this page you shoul...
17fc3162239646939323286bccfc7cfae1531265
jiwawa112/NLP
/assignment_03.py
8,087
4.5625
5
""" 2. Answer following questions: 1. Why we need machine learning methods instead of creating a complicated formula? 对于人类无法直接编码的过于复杂的任务,需要机器学习。有些任务非常复杂,如果不是不可能的话,人类可以明确地计算出所有的细微差别和代码,这是不切实际的。 因此,我们通过为机器学习算法提供了大量数据,让算法通过探索数据并搜索将实现程序员设定的模型来实现。模型执行的程度由程序员提供的成本函数决定,算法的任务是找到最小化成本函数的模型。 2. Wha't's the disadvantages of the ...
a8bbfb326bec028bad5b46574a51e5e3932dd685
yevgen93/python
/algorithms/find_single_number.py
336
3.6875
4
def find_single_number(array): d = {} for num in array: if num in d.keys(): d[num] += 1 else: d[num] = 1 for num, freq in d.items(): if freq == 1: return num array = [1, 1, 2, 2, 6, 3, 3, 4, 4] single_number = find_single_number(array) print...
7106d0c5f5c7936e1e69cd909da0ba9859528e4b
yevgen93/python
/algorithms/most_common_url_paths_in_log.py
1,108
3.640625
4
import re def most_common(file_path): d = {} with open(file_path, 'r') as file: for line in file: words = line.split() for word in words: if is_url_path(word): if word in d: d[word] += 1 else: ...
75405c30eaa97c9457c1b36d60380ae307995c12
yevgen93/python
/algorithms/palindrome.py
325
3.96875
4
def palindrome(num): if num < 0: return False original = num reversed = 0 # Reverse the original number while num > 0: reversed = reversed * 10 + num % 10 num //= 10 return original == reversed print(palindrome(1221)) print(palindrome(123)) print(palindrome(1233...
d9a8b7fc5b07e43657a112490b7bdad42c8a42e2
yevgen93/python
/algorithms/destination_city.py
796
3.90625
4
# You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. # Return the destination city, that is, the city without any path outgoing to another city. # It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be ...
3ac2b269e9e65d31a779babd9965b0a2bb287379
yevgen93/python
/algorithms/count_words_in_file.py
427
4.09375
4
def count_words(file_path): word_count = 0 with open(file_path, 'r') as file: for line in file: words = line.split() word_count += len(words) return word_count file_path = 'words.txt' word_count = count_words(file_path) print("Number of words in the file:", word_count) ...
8ae94337e251c8d29defa117cb664e9de7d89032
Maxim713/MLClass
/homeworks/second homework/Task G.py
143
3.703125
4
a, b = int(input()), int(input()) if a == b == 0: print("INF") elif not (a == 0) and (b % a == 0): print(-b//a) else: print("NO")
c7d12aeac9a924b64d03e210c0787e70b1fd8e10
Theveenan/Kahoot-Python-Game-Project
/Early Versions/V7 (working nested lists for storage).py
18,443
4.125
4
#MODULES ARE IMPORTED import time import random #FUNCTIONS ARE DEFINED #This function is used to create questions that will be asked for the 'play game' mode. def create_question(): try: #User enters how many questions they want to create. A loop asking for all necessary inputs will run that many times....
9858589924b5b2c4999c2cd3298a6c1697a64008
kashyap92/python-training
/operatoroverloading2.py
331
4.1875
4
#!/usr/bin/python class date(): def __init__(self): self.dd=7;self.mm=10;self.yy=2016 def __add__(self,date1): self.dd=self.dd+date1 return (self) def printvalues(self): print self.dd,self.mm,self.yy today=date() today+=5 today.pri...
c9e58aa8af5424e5b96811dd63afa86492c47c48
lucienne1986/Python-Projects
/pythonRevision.py
1,692
4.40625
4
animals = ['cat', 'dog', 'monkey'] for a in animals: print(a) #IF you want access to the index of each element within the body of a loop use enumerate #enums are constants #%-style formatting: %s and %r call the Enum class’s __str__() and __repr__() respectively; #other codes (such as %i or %h for IntEnum) treat t...
59b87b897187e9c22c00b844f4923e8624b13758
lucienne1986/Python-Projects
/pyton_generatingMatrices.py
715
3.6875
4
import numpy as np #generate an array of all zeros Z = np.zeros(10) print(Z) #outputs a vector of 10 with all zeros #create a matrix of size 10 X 10 of all zeros ZMat = np.zeros((10,10)) #having a tuple containing each dimension print(ZMat) #create a matrix of size 10 X 10 of all ones OMat = np.ones((10,10)) print(O...
0e87375922c3d294b3f5812b32ee2a6692bebbe6
amsun10/LeetCodeOJ
/Algorithm/Python/move-zeroes-283.py
572
3.671875
4
__author__ = 'xizhang' "https://leetcode.com/problems/move-zeroes/" class Solution(object): def moveZeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ length = len(nums) j = 0 for i in range(le...
94ab43281970119ab3ffe8e723539c0866f5f12c
amsun10/LeetCodeOJ
/Algorithm/Python/palindrome-number-9.py
1,068
4.125
4
# https://leetcode.com/problems/palindrome-number/ # Determine whether an integer is a palindrome. An # integer is a palindrome when it reads the same backward as forward. # # Example 1: # # Input: 121 # Output: true # Example 2: # # Input: -121 # Output: false # Explanation: From left to right, it reads -121. From ri...
78e3685d7d3ae8108eb3dc8da30ad8e600359996
amsun10/LeetCodeOJ
/Algorithm/Python/reverse-words-in-a-string.py
486
3.921875
4
# https://leetcode.com/problems/reverse-words-in-a-string/ class Solution: def reverseWords(self, s: str) -> str: s_array = s.split(" ") reversed_array = [x for x in s_array if x] reversed_array.reverse() return " ".join(reversed_array) if __name__ == '__main__': solution = S...
727c52e1370f007aec7cd2928bdb3baca2d2450a
amsun10/LeetCodeOJ
/Algorithm/Python/median-of-two-sorted-arrays-4.py
1,204
3.90625
4
# https://leetcode.com/problems/median-of-two-sorted-arrays/ # There are two sorted arrays nums1 and nums2 of size m and n respectively. # # Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). # # You may assume nums1 and nums2 cannot be both empty. class Solution(object...
6bf6f94738bb19decbf353385563749e371aef26
amsun10/LeetCodeOJ
/Algorithm/Python/spiral-matrix-II-59.py
3,677
3.515625
4
class Solution(object): """ https://leetcode.com/problems/spiral-matrix-ii/ """ output=[] def changemode(self, row_index, row_mode, row_positive_mode, col_index, col_mode, col_positive_mode, n): if row_mode: if row_positive_mode: if col_index > n - 1: ...
e3df8febb073038318ffa25963b6103174239918
pengfaliu/Code-Recipes
/Python/normal-project/decode-encode_for_base64/encode.py
659
3.53125
4
#/usr/bin/python #-*- coding: UTF-8 -*- # # # # 加密 # for unix import base64 import random import sys upperchr = 'ABCDEFGHIJKLMOPQRSTUVWXYZ' lowcarsechr = 'abcdefghijklmopqrstuvwxyz' otherchr = '~!@#$%^&*()?><:;' numchr = '1234567890' mselment = 'xxx.com' #---------------------------------------...
9f7f6dac97de67cc23c608b0d3d30ad8d5ef3c2f
momongaclub/japanese_rhyme_search
/search_rhyme.py
690
3.59375
4
from Class import Embeddings from Class import Vowel from Class import Search import argparse def parse(): parser = argparse.ArgumentParser() parser.add_argument('query_word', help='query word') parser.add_argument('embeddings', help='embeddings') parser.add_argument('vowel_dict', help='vowel_dict') ...
a9a6d17247788dff53d98942378d4ceeb9c83d2c
ThomasKundera/fedb
/code/python/divers/numerology.py
1,159
3.546875
4
#!/usr/bin/env python import sys name="excite".lower() #for c in name: #print (c+" "+str(ord(c)-ord('a')+1)) #sys.exit(0) def sumchar1(w): s=0 for c in w: s+=ord(c)-ord('a')+1 return s def sumchar0(w): s=0 for c in w: s+=ord(c)-ord('a') return s def revsumchar1(w): s=0 for c in w: s...
cc7abe19bda1f613b2d070d4a2c5ec4eb722107d
oojo12/algorithms
/sort/insertion_sort.py
612
4.34375
4
def insertion_sort(item, least = False): """Implementation of insertion sort""" """ Parameters: item - is assumed to be a list item least - if true returned order is least to greatest. Else it is greatest to least """ __author__ = "Femi" __version__ = "1" __status__ = "Done" ...
2068b0e51ee1d46c5d49a186a41e549dbd4d53a3
Ilya-Yavon/game
/game1_7.py
7,189
3.53125
4
import pygame from pygame import * import random #Характеристики персонажа SPEED = 7 WIDTH = 22 HEIGHT = 32 COLOR = "#00FFFF" JUMP_POWER = 10 GRAVITY = 0.5 #Характеристики платформ PLATFORM_WIDTH = 32 PLATFORM_HEIGHT = 32 PLATFORM_COLOR = "#858872" #Характеристики монет coin_width = 15 coin_hei...
238780e18aa4d804e2c1a07b4a7008719e4d1356
FaezehAHassani/python_exercises
/syntax_function4.py
781
4.25
4
# Functions for returning something # defining a few functions: def add(a, b): print(f"adding {a} + {b}") return a + b def subtract(a, b): print(f"subtracting {a} - {b}") return a - b def multiply(a, b): print(f"multiplying {a} * {b}") return a * b def divide(a, b): print(f"dividing {a} ...
6e0429ce27efefe33fb06345e3b51b55ff442e87
FaezehAHassani/python_exercises
/syntax_function.py
776
3.921875
4
# Functions # define a function named "print_two" that gets two arguments: "Zed", "Shaw" and returnts arg1: Zed, arg2: Shaw def print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") print_two("Zed", "Shaw") # define a function named "print_two_again" that gets two arguments: "Zed", "Shaw" a...
02e58d9216a199894663ee5996a606b08d82a155
FaezehAHassani/python_exercises
/syntax_argument4.py
550
3.625
4
# Reading seperate saved files from sys import argv script, filename = argv txt = open(filename) # open the file print(f"Here's your file {filename}:") print(txt.read()) # read and print the file content print(txt.close()) # it closed the file and returns None print("Type the filename again:") file_again = input(...
b7f9d36a46f860c345a15e2d07863ebc6515bc81
akarshh/Holmes
/GUI.py
3,445
3.53125
4
from tkinter import * from tkinter import filedialog from main import * class GUI: def __init__(self, root): self.win = root self.f1 = Frame(self.win) self.f1.pack(side = TOP) self.f2 = Frame(self.win) self.f2.pack(side = BOTTOM) self.image = PhotoImage(file = "h...
54bad82888355ea1afb712ec304e5b52b4dc34a5
Eragon-ZH/Data-Structure
/Harry Peter's Test.py
1,042
3.5625
4
''' https://pintia.cn/problem-sets/951072707007700992/problems/985411779057623040 ''' import copy # 找出最大值中最小的动物的编号 def minmax(D): a = [] for i in range(len(D)): maxnum = 0 for j in range(len(D)): if i!=j and D[i][j] > maxnum: maxnum = D[i][j] if maxnum == float('inf'): print(0) return a.append(m...
c9d867b70d57a5e6777b9132ca0b06e305864a6a
Eragon-ZH/Data-Structure
/Postorder to Preorder.py
1,318
4
4
''' https://pintia.cn/problem-sets/998409637106466816/problems/998409961867231274 PTA 数据结构2018春期末考试编程题,根据后序和中序遍历输出先序遍历 也可以不建树 ''' # 定义树类型 class Tree: def __init__(self,data,left,right): self.data = data self.left = left self.right = right # 获得输入 def getList(): K = eval(input()) post...
d2ad4f3b8b085537e75124e30fd324ebe616f16d
qcl/hundred-day-s-reform
/leetcode/138.py
1,189
3.609375
4
""" # Definition for a Node. class Node(object): def __init__(self, val, next, random): self.val = val self.next = next self.random = random """ class Solution(object): def copyRandomList(self, head): """ :type head: Node :rtype: Node """ if head =...
d5dd267d641f86a821308c1aec7d7f98a4bc56f8
mstepovanyy/checkio
/lesson8/task1/striped-words.py
991
3.96875
4
VOWELS = "AEIOUY" CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ" def checkio(text): count = 0 text = text.replace(',', ' ').replace('.', ' ') for word in text.split(): word = word.upper().strip('.,/?') if len(word) <= 1: continue if (set(word[::2]) <= set(VOWELS) and set(...
47dc919c3f9636955c761d5797ac3e28ca037ed0
mstepovanyy/checkio
/lesson8/task7/disposable-teleports.py
1,932
3.796875
4
def checkio(teleports_string): #return any route from 1 to 1 over all points routes = [item for item in teleports_string.split(',')] start_p = end_p = '1' visit = '' result = find_route(routes, visit, start_p, end_p) return result def find_route(routes, visit, start_p, end_p): for item in r...
8fb88cce473a54225301fe676770f87742156a30
mstepovanyy/checkio
/lesson7/task8/inside-block.py
2,237
3.640625
4
def area(a, b, c): x1, y1 = a x2, y2 = b x3, y3 = c return (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1) def intersect_position(x1, x2, x3, x4): if (x1 > x2): (x1, x2) = (x2, x1) if (x3 > x4): (x3, x4) = (x4, x3) return max(x1, x3) <= max(x2, x4) def intersect(a, b, c, d):...
35d51bca8331f3f109982860a55ac9b03a33c695
Elliotlank/quick_sort
/quick_sort.py
308
3.75
4
num_id = [1, 2, 3, 4, 5, 6, 7, 8, 9] print(num_id) while True: link_a = int(input("enter first numbers")) link_b = int(input("enter second numbers")) for i in range(len(num_id)): if num_id[i] == num_id[link_a]: num_id[i] = num_id[link_b] # asdad print(num_id)
367a8f3eaa33484459dcdda5923d1a401599823a
kamalnorizan/trainingmampu
/whileloop.py
191
3.90625
4
count = 0 #this is a while loop example """ This is an example of block comment for multiline comments """ while (count < 9) : print('The count is:'+str(count)) count+=1 print('End loop')
26d132929ff3944d3c1d24ed3e104da6f2fdd214
kamalnorizan/trainingmampu
/Car.py
302
3.578125
4
class Car: def __init__(self, brand, color, tyresCount, doorsCount): self.brand = brand self.color = color self.tyresCount = tyresCount self.doorsCount = doorsCount c1 = Car('Proton', 'Black', 4, 4) c2 = Car('Produa', 'Red', 4, 4) print(c1.brand) print(c2.color)
e7c802280dcd72e9accb4ac42e518ab9867b57fc
SukeshReddySpaceX/Hackerrank-SI
/right-angled-triangle.py
240
3.5
4
def rght(n): if (n==1): return print('*') for i in range(1,n+1,1): print((n-i) * ' ', end='') print(i * '*') m=int(input()) for i in range(m): n=int(input()) print("Case #"+str(i+1)+':') rght(n)
9a0494e31845de5b3e38b2e1aaf8cae045185634
vishnusak/DojoAssignments
/12-MAY-2016_Assignment/python/search.py
1,219
4.28125
4
# String.search # string.search(val) - search string for val (another string). Return index position of first match ( -1 if not found). # ---- Bonus: Implement regular expression support def search(string, val): val = str(val) #convert the to-be-searched string into a string type if (len(val) == 0): #if the...
ea4f181fd795b69f92fb4385f7fc9ecf00abee65
vishnusak/DojoAssignments
/3-MAY-2016_Assignment/python/reversearray.py
956
4.59375
5
# Reverse array # Given a numerical array, reverse the order of the values. The reversed array should have the same length, with existing elements moved to other indices so that the order of elements is reversed. Don't use a second array - move the values around within the array that you are given. # steps: # 1. find...
f2b26fd53f47da94ea9b3c51ff3e6e2670a2eafe
vishnusak/DojoAssignments
/20-MAY-2016_Assignment/Python/SingleLL.py
11,404
4.1875
4
# Single Linked List using classes class Node(object): """ Class for creating a node object. This will have just two attributes: data and next. This will not have any methods """ def __init__(self, data): self.data = data self.next = None class SLL(object): """ Class f...
a5cd1515a6bb28d716cff6124b9bdaeb37c413ca
vishnusak/DojoAssignments
/Python-RadixSort/radixsort.py
7,134
4.1875
4
# radix sort works on integers only # It is non-comparative (no comparisons between elements of the list are done) and NOT in-place # It works if range of integers in the list is known upfront. Otherwise it will go into an infinite loop # Radix sort: (assume list has numbers from 0 to 10000 only. so max = 10000) # 1 -...
e863c4cf8ce0e3ee3f45f004f7e370255ad5d3b8
vishnusak/DojoAssignments
/Flask-Login_Registration/MySQLConnect.py
1,413
3.5
4
import MySQLdb as ms class Sql(object): """ Sql: Class to provide an abstraction for connecting and querying against MySQL server """ def __init__(self, host, db, user='root', pwd='1979', port=3306): self.host = host self.user = user self.pwd = pwd self.db = db self.port...
0296ddc0d579edc89013f4034af9b0b0b6aec661
vishnusak/DojoAssignments
/2-MAY-2016_Assignment/python/swap.py
759
4.53125
5
# Swap Array Pairs # Swap positions of successive pairs of values of given array. If length is odd, do not change final element. For [1,2,3,4] , return [2,1,4,3] . For [false,true,42] , return [true,false,42] . # steps: # 1 - traverse array in for loop # 2 - increment counter by 2 each time instead of one # 3 - fo...
f9d1fb27c3ced358419cad969dba71e8f1d56a75
helderthh/leetcode
/medium/implement-trie-prefix-tree.py
1,836
4.15625
4
# 208. Implement Trie (Prefix Tree) # https://leetcode.com/problems/implement-trie-prefix-tree/ class Trie: def __init__(self, val=""): """ Initialize your data structure here. """ self.val = val self.children = [] def insert(self, word: str) -> None: ...
f7d24dfefa009b8ef30e9f2dcb7906430ae8c0ff
helderthh/leetcode
/medium/palindrome-partitioning.py
947
3.75
4
# 131. Palindrome Partitioning # https://leetcode.com/problems/palindrome-partitioning/ class Solution: def partition(self, s: str) -> List[List[str]]: self.memo = {} self.orig = len(s) return self._partition(s) def _partition(self, s, i=0): if i in self.memo...
d30d9e56aa36b68344225dd5dd23738ddfeed5a8
helderthh/leetcode
/medium/number-of-islands.py
2,189
3.578125
4
# 200. Number of Islands # https://leetcode.com/problems/number-of-islands/ class Solution: def __init__(self): self.visited = [] self.count = 0 def numIslands(self, grid: List[List[str]]) -> int: if not grid: return 0 self.visited = [] self.co...
ee46754162cbf61499c4025981689a1524e483df
Chagall/dutch-eng-dictionary
/Procedural Implementation (old)/dicFunctions.py
3,463
4.46875
4
import os import sqlite3 # Function Name : Create Dictionary Table # Parameters: # 1 - cursor : A cursor to the database connection to provide the means to alter it # Return: None # What it does: Creates the Dictionary Table if it does not exist def createDicTable(cursor): cursor.execute('CREATE TABLE IF NOT EXISTS ...
5fb8205cfde46a2f916aa9e72ecbfdeabc82d30a
benchada/Virtual_Box_All
/Documents/WordsChain.py
640
3.609375
4
import re f =open('list of words py.txt') words =f.readlines() f.close() def get_chain(word,Alist,chain): sorted_word ="".join(sorted(word)) #Sorting the letters within one word #Initializing the list of chained words #Itterating through the elements of the array for x in Alist: sorted_x ="".join(sorted(x)) ...
941f576fa4931fc669114030bdbc0621c1c22ff2
abhishek-kumar-agrawal/introduction-to-computation-and-programming-john-guttag-book-homework
/2-4 input ten numbers and return the largest odd number entered.py
669
4.09375
4
##Finger exercise: Write a program that asks the user to input 10 integers, and ##then prints the largest odd number that was entered. If no odd number was ##entered, it should print a message to that effect. x=[] y=[] for i in range(10): i=i+1 num=int(raw_input('introduzca el '+str(i)+'avo nu...
71d32b512305598371a3e034ef6471fbf4331f3b
narmadakrishnasamy/Udacity-Bikeshare-python
/bikeshare_2.py
14,524
4.28125
4
import time import pandas as pd import numpy as np from datetime import datetime from pprint import pprint CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTHS = {'january': 1, 'february': 2, 'march': 3, 'april': 4, 'may':5, '...
f4b95276c01084a6679d6b98db32130381d5459b
KodaiEzaki/Kodai
/ABC141A.py
253
3.921875
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 22 21:46:43 2020 @author: Kodai """ Weather = input() if Weather == 'Sunny': print('Cloudy') elif Weather == 'Cloudy': print('Rainy') elif Weather == 'Rainy': print('Sunny')
e4e84ae228671781e613c993b2330bee2560b4e7
KodaiEzaki/Kodai
/ABC148B.py
299
3.765625
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 9 16:41:09 2020 @author: TANAKA """ N = int(input()) S, T = input().split() list_S = list(S) list_T = list(T) list_NEW =[] for i in range(N): list_NEW.append(list_S[i]) list_NEW.append(list_T[i]) print(''.join(list_NEW))
d034e3b19d0c39446e75186522bfbf4d11075754
KodaiEzaki/Kodai
/ABC142B.py
327
3.515625
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 22 21:36:10 2020 @author: Kodai """ N, K = map(int, input().split()) height_list = list(map(int, input().split())) len_height_list = len(height_list) count = 0 for i in range(len_height_list): if height_list[i] >= K: count += 1 print...
6b580655a24351b85b8502d1a581f1ebc16f66a2
KodaiEzaki/Kodai
/ABC139A.py
217
3.6875
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 1 16:16:46 2020 @author: Kodai """ S = input() T = input() count = 0 for i in range(3): if S[i] == T[i]: count += 1 print(count)
4b36eb6836a7f9611c8c3c800079ae7933058952
roogla/poetic_pumas
/src/game/vector2D.py
4,361
4.0625
4
from __future__ import annotations from typing import Union Numerics = Union[float, int] class Vector2D: """2 Dimensional vector math class. Implements vector operations.""" def __init__(self, x: Numerics = 0, y: Numerics = 0): self.x: Numerics = x self.y: Numerics = y def __repr__(sel...
e6e53d8b520c8e12307e36242db08f4eb9f14c9d
okeks/Web_scraping_imdb
/Web Scraping IMBD 27th April 2020.py
1,606
3.59375
4
#!/usr/bin/env python # coding: utf-8 # ### Description # #### I'll create a movie picker that will crawl the imdb Top charts website and will randomly select a movie for you. Showing the movie title,name of the actor, Genre # #### Function that sends requests # In[44]: import random import pandas as pd import...
e477234aa60b9457645b7c5357aa635f03eb8e46
oliveiralenon/Learning_python
/Mundo 1/Desafios/025.py
264
4
4
""" Crie um programa que leia o nome de uma pessoa e diga se ela tem "SILVA" no nome. """ nome = str(input('Digite seu nome completo: ')).strip() split = nome.split() silva = 'Silva' in nome[0:].title() print(f'No nome {nome}, existe o sobrenome Silva? {silva} ')
8c0cfb67efbdd2cd0de9ac159c7284bd4d42be8c
oliveiralenon/Learning_python
/Mundo 1/Desafios/011.py
464
4
4
"""Faça um programa que leia a largura e a altura de uma parede em metros, calcule sua área e a quantidade de tinta necessária para pintá-la, sendo que cada litro de tinta pinta uma área de 2m²""" altura = float(input('Digite a altura da parede em metros: ')) largura = float(input('Digite a largura da parede em metros...
df24fa24226e0983bf510c2d92b21ff518ed1d2e
oliveiralenon/Learning_python
/Mundo 2/Desafios/046.py
328
3.5625
4
""" Faça um programa que mostre na tela uma contagem regressiva para o estouro de fogos de artifício, indo de 10 até 0, com uma pausa de 1 segundo entre eles. """ from time import sleep import emojis print('Contagem regressiva!!') for i in range(10, 0, -1): print(i) sleep(1) print(emojis.encode(':fireworks:' * ...
6ce3eb995744c1f9fc25b7761516cb3a29b131f8
oliveiralenon/Learning_python
/Mundo 2/Desafios/051.py
350
4
4
""" Desenvolva um programa que leia o primeiro termo e a razão de uma PA. No final, mostre os 10 primeiros termos dessa progressão. """ x = int(input('Escolha o primeiro termo da PA: ')) y = int(input('Escolha a razão da PA: ')) print('Progressão aritmética:') for i in range(0, 10): pa = x + (i * y) print(pa, ...
36a12c15deb0ce9f253457b390b43a6fc5ec5708
oliveiralenon/Learning_python
/Mundo 3/Desafios/081.py
772
4.03125
4
""" Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, mostre: a) quantos números foram digitados. b) A lista de valores, ordenada de forma decrescente. c) Se o valor 5 foi digitado e está ou não na lista, """ lista = [] while True: lista.append(int(input('Digite um número: '))) c...
9043e7b4e966797c20d293d674767f63b9d1af56
oliveiralenon/Learning_python
/Mundo 2/Desafios/071.py
836
4.25
4
""" Crie um programa que simule o funcionamento de um caixa eletrônico. No início, pergunte ao usuário qual será o valor a ser sacado (número inteiro) e o programa vai informar quantas cédulas de cada valor serão entregues. OBS: Considere que o caixa possui cédulas de RS50, R$20, R$10 e R$1. """ print('-=' * 20) print...
80964e8df8f8b7036736dbff1309f6478dedd805
oliveiralenon/Learning_python
/Mundo 2/Desafios/036.py
777
4.21875
4
""" Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. O programa vai perguntar o valor da casa, o salário do comprador e em quantos anos ele vai pagar. Calcule o valor da prestação mensal, sabendo que ela não pode exceder 30% do salário ou então o empréstimo será negado. """ valor_casa =...
047fb88ee80ddc5830ed77a99078812c58555e6a
oliveiralenon/Learning_python
/Mundo 1/Desafios/022.py
568
4.28125
4
""" Crie um progrma que leia o nome completo de uma pessoa e mostre: - O nome com todas as letras maiúsculas - O nome com todas minúsculos - Quantas letras ao todo (sem considerar espaços) = Quantas letras tem o primeiro nome. """ nome = str(input('Digite seu nome completo: ')) separado = nome.split() print(f'Seu nome ...
95d7346e60cb3ce345416da12bbe95cfb2bdf2ab
oliveiralenon/Learning_python
/Mundo 1/Desafios/028.py
700
4.25
4
""" Escreva um programa que faça o computador "pensar" em um número inteiro entre 0 e 5 e faça para o usuário tentar descobrir qual foi o número escolhido pelo computador. O programa deverá escrever na tela se o usuário venceu ou perdeu. """ from random import randint from time import sleep print('-=-' * 20) print('Vo...
11520885ca71df1b25939fb0bd6cf97dd313cb51
oliveiralenon/Learning_python
/Mundo 2/Desafios/040.py
537
3.828125
4
""" Crie um programa que leia duas notas de um aluno e calcule sua média, mostrando uma mensagem no final, de acordo com a média atingida: - Média abaixo de 5.0: REPROVADO - Média entre 5.0 e 6.9: RECUPERAÇÃO - Média 7.0 ou superior: Aprovado """ n1 = float(input('Digite a primeira nota: ')) n2 = float(input('Digite a...
965c0e4fc89e3e6557c57edddc242c207e31c496
oliveiralenon/Learning_python
/Mundo 3/Aulas/aula16.py
1,968
3.84375
4
""" Aula 16: Tuplas - Variáveis compostas len(lanche) = mostra quantos elementos tem dentro da variável lanche --------------------------- tipos de variáveis compostas: lanche = (tupla) [lista] {dicionário} ---------------------------- Tuplas são imutáveis, não é possível modificar espaços posteriormente lanche = (...
afb764b85f9036971b6784c22a52381ec93daba1
TimeTeleporter/computersimulation
/particle.py
1,682
3.640625
4
import numpy as np from vectors import magnitude, normalize, combilize class Particle(): """Models the behaviour of a particle.""" def __init__(self, position, speed, direction, mass, radius): self.position = position self.speed = speed self.direction = direction self.mass = mas...
e94a797e148c9eb0257ebb05d351b6ea58b475dd
jaivar15/CITS1401-Computational-Thinking-to-Python
/Labs/lab04.py
11,348
4.15625
4
#Question 2: Write a function find_word(sentence, word) that takes 'sentence' (a string) and 'word' (another string) as parameters # and returns the index of the first occurrence of 'word' in 'sentence'. As with the previous question, 'word' in this case can be any string, # it is not necessarily a standalone English...
e93530e2a0c1b094357ebeb2f6d9035751f71da1
yknnnnft/PythonStudy
/start.py
7,483
3.90625
4
import pdb; import math; import random; import string; import time; import calendar; import re; import os; #startup print("EXERCISE FOR: ", "startup"); str = 'Hello World!'; print(str); print(str[0]); print(str[2:5]); print(str[2:]); print(str * 2); print(str + "TEST"); print(); # list print("EXERCISE FOR: ", "list"...
6131142a290d352450528c93ab6796eb2f423536
sarastrasner/daily-code-challenges
/python/code_challenges/strings/buddy_strings/buddy_strings.py
511
3.5
4
def buddyStrings(A, B): if A == B: if len(A) > len(set(A)): return True if len(A) != len(B): return False if len(A) < 2 or len(B) < 2: return False res = [] for i in range(len(A)): if A[i] != B[i]: res.append(i) if len(res) == 0: re...
eb70962bebeb111fee481d9cdf4282d1e0ac8016
almog20-meet/YL1-201819
/lab7-part2.py
1,209
3.921875
4
# #problem 6 # class Bear(): # def __init__(self, name): # self.name = name # print("A new bear created. Its name is: " + self.name) # def say_hi(self, name): # self.name = name # print("Hi! Im a bear. My name is " + self.name) # my_bear = Bear("Danny") # print(my_bear.say_hi("Bar")) """ #problem 7 ball...
1d389d3540db4eb898ddc28e5f08ae60b1d15c64
peterpaints/peter-musonye-bc17-week-1
/day_3/cli/cli.py
1,743
3.6875
4
# -*- coding: utf-8 -*- import requests import click @click.command() @click.option('--city', prompt='Which city are you in?', help='The city you are currently in.') @click.option('--country', prompt='Which country?', help='The country your city is in.') def weather(city, country): """...
6900a62edc6b20af692c8744e52f2d08e863003b
rajatmehta1/vapor
/sentiment_analysis/utils.py
327
3.75
4
from nltk.tokenize import RegexpTokenizer def normalize( tweet ): """ lowercases, tokenizes and removes @ mentions """ tokenizer = RegexpTokenizer( r'\w+' ) tweet_tokenized = tokenizer.tokenize( tweet.lower() ) return [ word for word in tweet_tokenized if ( ( len( word ) > 1 ) and ('@' not in wor...
6b01c2cace8c5372576e081dfc29e1a34dca4521
emanuelmamani22/parecido
/parecido.py
1,950
3.75
4
import sys def letras (a,k): y=False for f in a : if y == True : break cont=0 cont2=0 p1=0 p2=0 contl=0 if k != f : b=f c=len(b) while cont < c : if k[cont] == b[cont2] : ...
ff046bed9c92c25ebc44c44c6f4b47366e3c7358
phanigenin/Interviews
/perm.py
726
3.78125
4
# Permutations of string def tostring(l): return ''.join(l) def permute(inputl,start,end,res=[]): if start==end: res.append(tostring(inputl)) else: for i in range(start,end+1): inputl[start],inputl[i] = inputl[i],inputl[start] permute(inputl,start+1,end...
4c6774ab89df5e438fdc23ac42a872760d1f4bf3
guillearch/ScriptsDump
/Automation/src/find-and-replace/find_and_replace.py
1,481
4.0625
4
# Finds and replaces a given string in all the files of a given path. import os def input_find(): print('String you want to replace: ') find = input() return find def input_replace(): print('String you want to replace it with: ') replace = input() return replace def input_source(): print...
af4caae1454e7fdb4b40d5192c45e7ca16783ff2
juancadh/mycode
/collatz_conjecture.py
1,118
4.59375
5
""" ======== COLLATZ CONJECTURE ======== The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half the previous term. If the...
51a31074343176c06138c2174823454ddff0dab9
tds54/vending_machine
/edit3.py
1,905
3.84375
4
import sqlite3 dbname = 'item_menu.db' conn = sqlite3.connect(dbname) cur = conn.cursor() item_price = cur.execute('select name, price from item_menus') item_price = dict(item_price) item_count = cur.execute('select name, count from item_menus') item_count = dict(item_count) class Edit: def edit(self): ...
c82d0514f54c9d1bd84655bac3ecbe6604780139
rachione/picoctf2019-scripts
/rsa-pop-quiz/main.py
1,615
3.71875
4
def multiplicative_inverse(a, b): """Returns a tuple (r, i, j) such that r = gcd(a, b) = ia + jb """ # r = gcd(a,b) i = multiplicitive inverse of a mod b # or j = multiplicitive inverse of b mod a # Neg return values for i or j are made positive mod b or a respectively # Iterateive Ver...
aaeb17270f7ccc8161cb4063e2d20fc384b1d8d8
rachione/picoctf2019-scripts
/rockstar/output.py
293
3.921875
4
your_heart = " bottles of beer on the wall" your_soul = " bottles of beer" Carol = "Take one down, pass it around" the_beers = 99 while the_beers != False: print(the_beers + your_heart) print(the_beers + your_soul) print(Carol) the_beers -= 1 print(the_beers + your_heart)
1890dfb55eb3fe77ec6ac573b0785dfe747caf5e
leticiaferraz/pythoncodes
/Bhaskara.py
912
3.9375
4
a=float(input("Leia A: ")) b=float(input("Leia B: ")) c=float(input("Leia C: ")) delta=(b**2)-(4*a*c) import math if delta<0: print("Delta menor que zero. Não há raizes reais nesta equação.") else: if delta==0: x= (-b+delta) / (2*a) print ("Único resultado: ", x) if delta>0: x1= (-b + math....
7e225e4e770e9e8d8fa2b87f59c1a9d97ee38ce0
zywvvd/Python_Practise
/Python sqlite3/sqlite3_test.py
1,213
3.703125
4
import sqlite3 if __name__ == '__main__': # 创建 / 加载硬盘数据库链接 conn = sqlite3.connect('test.db') # 内存数据库 # conn = sqlite3.connect(':memory:') #创建一个游标 cursor cur = conn.cursor() # 建表的sql语句 sql_text_1 = '''CREATE TABLE scores (姓名 TEXT, 班级 TEXT, ...
5cdf7a1d3b55d89bbce3183ffad615ff193a1c2b
kiyoxi2020/leetcode
/code/leetcode-206.py
625
3.671875
4
''' leetcode 206. 反转链表 给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。 ''' # Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def reverseList(self, head): """ :type h...
758171f09b3a902f93cbaa9832f86113bbbb1349
kiyoxi2020/leetcode
/code/leetcode-21.py
1,175
3.796875
4
''' leetcode 21. 合并两个有序链表 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 ''' # Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution(object): def mergeTwoLists(self, l1, l2): ...
8c8bb577de74952028257cdd4fe2dd252aa57ef4
kiyoxi2020/leetcode
/code/leetcode-208.py
2,568
4.0625
4
''' leetcode 208. 实现 Trie (前缀树) Trie(发音类似 "try")或者说 前缀树 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补完和拼写检查。 请你实现 Trie 类: Trie() 初始化前缀树对象。 void insert(String word) 向前缀树中插入字符串 word 。 boolean search(String word) 如果字符串 word 在前缀树中,返回 true(即,在检索之前已经插入);否则,返回 false 。 boolean startsWith(String prefix) 如果之前已...
9e93937f588e619e9be88a870a1f8f882eea7602
kiyoxi2020/leetcode
/code/leetcode-303.py
1,396
3.546875
4
''' leetcode 303. 区域和检索 - 数组不可变 给定一个整数数组  nums,求出数组从索引 i 到 j(i ≤ j)范围内元素的总和,包含 i、j 两点。 实现 NumArray 类: NumArray(int[] nums) 使用数组 nums 初始化对象 int sumRange(int i, int j) 返回数组 nums 从索引 i 到 j(i ≤ j)范围内元素的总和,包含 i、j 两点(也就是 sum(nums[i], nums[i + 1], ... , nums[j])) 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/probl...
b07ae189a459384f8e7e686478c9d75eef233768
aadilkhhan/Advance-Python-2
/05-map.py
182
3.90625
4
def square(num): return num*num l = [12 , 2 , 3 ] #Method 1 l2 = [] for item in l: l2.append(square(item)) print(l2) #Method 2 print(list(map(square , l)))
42c3588e02505be7f28c1993f1be9b2ad5385995
jeonjunmin/python_basic
/ch2.py
1,891
4.0625
4
#1.자료형 변환 print('#################### 1.자료형 변환 ###################') my_int = 1 print(type(my_int)) print(my_int) print(type(float(my_int))) #정수형 -> 실수형 변환 print(float(my_int)) print(type(str(my_int))) #정수형 -> 문자형 형변환 print(str(my_int)) my_str='coding' #문자형 -> 리스트 형변환 my_list = list(my_str) print(my_list) #2.문자...
5760dbab1b239b32b1dfe7413be2bc5946afa6b3
ywluohao/cses
/i_Repetitions.py
316
3.53125
4
s = input() max_count = 1 pointer1 = 0 pointer2 = 1 while pointer1 + pointer2 < len(s): if s[pointer1 + pointer2] == s[pointer1]: pointer2 += 1 else: max_count = max(max_count, pointer2) pointer1 += pointer2 pointer2 = 1 max_count = max(max_count, pointer2) print(max_count)
d9df5bad0d86c01fdd29613c27b1fc46fcee2112
FrancoisGautrais/myPL
/number/builtin.py
518
3.5
4
#!/usr/bin/python3 import time class Array(list): def __init__(self): list.__init__(self) def length(self): return self.__len__() def at(self, n): return self[n] def contains(self, n): return n in self def set(self, n, val): self[n] = val return val BUILTIN={ ...
4912da10c8bd2b4e243055ccc17c45d10dfbadb9
RotemBH/first_project
/leetcode_exe/arrays_and_list/two_sum.py
796
3.875
4
"""Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.""" class Solution: """ explanation: loop over the array, check if the value in some cache (seen). if it is- we saw it diff from target so return the value in the cache -it is the di...
12ca2651bcb1826220cd2dd14be98f2f3d92489f
jasonseto/Kelburn_Repository
/Teradata/SparkClass_NoData/exercises/Spark-In-Python/03-pyspark-transformations-program.py
350
3.859375
4
## Compute all the squares and sum all the values provided fib = sc.parallelize([1, 2, 3, 5, 8, 13, 21, 34]) def square(x): return x * x def divisible(x): return (x % 3 == 0) ## First using named functions fib.map(square).filter(divisible).collect() ## Now use functional literals fib.map(lambda x: x*x).filter(lambd...
29a65033138af3800d2dfd07a207ef276e286bb4
Varun-M11/CoinChange-Problem
/MinCoinsReq.py
767
3.59375
4
# Function to find out minimum numbers of coins required to make # the change for the amount. def find_min_coins(coins, amount, numOfCoins, minNumCoins, usedCoins): minNumCoins[0] = 0 for i in range(1, amount+1): minNumCoins[i] = 99999 for i in range(1, amount+1): for j in range...
40efa43a24d9bb125414aa5cd0dac713b37fd13e
vishnupsingh523/pictorial-tkinter
/tkinter6.py
1,146
3.734375
4
# Making the login form sample here from tkinter import * root = Tk() root.geometry("600x500") root.title("Student Login") # using frame where all the other elements will lie mainFrame = Frame(bd = 2, bg = "grey") mainFrame.pack(pady= 100) loginTop = Label(mainFrame, text = "LogIn",bg="navy",fg="white", fon...
61ed165d22712d387933cfb75483d3423c1ede76
vkaravapalli/Selenium
/Python/ifelse.py
255
4.0625
4
a = "chandu" b = "chaitu" if a =="chandu": print("Entered into next loop") if b =="chait": print("The value of b is true") else: print("The value of b is false") else: print("The value of a is false")
d542b4aa9d6c28c525fd1538002906002918c266
harsh-98/Minecraft
/player.py
1,792
3.609375
4
import pyglet class Player: def __init__(self,batch): # When flying var_.GRAVITY has no effect and speed is increased. self.flying = False self.power_time=0 # Strafing is moving lateral to the direction you are facing, # e.g. moving to the left or right while continuing to f...