blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e9c4e146a61bdb24c45afa51037279dd3d8db952
dm3dm3/dm3_hwt
/Py-1-lesson2-hw/py1_l2_norm3.py
773
4.125
4
# coding : utf-8 # PEP-8 # Python-1-lesson2-normal Task 3 import time import datetime import random rlist = [] inpn = input('Enter count of elements in list:') inpint=int(inpn) for _ in range(inpint): rlist.append(random.randint(-100, 100)) print(f'Output of randomize:\n\t {rlist}') ##############################...
fd9c62fa096e42dbc56ff1ca7f016dbe55a08f7e
vsdrun/lc_public
/depth-first-search/529_Minesweeper.py
3,190
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ https://leetcode.com/problems/minesweeper/ """ class Solution(object): def updateBoard(self, board, click): """ :type board: List[List[str]] :type click: List[int] :rtype: List[List[str]] dfs 1. if 1~8, show 1~8 and...
27aa805d441aea6d87bb0e29ddec9e70cc451888
LiliaSkaletska/amis_python71
/km71/Skaletska_Liliia/3/task1.py
632
4.3125
4
""" Умова: Напишіть програму, яка отримує три числа і друкує їх суму. Кожне число користувач вводить у окремому рядку. Вхідні дані: 3 дійсних числа. Кожне число користувач вводить в окремому рядку. Вихідні дані: вивести суму трьох чисел на екран. """ number1 = float (input("put a number:")) number2 = floa...
007991bbc3a58fee620944d3d23ec6ec6a1a483b
afcarl/MachineTranslation
/langaugemodel/file_ops.py
398
3.703125
4
import collections def read_trigrams(filename): file = open(filename, "r") words = dict() for line in file: items = line.split() words[items[0].strip()] = int(items[1].strip()) vocab = collections.Counter(words) return vocab def write_trigrams(trigrams,filename): with open(filename,"w") as f: for key...
d5a5596c34a75d0a041259f85ee04cb7e7bf5c81
jdht1992/PythonScript
/class/class3.py
678
4.03125
4
class Point: #“The self argument to a method is a reference to the object that the method is being invoked on. We can access attributes and methods of that object as if it were any another object. This is exactly what we do inside the reset method when we set the x and y attributes of the self object.” def reset(se...
cedb25a9dd5d5a314ebfec39ac867802bc28d68c
prashantpandey9/create-your-own-what-you-want
/python/calculator.py
244
3.6875
4
n1= input("Enter a no.: ") n2= input("Enter a no.: ") x= int(n1) y= int(n2) a1= input("Enter a choice :") a= int(a1) if a==1: print(x+y) elif a==2: print(x-y) elif a==3: print(x*y) elif a==4: print(x/y) elif a==5: print(x%y)
9d5a8ccf35acc9e5530f7f4986bf7df4fdc79071
DELPiSHO/Spell-corrector
/spellChecker.py
195
3.609375
4
from spellchecker import SpellChecker spell = SpellChecker() print(spell.correction('hellou')) sentence = spell.split_words("Howw are theyi?") print([spell.correction(word) for word in sentence])
3d432cb8db9bc62c3378da6aca14c5f230df90d4
jsundahl/220-project-4
/immdict.py
879
3.5
4
import copy from functools import * class ImmDict: def __init__(self, d=None): if d is None: self.d = {} else: self.d = d def put(self, key, value): return ImmDict({**self.d, **{key: value}}) def get(self, key): try: return copy.deepcop...
9635ca3d1ca193ea8d3c345d570c1dfd6b8fee53
JLew15/Python
/verificationfunction.py
516
4.15625
4
import datetime def getVerifiedInteger(message, low, high): var = 0 while not low <= var <= high: var = int(input(message)) if var >= high + 1 or var <= low - 1: print("Try again...") return var month = getVerifiedInteger("Please enter today's month ", 1, 12) day = getVerifie...
e8bf955a188709b95432a7f200a98aebe490d1c4
JennyShalai/rusty-calculator
/rusty-calculator.py
2,110
4.28125
4
def answer(str): # store output result here output = "" # valid chars can be in equation numbers = "0123456789" operations = "+*" # counters to hold operations as "+" and "*" counter_for_pluses = 0 counter_for_multipliers = 0 # check validity of input equation if len(str) ...
80682a1ff947f4330d89e6578b3c004ceb247b1f
chc1129/python_jisen
/04/valueBuiltType.py
284
3.703125
4
a = 1 # 数値リテラルを使う場合 print(a) 1_000_000 # _を使うと見やすくかける print( 1_000_000 ) a = int(1) print(a) float(a) # int型の値からfloat型の値を作成 print( float(a) ) complex(a) # int型の値からcomplex型を作成 print( complex(a) )
f805d2ca5f00f0aabc346b72368c831b4df0cad9
LloydNicholson/fun-py-projects
/guessing_game.py
1,290
4.15625
4
import random # randomise the list def shuffle_list(): digits = list(range(10)) random.shuffle(digits) return digits[:3] # get player input def player_input(): return input('Guess the 3 digit number: ') # check player input is correct or not def is_correct(guess_numbers, shuffled_nums_list): c...
5594d5430298bac35532b53fc61f3ea445b1aa01
ThaisaAndrade2/curso-em-video-python
/exercicios/ex09a.py
268
3.921875
4
#n1 = int(input("Digite um número: ")) #c = 0 #while c <= 10: #tab = n1 * c #print("{} X {} = {}".format(n1, c, tab)) #c += 1 n1 = int(input("Digite um número: ")) for x in range(11): resul = n1 * x print(" {} X {} = {}".format(n1, x, resul))
d3e24392b447c576508044a1ab4c154434ccf197
monqeth18-meet/meet201617YL1cs-mod4
/square.py
862
3.875
4
from rectangle import Rectangle class Square(Rectangle): def __init__(self, length): super(Square, self).__init__(length,length) def set_length(self,new_length): if new_length>=0 : self.length=new_length if self.has_been_drawn : self.draw_shape() ...
50163173056d62077024fefcd3f2492a3dd1c66b
DoctorSad/_Course
/Lesson_10/_7_inheritance_1.py
734
4.09375
4
""" Реулизуем класс, наследуясь от int дополнить его методом проверки простоты числа вместо CustomInt класс можно назвать int, но таким образом мы переопределим стандартный класс """ class CustomInt(int): def is_prime(self): if self < 2: return False elif self == 2: ...
c920dc42f3546ee3f28b90c5a8781252ebab9eae
souzaluuk/CG-2019.2
/utils.py
730
3.765625
4
import datetime as dt import statistics as st import math def quartis(values): meio = len(values)//2 Q1 = st.median(values[:meio]) Q2 = st.median(values) Q3 = st.median(values[meio:]) # print('Quartis:') # print('Q1:',Q1) # print('Q2:',Q2) # print('Q3:',Q3) return [Q1,Q2,Q3] ...
404ed8cc45c4cc0aaf81df6532151ad73b508b9c
codingscode/Teste_Python
/01/teste028.py
664
3.609375
4
dias_semana = ['domingo', 'segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado'] print(dias_semana) print(dias_semana[-1]) print(dias_semana[-2]) print(dias_semana[1:5]) print('------------------------') cores1 = ('verde', 'azul', 'branco') cores2 = ('roxo', 'laranja') cores = cores1 + cores2 print(cores1) pri...
84db7aec84ceb1304cf8459fa55c3ef98ebf9023
persocom01/TestAnaconda
/numpy/01a_np_ndarray_test2.py
4,625
4.71875
5
# Demonstrates ways to generate an ndarray without an input. import numpy as np # np.empty(shape, dtype=float, order='C') creates an ndarray with random values # of the specified shape and dtype. # shape=[rows, columns] or int, where int is the length of the array. # To create an empty array with each row being a 2d m...
e73613f322ef8ffa18061342929d6ddf945ad466
revanks/Data-Structures-and-Algorithms-Interview-Questions-for-Practice
/find_numbers_with_even_number_of_digits.py
185
3.609375
4
a = [12,345,2,6,7896] def even_digits(array): counts = 0 for num in array: result = len(str(num)) if result%2 == 0: counts += 1 return counts ans = even_digits(a) print(ans)
d0668e55f5f3f8abf0ef3320a8301ab65781c223
YJL33/LeetCode
/current_session/python/26.py
414
3.5
4
from typing import List class Solution: def removeDuplicates(self, A: List[int]) -> int: # 1st pass: count k # 2nd pass: craft the array # by observation: we can combine above into one if not A: return k, tail = 1, A[0] for a in A[1:]: if a != tai...
5c57023f9d6333f3bb8ba0de27cb0144197d3042
Shishir-rmv/oreilly_math_fundamentals_data_science
/statistics_hypothesis_testing/09_standard_normal_z_score.py
362
3.6875
4
def z_score(x, mean, std): return (x - mean) / std def z_to_x(z, mean, std): return (z * std) + mean mean = 6.0 std_dev = 1.0 x = 8.0 # Convert to Z-score and then back to X z = z_score(x, mean, std_dev) back_to_x = z_to_x(z, mean, std_dev) print("Z-Score: {}".format(z)) # Z-Score: 2.0 print("Back to X:...
bf198cd592afcfc80221986cae350f089417a273
shantanu609/Trees-4
/Problem3.py
2,640
3.734375
4
# Time Complexity : O(n) # Space Complexity :O(n) # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : No # Your code here along with comments explaining your approach class Node: def __init__(self,x): self.val = x self.left = None self.right = No...
0883496937a092aec7cd48c70c1ccfb618568f60
bcimring/Pong-Game
/Pong_main.py
18,782
3.671875
4
################################ # Name: Barry Cimring # Date: 15/5/2019 # Description: The game of pong ################################ import pygame import time import math as m from random import randint pygame.init() WIDTH = 1000 HEIGHT = 750 game_window = pygame.display.set_mode((WIDTH,HEIGHT)...
67a03fb52352433dfbd45308b09c9f9a2d93ceca
gavrie/pycourse
/examples/log_broken.py
568
3.703125
4
def log_func(func): counter = 0 def wrapped_func(*args): counter = counter + 1 print ">>> Enter {}{} (count: {})".format( func.__name__, args, counter) result = func(*args) print "<<< Exit {} [return: {}]".format( func.__name__, result) pri...
ee524d01ce05d5892a0e801be80544d13be77802
pranavgarg/algorithms
/interview/max_chain_dominos.py
1,259
3.5
4
import random; class Domino: def __init__(self, left, right): self.left = left self.right = right def __repr__(self): return "[{}|{}]".format(self.left, self.right) def get_random(): return random.randint(1,6), random.randint(1,6) def generate_dominos(no): dominos = [] f...
96a406695f6c90e24a8e2640fcf492fece5d25cb
steve-77/Learning_Python
/Scripts/test2.py
390
4.34375
4
# sort strings in a list, case insensitive import string wordList = ['Python', 'is', 'really', 'great', 'stuff'] print "Original list:" print wordList wordList.sort() print "After standard sort (ASCII upper case is before lower case):" print wordList wordList.sort(lambda x, y: cmp(string.lower(x), string.lower(y))) pri...
c45024af81048135c0a158fe226e97802ce66c79
luuketi/project_euler
/191.py
381
3.515625
4
# Project Euler # Problem 191 - 35% #Tribonacci numbers #0, 0, 1, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927, 1705, 3136, 5768, ... serie=[0,0,1] def trib(n): if n > len(serie)-1: serie.append( trib(n-1) + trib(n-2) + trib(n-3) ) return serie[n] def calc(n): return sum( [ trib(i-1+3) * trib(n-...
fd73e317088a6679182e426d3e1950d302e2e20c
sancho-mgn/sports_programming
/BalancedParentheses.py
545
3.609375
4
def generate_parentheses(out, open_parenthes, close_parenthes, N, result): if open_parenthes == N and close_parenthes == N: result.append(out) else: if open_parenthes < N: generate_parentheses(out + '(', open_parenthes + 1, close_parenthes, N, result) if close_parenthes...
279af18f10f22874251cbc3386c3fb83d27d107e
lgdelacruz92/LeetCode-Challenges
/bst/bst.py
2,534
3.6875
4
class BST: def __init__(self, v): self.left = None self.right = None self.v = v def printBST(root, level): item = '' for i in range(level): item += '.' if root == None: item += 'null' print(item) return else: item += '{v}'.format(v=ro...
b2610269631403742fd95c688702b15fec3716cf
gatherheart/Solved_PS
/KAKAO/2018_KAKAO_6.py
2,094
3.53125
4
import re HOUR_TO_MS = 60 * 60 * 1000 MINUTE_TO_MS = 60 * 1000 S_TO_MS = 1000 def convert_time(hours, minutes, seconds, mili_seconds): return hours * HOUR_TO_MS + minutes * MINUTE_TO_MS + seconds * S_TO_MS + mili_seconds def solution(lines): answer = 0 times = [] max_processed = 0 max_start_time ...
a23cbe23d923f241732bae12bdd883d8e1a6828b
tamerlan-b/ParticleSwarmOptimization
/scripts/Particle.py
4,535
3.796875
4
#!/usr/bin/env python #coding=utf-8 import random class Particle: """Частица роя""" def __init__(self, xmin, xmax, ymin, ymax): """Создаем частицу и инициализируем начальные значения Args: xmin (float): нижняя граница по x xmax (float): верхняя граница по y ...
263cb207abc7312f30f7205e51b7d18de17ff576
leonel9821/curso_linux
/sum.py
168
3.875
4
print('Insert the first number') num1 = int(input()) print('Insert the second number') num2 = int(input()) print('The sum of the above numbers is ' + str(num1 + num2))
a358f9cb61915c899ebe84e21173f394b068c307
YuanShisong/pythonstudy
/day3/08高阶函数.py
335
3.78125
4
''' 高阶函数: 将函数作为参数传递给另一个函数 注意和函数调用后的返回值传递给另一个函数的区别 ''' def absAdd(a, b, f=abs): return f(a) + f(b) rtn = absAdd(4,-8) print(rtn) '''结果>>: 12 ''' def myf(n): return n / 2 rtn = absAdd(4,-8, myf) print(rtn) '''结果>>: -2.0 '''
5f43de1c318ebf9a4c9cb19e5dd7bed866ad06e5
sshling/pyDemo
/ch01/t4_string.py
569
4.0625
4
#双引号包裹 单引号 x="I'am" #转义 x='I\'m' #字符串连接 x = 'I'+' am' a=2 # TypeError: Can't convert 'int' object to str implicitly #这里 str(a) 将 整数对象 转换为字符串对象,虽然 str 是一种对象类型,但它也能够实现对象类型的转换,起到了一个函数的作用 x='ab'+str(a) # repr() 是函数,能把结果字符串转化为合法的Python表达式 x='ab'+repr(a) # repr() str() 区别: # 大多情况用str() # repr() ,mainly useful for debugg...
364249af36e53d35ee8e7869f8792a86231bd57d
osterhout/python_practice
/09_guessing_game_one.py
472
3.90625
4
#!/usr/bin/python from random import randint q = int(randint(1,10)) guess = [] def ins(): userin = guess.append(int(raw_input("Guess an integer between 1 and 10: "))) while q not in guess: if guess[-1] > q: print("You're too high") ins() elif guess[-1] < q: print("You're too low") ins() elif Index...
14eb09d1ee705b1dc6ed0592e727bbdf146dfe63
3desinc/YantraBot
/mpu_6050/gyroscope_path_correction_mpu.py
2,853
3.578125
4
#!/usr/bin/env python # uses the gyroscope to read when drifting (mostly) and correct the path to go straight from rrb3 import * import time import read_mpu_6050 as reader rr = RRB3(9,4.5) # the 4.5v is for the motors, slowing it down. last = [0,0,0,0,0] # array of last 5 values read avgGyro = 0 try: # setup for...
68c23772e31eaf3ed7db2c91630fec68d9ff7b95
montaro/CtCI-6th-Edition-Python
/Chapter3/MyQueue.py
2,111
3.53125
4
import unittest class QueueNode(object): def __init__(self, data): self.data = data self.next = None class NoSuchElementException(Exception): pass class Queue(object): def __init__(self): self._first_ = None self._last_ = None def add(self, data): node = Qu...
7a97dfe941eb48d78eeb73df17d441de58c81b96
devilist/FirstProject
/chapter/chapter_4/exercise_4.py
1,155
3.65625
4
#! /usr/bin/env python3 guess_me = 7 start0 = 1 while True: if start0 < guess_me: print("low") start0 += 1 elif start0 == guess_me: print('yeh') break for item in [1, 2, 3, 4]: print(item) num_list = [num for num in range(0, 9) if num % 2 == 0] print(num_list) num_dict = {num: num ** 2 for num in range(0, ...
89e075e9ff3dc502ad22d040d6420d1b43d7a10f
Uthsavikp/Python_Data_Structures
/Tuple_Programs/different_data_type.py
513
3.71875
4
''' @Author: Uthsavi KP @Date: 2021-01-05 13:42:48 @Last Modified by: Uthsavi KP @Last Modified time: 2021-01-05 14:53:18 @Title: To Create Different A Tuple With Different Data Types ''' class DifferentTuple: def __init__(self): pass def tuple_with_different_data_type(self): """ creating a tuple ...
ec982c110c4833d91d4a2795334e78452e511a7f
jemmelot/Homework
/Homework/Week_3/convertCSV2JSON.py
882
3.6875
4
# Jesse Emmelot # 11963522 # # Converts a txt file to a csv, and csv to json import csv import json txt_file = 'KNMI_20161231.txt' csv_file = 'windspeeds.csv' json_file = 'windspeeds.json' days = [] # read txt file and format accordingly with open(txt_file, 'rb') as in_file: reader = csv.reader(in_file) for row i...
5780df8a70612db3bc5dff95f41dafab965d735f
alaaHdiab/Python_iti
/ass/str_index.py
474
3.703125
4
def str_index(txt,tst): lst=[]; strt=-1; for k in txt: #lst=[]; strt+=1; if k == tst: rr=txt.index(k,strt) lst.append(rr); return lst; #lst=[]; # txt=input('enter full text:'); # tst=input("enter a letter:"); # str_index(t...
9a881bae211cbdbc98ffe1db3dcab23f761b44e4
codeSmith12/PCAP-Training
/split.py
388
4
4
file = open("ipsum.txt", "r") data = file.read() print(data) textList = data.split() print(textList) # Search each list item, and count every letters (lowercase forced) occurance letterCounts = {} letterCounts["Enigma"] = "Unsolvable Mystery." for word in textList: for ch in word: if ch not in letterCounts...
573a11205eddff2a1b8c5c3b18ddad1f50cd881e
HohenheimGG/relaxed
/leet_code/128_longest_consecutive_sequence.py
1,728
3.75
4
# -*- coding: UTF-8 -*- # Given an unsorted array of integers, find the length of the longest consecutive elements sequence. # # For example, # Given [100, 4, 200, 1, 3, 2], # The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. # # Your algorithm should run in O(n) complexity. # class Long...
ab2184717a2589eb7e3e35400b68f87f3cc48e55
chaitanyakulkarni21/Python
/ObjectOrientedPrograming/oop3.py
657
4.0625
4
print(' ') class SchoolMember: def __init__(self,name,age): self.name = name self.age = age print("Intialised School Member:",self.name) class Teacher(SchoolMember): def __init__(self,name,age,salary): SchoolMember.__init__(self,name,age) self.salary = salary print("Initialised Teacher: ",s...
117e37cdfea8e8164e6d4d2ce18c49fcaa106dfb
joseph-mutu/JianZhiOfferCodePics
/复杂链表的复制.py
1,262
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-08-26 09:10:31 # @Author : mutudeh (josephmathone@gmail.com) # @Link : ${link} # @Version : $Id$ import os class RandomListNode: def __init__(self, x): self.label = x self.next = None self.random = None class Solution: # 返回 RandomListNode d...
beff61627ef26bc7fb73de127a85eef744ab0211
sudo-hemant/test
/geeksForGeeks/graph/topological-sort.py
598
3.78125
4
# NOTE: pepcoding has explained it very well, why we can't do it directly # insted of using stack and again reversing # recursive dfs & stack def topoSort(n, adj): is_visited = [False] * n res = [] * n for vertice in range(n): if not is_visited[vertice]: dfs(vertice, is_visit...
b0512a6051711c7077af7f21bb1ca26b3e207476
astar21/Programacion
/practica6/ejercicio6_1.py
145
3.6875
4
num=int(raw_input("Nmero de palabras:")) lista=[] for i in xrange(1,num+1): lista.append(raw_input("Palabra:")) print lista
6683784aaf59c2f5729024d9087b5019493a7464
miteshkumarsavita/CSE534-Final-Project
/src/Cache.py
2,751
3.609375
4
import datetime import sys def canEvict(value): return True class Node: def __init__(self, value, prev=None, next=None): self.value = value self.prev = prev self.next = next class LRUCache: dummyValue = -1 def __init__(self, maxSize, canEvictFunc=canEvict): self.maxSi...
da8167ab9139d1b6f0a1b425877ed60f80c49dc9
Alexandr4812/SF_Practicum16module
/QAP16.9.1.py
1,796
4.03125
4
from math import pi class Figures: def __init__(self, name): self.name = name class Rectangle(Figures): def __init__(self, name, a, b): super().__init__(name) self.a = a self.b = b def get_area_rectangle(self): return f'Площадь прямоугольника = {self.a *...
43e963a9d69082980843e03aa1b1dac9e611752a
Adrian-Perez-98/HW2_Python
/investment.py
419
4.09375
4
def calculate_apr(principal, interest_rate, years): """This function calculates the value of an investment after x amount of years""" if principal < 0 or interest_rate < 0 or years < 0: return False for i in range(0, years + 1): total = principal * (years + interest_rate) return total ...
dd04c630a9558e292cfcd0665e804e6564c83f26
farellf/pykue
/API/g_maps_api.py
3,314
3.828125
4
""" This code research nearby places in a given area. The code is divided in two parts : A first part, which uses Google API Geocode, tries to lookup the latitude and longitude of the place name the user enters. The Second part, which uses Google Web services API, uses the coordinates retrieved in t...
2bbce6bdd9cc10443aaae06a5fe33a77c3b68313
casthewiz/Sorts
/quicksort.py
566
3.609375
4
def partition(sortMe, start, finish): pivot = sortMe[finish] i = start for j in range(start, finish + 1): if sortMe[j] < pivot: tmp = sortMe[i] sortMe[i] = sortMe[j] sortMe[j] = tmp i += 1 tmp = sortMe[i] sortMe[i] = sortMe[finish] sortMe[f...
c25a995ecfe9334beb5eb6c56d58939c84a14eaf
jerrywu2013/computer_science_with_python
/Chapter05 拷貝/spiral1.py
1,156
4.125
4
# L-5 MCS 260 Fri 22 January 2016 : spiral1.py """ The instructions below illustrate some very basic turtle operations to draw the start of a spiral on canvas, using primarily goto commands. """ from turtle import Turtle # import the Turtle class SAM = Turtle() # sam is the name of a Turtle o...
71ce789b79d6c79c01038867bfb59f4fa6ac2eda
Jinyu97/python
/6_9월 28일 실습_170928/2061113466_4.py
313
3.625
4
grade=[] grade.append([int(input()), int(input()), int(input())]) grade.append([int(input()), int(input()), int(input())]) grade.append([int(input()), int(input()), int(input())]) stu={1:grade[0], 2:grade[1], 3:grade[2]} student=int(input()) gra=stu.get(student) gra.sort() print(gra, gra[2],gra[0])
c37d2c9935f44b6a525bfdcaed3048dca4afc52d
eopr12/pythonclass
/python20200322-master/class_Python기초/py14리스트/py14_06_리스트의연산자.py
1,820
3.71875
4
# 리스트 연산자 # + 결합 연산자 # * 반복 연산자 # [] 선택 연산자 # [:] 범위 연산자 # == 일치 연산자 # in in 연산자 # not in not in 연산자 # del 삭제 연산자 # 리스트 선언 list1 = [1, 2, 3] list2 = [4, 5, 6] print("list1 : ", list1) print("list2 : ", list2) print() # 리스트 + 연산자 list3 = list1 + list2 # [1, 2, 3, 4, 5, 6] p...
7dd2b044e75b4b8aaab70271fa00410d168fb5e3
OleksandrLozinskyy/Hillel_Python_Lessons
/Lesson2/task_dialog.py
356
3.953125
4
name = input('Привет меня зовут Жарвис а тебя как зовут : ') how_are_you = 'Как дела ' + name + '? :' answer = input(how_are_you) print(answer) num1 = int(input('Загадай число от 1 : ')) num2 = int(input('Загадай второе число :')) total = num1 + num2 print('Сума этих чисел :', total)
6806f0b597529ea82f2684d8b5612c3604131875
Sakshamgupta20/Python-Programs
/Collections.OrderdDict().py
757
3.875
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 23 21:29:59 2019 @author: Saksham """ """ You are the manager of a supermarket. You have a list of N items together with their prices that consumers bought on a particular day. Your task is to print each item_name and net_price in order of its first occurrence. """ f...
ab83676df09659b36dc3270b78fa6a5b07e13686
FrailCarter/ProgrammingChallenges
/quicksort.py
1,349
4.03125
4
def quicksort(arr): def qsort(low , high): if low >= high: return i , j = low , high pivot = arr[random.randint(low , high)] while i <= j: while arr[i] < pivot: i += 1 while arr[j] > pivot: ...
c9d7eebff51d7bdbfb9c1a9f3a4d6e4593a7dd52
jsanon01/python
/python-folder/phone-number-format2.py
356
4.15625
4
# This script formats phone number print() print('Phone Number prints in the following format:\t(XXX)-XXX-XXXX') while True: num = input("\nEnter Phone Number or 'q' to exit: ") if num == 'q': break else: print("\nYou entered: ("+num[:3]+")"+num[3:6]+"-"+num[6:]) print('\nYou have e...
971f07d9f80aeb43d26a7ac9e1465be64047c9ab
dundunmao/lint_leet
/mycode/lintcode/advance/5 DP/430 Scramble String.py
1,887
3.59375
4
# -*- encoding: utf-8 -*- # 记忆化搜索 class Solution: # @param {string} s1 A string # @param {string} s2 Another string # @return {boolean} whether s2 is a scrambled string of s1 def isScramble(self, s1, s2): hash = {} if len(s1) != len(s2): return False if hash.has_key(s...
72c09fc2339467cc9af01237c92da39a33a27aa9
nickbuker/monte_hall_python
/src/monte_hall_rec.py
1,545
3.890625
4
import numpy as np def monte_hall_rec(switch_door, n_sim=500): """ Simulates the Monte Hall problem to find the probability of winning by either the strategy of keeping the original guess or switching doors Parameters ---------- switch_door : bool whether or not to switch doors after bein...
091f227c9836aa22b373aa3b2cc246e11409b6cd
EduRibeiro00/hashcode-training
/prep/state/state.py
887
3.78125
4
class State(object): def __init__(self) -> None: self.value = None def calc_random_solution(self): """Calculates a random solution for the problem.""" pass def get_all_neighbours(self, generator=True) -> list('State'): """Generates all neighbors of the current state.""" return [] def ge...
83b4254620fc61813b3bcc34a202435e5bfabdae
om-prakas/Machine-Learning
/Polynomial Regression/Mutilple_regression_Sal_VS_Position.py
2,132
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sat May 11 15:01:26 2019 @author: OmPrakash # According to position(year of experience matters for position) find salary """ import numpy as np import pandas as pd import matplotlib.pyplot as plt dataset = pd.read_csv('Salary_Negotiate_position.csv') #writing 1 instead of 1...
b5618ba48f2476e416afc0adc5a8d50c66c492f5
elainy-liandro/mundo1e2-python-cursoemvideo
/Desafio 7.py
136
3.71875
4
n1 = float(input('Digite sua nota: ')) n2 = float(input('Digite sua segunda nota: ')) m = (n1 + n2)/2 print('Sua média final foi ' , m)
53e2cc94dbc69d98f7b9cdde4b5649e1f7d098a5
Matthew-J-Walsh/UtilityFunctionWebapp
/varibleApp/DataFolder/test/test.py
585
3.625
4
import argparse def main(arguments): if isinstance(arguments, dict): result = add(arguments[arguments.keys()[0]],arguments[arguments.keys()[1]]) else: parser = argparse.ArgumentParser() parser.add_argument("-a", help="Number One.", type=float, default=5) parser.add_argument("-b"...
32043f35f0de6bbb95276acaf62b039cb52aa526
basyura/sample-py
/analysis01/dummy_var.py
684
3.9375
4
# 単回帰分析 import pandas as pd import matplotlib.pyplot as plt import numpy as np import pyper from sklearn import linear_model # データ全体をまとめる iris = pd.read_csv( "https://raw.githubusercontent.com/pydata/pandas/master/doc/data/iris.data") # カテゴリデータを数値として扱うため # 品種ごとに該当する要素に 1、該当しない場合は 0 を入れる。 dummies = pd.get_dummie...
6f0c1742fa907e9a3e1a6117221252c61bec5c7d
muhanadAfifi/Laps-project-assignment
/Muhanad-Affif-3705648/Laps/Lap-2.py
3,266
3.890625
4
#!/usr/bin/env python # coding: utf-8 # In[43]: from platform import python_version print(python_version()) # In[68]: # filename.py if __name__=="__main__": pass # In[67]: if __name__=="__main__": print("Hello,world") # In[66]: x = 5 y= 2**2 +1 x==y x,y=5, 2**(2+1) x==y # In[72]: def add(x,y)...
f64b9895906a3447fd3d4cf8217374a3aee76d21
susnchen/CtCI
/2. Linked Lists/2.2.py
345
3.921875
4
from LinkedList import * def kthToLast(node, k): diction = {} cur = node counter = 0 while cur != None: diction[counter] = cur cur = cur.next counter += 1 return diction[counter-k] a = Node(1) a.insertList([5,2,3,4,15,4,5]) a.print() print(",") a = k...
dbfeea2892355e4a864a4fdcc9023fa9b04727a4
sidgn/summerPython
/fileread.py
354
3.578125
4
try: fhand = open('essay.txt', 'r') except: print('File not available.') quit() thisset = set() wordcount = dict() for line in fhand: for word in line.split(): thisset.add(word) if word in wordcount: wordcount[word] += 1 else: wordcount[word] = 1 ...
e20d25a4daddb24e6b98207c592a7e18bd5e6366
Barbara0070/barbara
/colections/zad11.py
316
3.515625
4
liczby=set() parzyste=set(range(0,101,2)) print(parzyste) while(True): print("podaj liczbe q to koniec") a=input() if a=='q': break a=int(a) liczby.add(a) print(liczby) iloczyn=parzyste&liczby print("unikalne liczby", liczby.__len__()) print("parzyste w zakresie", iloczyn.__len__())
77bb405966a375c3ca5d3bf16f17263330cc0e17
lee9871/heima_suanfa
/coda/5_02_bubble_sort.py
663
3.953125
4
def bubble_sort(alist): """冒泡排序""" # j是遍历的轮次 # i是每层遍历,第一次0 - n-2,range(0,n-1),第二次0 - j-3,最后一次 0-1 # 最坏时间复杂度为o(n^2) # 最优时间复杂度为o(n) # 稳定性:是稳定的 n = len(alist) for j in range(len(alist)-1): count = 0 for i in range(0, n-j-1): if alist[i] > alist[i+1]: ...
33fda3e2a7608623dbfaaa2ab3eecdef2b15d3aa
codernineteen/Portfolio6_breakoutgame_clone
/paddle.py
462
3.53125
4
from turtle import Turtle X_COR = 0 Y_COR = -150 class Paddle(Turtle): def __init__(self): super().__init__() self.speed(10) self.penup() self.shape("square") self.color("#766161") self.setpos(x=X_COR, y=Y_COR) self.shapesize(stretch_wid=0.5,str...
e6021a2412daa85e2eca6f37ebb534d2b0fe3562
jodaruve/Parcial
/ejercicio 61 (2).py
380
4.125
4
## 61 print("Este programa mostrara los nmeros naturales en el rango que usted desee") n=int(input("Por favor ingrese desde donde desea que empiece el conteo ")) m=int(input("Por favor ingrese hasta donde desea que llegue el conteo ")) if m>n: for i in range(n,m+1): print(i) else: print("Por favor asegrese que ...
d0fa1f64065e63d5e95474f6ebfd8469e1f01fd6
RyanMcCall/python-exercises
/4.7_working_with_files.py
1,783
4.28125
4
# Read the contents of your last exercise file into a variable. with open("4.6_import_exercises.py") as f: import_exercises = f.read() # Print out every line in the file print(import_exercises) # Print out every line in the file, but add a line numbers with open("4.6_import_exercises.py") as f: for i, line in...
5054084e4d87752f2d06fd2117c70aa1c3cf6f82
ciscowh/oop1
/定义类.py
929
4.15625
4
class Person: ''' 对应人的特征 ''' # name='小明' # age='18' ''' 对应人的的行为 实例方法 ''' def __init__(self,name,age,sex): self.name=name #实例的属性 self.age=age self.sex=sex def eat(self,food): print(self.name+'大口大口的吃'+food) pass def run(self): #实例方法 ...
43bdb08ad51c2d37501df84d727986f4ebd6c178
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_136/2315.py
400
3.6875
4
#!/usr/bin/env python3 def meilleur(C, F, X): R = 2.0 derniere_ferme = 0.0 meilleur = X / R while True: derniere_ferme += C / R R += F candidat = derniere_ferme + X / R if candidat < meilleur: meilleur = candidat else: break return meilleur T = int(input()) for i in range(T): C, F, X = map(...
6bb6d3cb4fe269a0c06786d9bfef8062f71a714b
AkashPatel18/Basic
/video1/Q8.py
144
3.5
4
''' def fac(n): if n ==0: return 1 return n*fac(n-1) print(fac(5)) ''' n= 6 f=1 t=1 while(t<n): f=f*n n=n-1 print(f)
5296cda73023e60f80320becec9ecb6ae0f0931f
sarikasp/Python
/python/Day2ListAppendCountReverseSlicingPopRemoveCopyInInsert+=.py
2,484
4.03125
4
# data structures # collection list fruits = ["apple", " chikoo", "banana", "mango", "stawberry", "peach", "grapes"] fruits.append("cherry") print(fruits) #output is ["apple", " chikoo", "banana", "mango", "stawberry", "peach", "grapes", "cherry"] x=fruits.count("mango") print(x) #output is 1 #fruits.clear() fruits.i...
de387432abe61e5f6fadc2f91421a3ec7f43dc54
jmperez81/udacity-machine-learning
/outliers/outlier_cleaner.py
1,094
3.53125
4
#!/usr/bin/python from numpy import subtract, square, argmin, take, delete import sys def outlierCleaner(predictions, ages, net_worths): """ Clean away the 10% of points that have the largest residual errors (difference between the prediction and the actual net worth). Return a lis...
46178c9528e2f267053992b3677e017bec4c03d8
hemanadhan/CADMium
/CADMium/pssolver/calc_density.py
1,264
3.5
4
""" calc_density.py """ import numpy as np def calc_density(self): """ Calculate density from orbitals """ self.n = np.zeros((self.grid.Nelem,1)) #Figure out the number of occupied norbitals: Nocc if self.m == 0: if self.pol == 1: Nocc = np.floor(self.N/2) nu =...
74a254efb8be79801d61b3c94795cab85bf246d4
uyilgnaw/notebook
/多线程/12.py
1,058
3.65625
4
import threading import time lock_1=threading.Lock() lock_2=threading.Lock() def func_1(): print("func_1 starting.....") lock_1.acquire() print("func_1 申请了lock_1") time.sleep(2) print("fun_1将要申请lock_2") lock_2.acquire() print("func_1申请了lock2") lock_2.release() print("lock_2释放了") ...
17fef2c7d0f7aee39dea4cac1720f6597f799f68
KostyaTyurin/programming_practice_2020
/week6/ploshad_task3.py
529
3.78125
4
import numpy as np def krug(r): return np.pi * r ** 2 def square(a, b): return a * b def triangle(c, h): return 0.5 * c * h a = input('What are you gonna count (triangle, square, circle?) ') if a == 'triangle': c = int(input(' длина = ')) h = int(input('высота = ')) print(triangle(c, h))...
eaa0862ac25519a84af0807c03bc01c1fa2de9ea
RitRa/Little-Python-application-gmit-semester-3-2019
/Python/connect.py
2,733
3.703125
4
import pymysql.cursors # Connect to the database conn = pymysql.connect(host='localhost', user='root', password='Password!', db='world', charset='utf8mb4', cursorclass=pymy...
882c9caa5323a15c8194b1d7a227fcfef471dfe2
BoynChan/Python_Brief_lesson_answer
/Char10-File&Error/char10.2.py
279
3.8125
4
filename = 'guest.txt' with open(filename, 'a') as file_obj: file_obj.write("Guest Name: \n") while True: string = input("Write a name,'q'to leave ") if string == 'q': break print("Hi!"+string+".") file_obj.write(string+"\n")
bd664d582300e49d7b79f9bea1fcfbe4c0b03f0b
PulkitSingh2008/Calculator-that-you-need
/Grades.py
722
4.03125
4
def grade_obtained(percentage): if (percentage >= 60) : print("1st Division") elif (percentage >= 50 and percentage <= 59) : print("2nd Division") elif (percentage >= 40 and percentage <= 49) : print("3rd Division") else: print("Fail") print("Please enter your marks out of 100") subject1=float(input("Pleas...
5f8e8fbe1fc65c904aee204b7889940869e56080
Raision-seudun-koulutuskuntayhtyma/OhjelmointiTA
/silmukoita3.py
854
3.953125
4
# Täytetään listaa kunnens käyttäjä syöttää tyhjän arvon kauppalista = [] while True: ostos = input('Mitä pitää tuoda kaupasta? ') if ostos == '': break kauppalista.append(ostos) print('Ja tuo kaupasta:', kauppalista) # Luetaan kauppalista FOR-silmukassa, merkinta-muuttuja viittaa listan jäseneen ...
b1a96d618bfa0026a3e2678b172b5d26cc45fd31
dmtkomkov/chess
/objects.py
1,778
3.703125
4
class Square(object): def __init__(self, name, x, y): self._piece = None self.name = name self.x = x self.y = y def __str__(self): return self.name @property def piece(self): return self._piece @piece.setter def piece(self, piece): self._piece = piece class Piece(object): def __init__(self, nam...
e0a86bc39ab1751a576664e4d5443f72f4b8cd93
wpy-111/python
/DataStructure/train_link/2stacktoqueue.py
1,173
3.953125
4
""" 两个栈实现队列 完成队列的push和pop操作 队列中的元素为int类型 思路: 1.最终目标实现队列:先进先出fifo 2.现有资源:两个栈(计划使用顺序表实现) 设计: stack_A = [100,200,300] append(),pop()进行入栈和出栈 stack_B = [] 也是用append(),pop()进行入栈和出栈 """ class Solution: def __init__(self): #创建两个空栈 self.stack_A = [] self.st...
586bcd992241a16649bd33812562d440e4547a4d
Ashank-Dsouza/Instagram-Image-Scrapper
/UserNameHandling.py
1,089
3.65625
4
import os class UserNameClass: Usernames = list() def __init__(self): self.Usernames = self.filter( self.getUserNamesFromTxtFile() ) def filter(self, Usernames): ValidUsername = list() for name in Usernames: if name and isinstance(name, str): Candidate...
21d804be59f134ee1a2ee6d87013d5239ddd1586
siri3/Byte_Exercises
/py_basics/wknd2.py
3,173
4.125
4
#https://knightlab.northwestern.edu/2014/06/05/five-mini-programming-projects-for-the-python-beginner/ def roll(): import random roll = input("enter y to continue, enter to stop ") while roll == "y": print (random.randint(1,6)) roll = input("enter y to continue, enter to stop ") d...
9c7cef53b3dbba41e4633415433621b6d7da2946
petros-p/xkcdpwgen
/xkcdpwgen.py
2,705
3.78125
4
#!/usr/bin/env python3 import random import argparse # parse arguments parser = argparse.ArgumentParser(description="Generate a secure, memorable password using the XKCD method") parser.add_argument("-w", "--words", default=4, type=int, help="include WORDS in the password (default=4)") parser.add_argument("-c", "--cap...
0f0aecb51380c691a5fb9f9bfef639fc4f3b4074
juseus03/HerramientasComputacionales
/2018-20/SEC 03 (M 1130-1250)/HW4-FUNCTIONS/HW4_S_SEC03.py
449
3.53125
4
#Punto 1 def mcd(m,n): r = m%n if(r==0): #Caso base return n else: return mcd(n,r) m=60 n=40 print "MCD de m=",m,"y n=",n,"es:",mcd(m,n) #Punto 2 def sumDig(num): numStr=str(num) #COnversion del numero a string if(len(numStr)==1): return num else: return int...
f0db926d60ecdc61580694e5d5623746cbef3b9d
PeterBeattie19/Machine-Learning
/Kaggle/Mnist_Sklearn_NeuralNet.py
1,880
3.5
4
import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) from sklearn.neural_network import MLPClassifier import csv # Input data files are available in the "../input/" directory. # For example, running this (by clicking run or pressing Shift+Enter) will list the files ...
2738e6d8e37e9d44c24e2f65e464dcb3952304cf
RahulBhoir/Python-Projects
/data_structure/birthdayGift.py
337
3.5
4
n = 7 count = 0 # for i in range(1, n): # for j in range(1, n): # if j % i == 0: # print(i, j) # count += 1 for i in range(1, n): for j in range(1, n): for k in range(1, n): if j % i == 0 and k % j == 0: print(i, j, k) count +=...
1c383b70d51c15d4589929e9a7001e51c981cf46
kelr/practice-stuff
/leetcode/1431-kidcandies.py
593
3.828125
4
# Find the largest current value of candies, then check if any of the kids can meet or exceed the max when you give # them all the extras. # O(N) time since N comparisons to find the max, then N comparisons to check if they can have the greatest. # O(N) space technically since an output list has to be created with ...
b27f38a3a173eb7607d22f8e589ab3959db27669
yongyuandelijian/mystudy
/studypc/common/csv_utils.py
633
3.515625
4
# csv 文件操作工具 import csv # import codecs # 将数据写入csv def write_csvFile(path,head,data): try: with open(path,"w",newline="",encoding="utf-8-sig") as csvFile: # 制定编码,否则会提示编码不匹配 writer=csv.writer(csvFile,dialect='excel') if head is not None: writer.writerow(hea...
823d32c3a9c766777d14573e9d49cf1e9e923ced
Vallarasan7/Project3
/Project3.py
269
4.21875
4
#Assigning elements to a list. a=[1,2,3] a.append(4) a.append(5) print(a) #Accessing elements from a tuple. b=(1,2,3,4,5) print(b[0:3]) print(b[3]) print(b[3:5]) #Deleting different dictionary elements. c={1:1,2:2,3:3,4:4,5:5} c.pop(1) c.pop(3) print(c)
1401a48ab78fa934fa488e8946e2da04960f4c35
loredan/maze
/maze.py
8,074
3.546875
4
from tkinter import Canvas import cubehelix DIRECTIONS = ["LEFT", "TOP", "RIGHT", "BOTTOM"] class Maze: def __init__(self, size): self.size = size self.paths = [] self.reset_maze() self.flood = self.Flood(self, 10) self.colormap1 = cubehelix.cmap(startHue=-100, endHue=30...
71aab71320a72efeea1aac7468a032ec4c97b3ad
alexk307/pr-monitor
/git.py
3,150
3.625
4
from requests import get from config import CONFIG import json class Github: """ Class encapsulating GitHub API """ def __init__(self, token): self.token = token self.base_url = 'https://api.github.com' self.owner = CONFIG['organization'] def _build_request(self, path): ...
1f5eb318389a96c08aacdc5973d47ba17aaac1ae
rafaelpuyau/HSMu-Code-School
/banco_digital.py
3,310
4.25
4
""" Simule o funcionamento de um banco digital e crie contas para reproduzir alguns dos principais recursos. Um banco possui uma conta comum, que deve ter as seguintes propriedades: números da agência e conta, nome do proprietário da conta, renda mensal e saldo. A conta deve ter seu número gerado aleatoriamente e preci...