blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
199ffaef94cf149852ceb2b44a90f6e30b430290
westgate458/LeetCode
/P0497.py
1,563
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 27 01:22:26 2020 @author: Tianqi Guo """ class Solution(object): def __init__(self, rects): """ :type rects: List[List[int]] """ # accumulative area area = 0 # record accumulative area for each rectangle self.a...
249437b0912f95b7fd0777acd2c5c1397948ab53
mizydorek/pands-problems-2020
/Topic07-Files/lab07.03-json-write copy.py
230
3.53125
4
# Maciej Izydorek # function to store data in json import json filename = 'testdata.json' d = dict(name = 'Fred', age=31, grades=[1,34,55]) def writeFile(obj): with open(filename, 'w') as f: json.dump(obj, f) writeFile(d)
5d590773e948a8fe8ce2c00a0705958e7c71fa38
temptemp3/rps-1
/rock_paper_scissors/league/daymoo.py
1,726
3.546875
4
import random from rock_paper_scissors import ROCK, PAPER, SCISSORS, BasePlayer class Player(BasePlayer): player_name = 'Daymoo' author = 'Daymon' def __init__(self, start_play=PAPER): self.next_play = start_play self.their_history = [] def play(self): if len(self.their_his...
0efbb2e577489249052855a4e39a0855bf2b440d
gabriellaec/desoft-analise-exercicios
/backup/user_278/ch34_2020_03_31_22_39_40_279497.py
378
3.59375
4
def eh_primo(x): if x<=1: return False if x==2: return True if x%2==0: return False tmp= 3 while tmp < x: if x%tmp==0: return False else: tmp += 2 return True def maior_primo_menor_que (n): n = x while x>=2: if eh...
bfa364bc069295af9331dccdd38c74de61521315
sapnadeshmukh/loop_python
/greaternum_among_3.py
208
4.15625
4
num1=int(input("enter num1=")) num2=int(input("enter num2=")) num3=int(input("enter num3=")) if (num1>num3 and num1>num2): print(num1) elif (num2>num1 and num2>num3): print(num2) else: print(num3)
89b98ed9306fdabfe31749212412e798e1443ae4
adwynn/comp110-21f-workspace
/exercises/ex05/utils.py
770
3.65625
4
"""List utility functions part 2.""" __author__ = "730443412" # Define your functions below def only_evens(x: list[int]) -> list[int]: result: list[int] = [] for num in x: if num % 2 == 0: result.append(num) return result def sub(x: list[int], start: int, end: int) -> list[int]: ...
3d37a3ccecee3ae8fc529ae77a76d0edfdc91cad
RickyZhong/CheckIO
/ICE BASE/Feed Pigeons.py
623
4.09375
4
def checkio(number): pigeons = 0 minutes = 0 remains = number while remains > 0: minutes += 1 pigeons += minutes remains -= pigeons if remains == 0: return pigeons elif pigeons + remains <= pigeons - minutes: return pigeons - minutes else: ret...
38f5561c4ab66c3bc30741ca35c25420fe6875b5
alimsta/NxN-TicTacToe
/NxN_TicTacToe.py
3,213
3.84375
4
# Alim Momin # Tic Tac Toe # Instructions: def fillBoard(dimension): board = [] for x in range(dimension*dimension): board.append("_") return board def displayBoard(board, dimension): cnt = 1 for r in range(dimension): for c in range(dimension): if board[(r*dimension)+c] == '_': print("...
183b7097beecfa95bdf01a2a8ee694b80b0b1e33
dvminhtan/python_core
/source/lession_3/baitap5.py
1,101
3.8125
4
#Bài 05: Viết chương trình tìm ra ký tự lớn nhất và ký tự nhỏ nhất của một chuỗi nhập từ bán phím. #Python3 program to find largest and smallest characters in a string """ Input : minh tan Output : Largest = t, Smallest = a """ #cach 1: s_05 = input("Nhập vào một chuỗi: ") # if s_05: # c_max, c_min = s_05[0], s_05...
05284338004f0d4feffb7c1f043b7589ed4ed622
hcxie20/Algorithm
/shopee/q3.py
586
3.515625
4
import math class Solution: def expect(self , n ): rst = 0 def c(n, k): # return tmp(n, k) / math.factorial(k) return math.factorial(n) / (math.factorial(n - k) * math.factorial(k)) def tmp(n, k): rst = 1 tmp = n while tmp >= n - ...
41afd0aea6d1f8ac60c2b60911603d3a277354f5
lucasolifreitas/ExerciciosPython
/secao4/exerc5.py
91
3.828125
4
num = float(input('Digite um numero: ')) print(f'A quinta parte desse numero é: {num /5}')
fc20adb6c6fd82ceaa1244b5026c0b6b97fe06cd
leehaejoon/QA_INTERN_TEMP
/src/01.string_reverse/hwpark/md_reverse.py
1,142
3.625
4
import re def read_file(file_name): with open(file_name, 'r') as f: _line = f.readline() line_list = [_line] while _line: _line = f.readline() line_list.append(_line) return line_list def line_reverse(line_list): pattern = re.compile("\w+") reverse_line_...
53b64f42cbe0f76303f7dc680b13e0983e48207b
hz336/Algorithm
/LintCode/DFS/Next Closest Time.py
2,309
4.03125
4
""" Given a time represented in the format "HH:MM", form the next closest time by reusing the current digits. There is no limit on how many times a digit can be reused. You may assume the given input string is always valid. For example, "01:34", "12:09" are all valid. "1:34", "12:9" are all invalid. Example Gi...
9c670b56b8b4e77a32a4c127ef15db8a11a45572
karcagtamas/Demos
/Python-Demo/tuples_sets.py
750
3.96875
4
# Tuple - Unchangeable # Create tuple fruits = ('Apples', 'Oranges', 'Grapes') fruits2 = tuple(('Apples', 'Oranges', 'Grapes')) print(fruits, fruits2) # Weird string fruits3 = ('Apples') print(fruits3, type(fruits3)) # Get value print(fruits[1]) # Can't change value # fruits[0] = 'asd' # Delete del fruits2 # prin...
c9dba83fc6ee5f33ba6db6576bae42315409065f
kasem777/Python-codeacademy
/List_challenges/nested_lists.py
1,129
4.28125
4
# Nested_lists # Given the names and grades for each student in a Physics class of students, # store them in a nested list and print the name(s) of any student(s) having # the second lowest grade. # Note: If there are multiple students with the same grade, order their names # alphabetically and print each name on a n...
1f08e49076fb984882b2de54a9ce08edc7f92b86
xoyolucas/My-solutions-for-Leetcode
/92.反转链表-ii.py
1,451
3.75
4
# # @lc app=leetcode.cn id=92 lang=python3 # # [92] 反转链表 II # # https://leetcode-cn.com/problems/reverse-linked-list-ii/description/ # # algorithms # Medium (51.99%) # Likes: 636 # Dislikes: 0 # Total Accepted: 95.5K # Total Submissions: 183.7K # Testcase Example: '[1,2,3,4,5]\n2\n4' # # 反转从位置 m 到 n 的链表。请使用一趟扫描完...
7a94a80d47f2e40c76be40a0b6a2ec65c9ccbfdb
AMinerva400/MachineLearning
/Class_Exercises/classExercise3.py
2,353
3.984375
4
#!/usr/bin/python #Author : Anthony Minerva #Date : September 12th, 2018 #Desc : Class Exercise 3: Working with Pandas from pandas import DataFrame, read_csv import pandas as pd def makeDataSet(f1, f2, f3, l1): dataSet = list(zip(f1, f2, f3, l1)) return dataSet def makeDataFrame(ds): dataFrame = Dat...
0c4c50a6e750e20db774cb94f0275fe1dfa40c53
sheelabhadra/Elements-Programming-Interviews
/Greedy Algorithms and Invariants/minimize_waiting_time.py
695
4.09375
4
# Schedule to minimize waiting time # Given service times for a set of queries, compute a schedule for processing the # queries that minimizes the total waiting time ## SOLUTION: Sort the service time array. As lower service time in the beginning # will reduce the total waiting time. def minimum_total_waiting_time(...
f116adf4fe1e27dc6a281c31bc52dc71234f7650
divyanarra0/pythonprogram
/natural.py
136
4.0625
4
num=int(input("")) if(num<0): print("the num is negative") elif(num==0): print("the num is zero") else: num=num*(num+1)/2 print(num)
70a4ee9fcb28b8de53b3b68669baa7f9c6fb2d91
adyadyat/pyprojects
/personal_folder/py2.py
753
4.21875
4
name = input("Enter your name: ") print(name.title()) # title() - изменение регистра символов в строках # (первые символы в словах верхним, остальные нижние) print(name.upper()) # upper() - все символы в строках верхним регистром print(name.lower()) # upper() - все символы в строках нижним регистром # "\t" табуля...
5c87f1f0c7aa3e917fdd93303fe5aa09ceb37cc3
mitakaxqxq/CinemaReservationSystem
/root/users/validations.py
929
4.03125
4
import re import string def validate_username(username): smallcase_letters = string.ascii_lowercase uppercase_letters = string.ascii_uppercase numbers = string.digits available_symbols = list(smallcase_letters) + list(uppercase_letters) + list(numbers) + [' '] for character in username: if...
53bb3c1d0f87a233f97a9cf1b743ea0c1c6f587f
KKimishima/Studying_Python
/1.Basic/jankein.py
174
3.796875
4
print("ジャンゲーム開始\nグー...1,チョキ...2,パー...3") x = "a" while x == "b": print("入力:") x = input(); print("入力"+ x) print("正解")
cb8d82a83143e3a0b7626852ed990ffd209fc8b3
alok1994/Python_Programs-
/try_except1.py
269
3.890625
4
a = raw_input('Enter a number:') b = raw_input('Enter second number:') try: z = int(a)/ int(b) except ZeroDivisionError: print 'Divide by zero exception' except TypeError: print 'String and int we can not divide' else: print 'Divide {0}/{1}: {2}'.format(a,b,z)
3961aae08bd4ec807b7ea5fe81458102f5b29a69
calt-laboratory/knn_from_scratch
/knn_test_file.py
625
3.515625
4
# import libraries import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split from k_nearest_neighbor_classifier import * # build Iris data set iris_dataset = datasets.load_iris() X, y = iris_dataset.data, iris_dataset.target # split dataset into train set and test set X_tra...
6f2d33eb776217bb8285b242e073253e9ca72f72
abhinai96/Python_conceptual_based_programs
/datastructures/Lists/list to comma seperate.py
82
3.53125
4
a=[1,2,3,4,5] print(a) numbers=",".join(str(i) for i in a) print(numbers)
a919c04457e3f13f352a722a8adaf3732cbd2bf2
rishabh-1004/projectEuler
/Python/euler035.py
735
3.609375
4
import time def SieveOfEratosthenes(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime def iscircularprime(n): global primes s=str(n) fo...
74609ecff08492d5f2149c96a22946c71cb56b32
timleslie/pyblas
/pyblas/level1/scnrm2.py
1,359
3.625
4
import numpy as np from ..util import slice_ def scnrm2(N, X, INCX): """Computes the Euclidean norm of the vector x Parameters ---------- N : int Number of elements in input vector X : numpy.ndarray A single precision complex array, dimension (1 + (`N` - 1)*abs(`INCX`)) INCX :...
bbe6d52c72d7ff4b7bc494d6baef8ce296d40501
hyunjunmn/Languages
/Python/Python_day2.py
662
3.859375
4
#tuple ,list 랑 같지만 변경할 수 없음 #days = ("Mon","Tue","Wed","Thr","Fri") #print(type(days)) #type을 알아보기위한 출력방식 #dictionary 만들기 #key와 value로 이루어짐 nico={ "name":"nico", "age":29, "korean":True, "fav_food":["Beef","Chicken"] } #print와 같은 python안에서 built-in된 함수들 알아보기 print(nico) nico["awesome"] = True #dictio...
27b8014f7160b6d2af51a9361fec383cf7a74766
ellaazhang/fullstack_develop
/day4/triangle.py
231
4.03125
4
def triangle(n): i = 1 while i <= n: m=0 while m < i: if m == i-1: print("#") else: print("#",end='') m = m+1 i = i+1 triangle(3)
c7cccdceb6affd4c7ebfb560ab6f30cee92e493a
RLBot/RLBotPack
/RLBotPack/Bribblebot/util/vec.py
4,146
3.859375
4
import math from rlutilities.linear_algebra import vec3 # This is a helper class for vector math. You can extend it or delete if you want. class Vec3: """ This class should provide you with all the basic vector operations that you need, but feel free to extend its functionality when needed. The vector...
7b0e5e8900154b427a4556bbde75952cc5e34335
katipogluMustafa/PythonLangTraining
/03_CodeSnippets/00_Language_Fundamentals/03_Data_Types/04_Strings.py
3,367
4.46875
4
# Strings # Creating Strings my_str = 'Hello'; # Method 1 print(my_str) my_str1 = "Hello"; # Method 2 print(my_str1) my_str2 = '''Hello'''; # Method 3 print(my_str2) # Multiline Strings using Triple Quotes my_multiline_str = """Hello... This is a multiline Str...
8cb9f07489345080bd9799cdce21786f1462f69e
mekhala1808-cmis/mekhala1808-cmis-cs2
/recursive.py
307
3.828125
4
def adder(stuff, total): if stuff == "": return total else: total += float(stuff) stuff = raw_input("Running total: " + str(total) + "\nNext number: ") return adder(stuff, total) def main(): out = adder(0, 0) print "The sum is " + str(out) main()
5f854157da8ff79f0474764419338b8d5757fda8
duongcao74/PythonHW
/hw9/hw9.py
3,914
3.546875
4
import urllib.request import urllib.parse import bs4 import re import pandas as pd def process_num(num): return int(re.sub(r'[^\w\s.]', '', num)) def process_str(str): return re.sub(r'(\[\w])|(\[]?\w.])', '', str) def visit_url(url): """ Open the given url and return its visible content and the re...
f387c0b8bc2bf5c9ab657074bde6c0124f441e6e
winkelmantanner/math5107
/hw2HardestProblem.py
636
3.625
4
NUMBERS = tuple(range(10)) MIN_NUMBER = 0 MAX_NUMBER = 9 def generate_increasing_sequnces(length, increase_amount): if length == 1: for number in range(MIN_NUMBER, MAX_NUMBER + 1): yield (number, ) else: for suffix_sequence in generate_increasing_sequnces(length - 1, increase_amoun...
3fe44299fc5aff56b5d3275c7f80b469e9e5d0ec
kebingyu/python-shop
/the-art-of-programming-by-july/chapter1/string-contains-1.py
2,900
3.828125
4
# -*- coding: utf-8 -*- """ 给定两个分别由字母组成的字符串A和字符串B,字符串B的长度比字符串A短。请问,如何最快地判断字符串B中所有字母是否都在字符串A里? 为了简单起见,我们规定输入的字符串只包含大写英文字母,请实现函数bool StringContains(string &A, string &B) 比如,如果是下面两个字符串: String 1:ABCD String 2:BAD 答案是true,即String2里的字母在String1里也都有,或者说String2是String1的真子集。 如果是下面两个字符串: String 1:ABCD String 2:BCE 答案是fa...
961ffd4488a711566768a6f05fdda8395990eca4
pydevjason/Python-VS-code
/python_clock.py
411
3.71875
4
import time hours = 12 minutes = 59 seconds = 59 while True: print(str(hours).zfill(2) + ":" + str(minutes).zfill(2) + ":" + str(seconds).zfill(2)) seconds += 1 time.sleep(1) if seconds == 60: seconds = 0 minutes += 1 if minutes == 60: minutes = 0 h...
4d5ac67a0a15a97b4c87fd065af97928c164eeb8
devkudasov/py4e
/dataStructures/assignment_7_2.py
308
3.71875
4
# Use words.txt as the file name fname = input("Enter file name: ") fh = open(fname) total = 0 count = 0 for line in fh: if 'X-DSPAM-Confidence:' in line: iPos = line.find(':') total += float(line[iPos + 1:].strip()) count += 1 print('Average spam confidence:', total / count)
7632a27c605e01f70d5acdf4485292307066f54c
ngeraci/disqus2csv
/comments_by_user.py
1,039
3.578125
4
"""Extract comments from single username to CSV. """ import sys import argparse import pandas as pd from disqus_to_csv import * def main(args=None): """Parse command line args. """ parser = argparse.ArgumentParser( description='Disqus XML to CSV, filtered on a single username') parser.add_argum...
3c6005302d5d609bf5b76663a5d692dc078b2559
Eduardo211/EG
/Lecture/99_bottles_of_beer_v1.py
1,370
4.40625
4
# Defining variables bottle_start_amount = 99 bottle_end = 0 bottles_current = bottle_start_amount bottles_remaining = int(bottles_current) - 1 # This function checks if the word "bottle" should be singular or plural def bottle_check(): bottle_state = "bottles" if bottles_remaining != 1: bottle_state ...
763de5f802a0c68f0d68b8f5fe0982a151f3365a
hipsterpants/neural_network
/NeuralNetworkV35.py
5,013
4.40625
4
""" Sean McDonald 10/31/16 Neural Network Version 3.0 A slightly more advanced neural network when compared to V2. Implements a very basic backward propagation algorithm in order to reach the result. Uses Standard Gradient Descent with a variety of Alpha values that modify the size of the weight adjustment. This has...
56b6e7ee2893fc20d367ae4973f378b3a0f2a138
gabreuvcr/curso-em-video
/mundo2/ex057.py
309
4
4
## EX057 ## sexo = '' while (sexo != 'F') and (sexo != 'M'): sexo = str(input('Digite o seu sexo (M/F): ')).strip().upper() if (sexo != 'F') and (sexo != 'M'): print('ERROR: Valor invalido.\n') if sexo == 'F': print('\nSeu sexo é feminino!') else: print('\nSeu sexo é masculino!')
20ebee4836d0ad64f1e7df7ecb963e931ce74d36
berrycam/PH_checkConfig
/src/main/listCompare.py
1,560
3.5625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # @Time :2018/8/24 # @Author :chenaimei # @Function :公共类,用于对比两个list from src.main.whiteList import WhiteList class ListCompare(): """ : """ def get_diff_list(self, java_list, json_list): """ :return:对比两个list,返回两个list的差集 """ ...
7195494004afd3ccff61aa18a4ca3cff7b549f74
AdrianoKim/ListaDeExerciciosPythonBrasilAdrianoKim
/PythonBrasil/3. Estrutura de repeticao/12. tabuada 1 a 10.py
423
4.0625
4
""" 10. Desenvolva um gerador de tabuada, capaz de gerar a tabuada de qualquer número inteiro entre 1 a 10. O usuário deve informar de qual numero ele deseja ver a tabuada. A saída deve ser conforme o exemplo abaixo: Tabuada de 5: 5 X 1 = 5 5 X 2 = 10 ... 5 X 10 = 50 """ num = int(input('Digite o numero :')) print('...
f9d1c5f8bb63daed77037cce4dc796a0ea5c09d6
rajdeepslather/Scraps
/Scraps/Python/py_scraps/hacker_rank/percentage_marks.py
559
3.921875
4
def avg(list): int_list = map(float, list) return sum(int_list)/len(int_list) def print_avg(student_marks, query_name): print "{:.2f}".format( round(next( avg(marks) for name, marks in student_marks.iteritems() if name == query_name), 2)) def main(): stude...
a599f495db67a6b0bf9da7dbdd82ff140986f94d
tillyoswellwheeler/module-02_python-learning
/ch03_functions-and-modules/ch03_tilly_test.py
1,779
3.640625
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 29 13:55:05 2018 @author: """ from ch03_tilly_functions import * #--------------------------------------------------------------------------------------- # CHAPTER THREE - Functions, returning values and importing modules #-----------------------------------------------...
a50354ef20d80503f6f0dfe048eae3c1b2cfb9b2
josehernandez168/Graphing-MK1
/Testing Files/3D Plot test/3D_test.py
1,773
3.640625
4
import matplotlib.pyplot as plt #-> from matplotlib import cm #-> This is important import numpy as np #-> This is important import math #-> mmm, this is not important # |-> I was not able to use functions #from this library to take the sine and cosine #of x2 and y2, perhaps because these are now #arrays whi...
f5c7312c1c072c0ed3fdcbe0b7094b58353060e1
Manishkumar21/My_Chat
/default_spy_detail.py
885
3.65625
4
# import datetime function from library so we can use current date and time. from datetime import datetime # defining or creating a class class Spy: # creating the constructor using __init__ def __init__(self, name, salutation, age, rating): self.name = name self.salutation = salutation ...
648710cad0b7d014ec1ca52778bb145170eb5a69
freebritneyspears/capitalsoftheworldquiz
/user_details_v3.py
885
4.125
4
# In this version I will be using if and else to fix errors found from program planner. #asking the user to enter their name. try: name=str(input("enter your name: ")) if name == "1234": raise Exception except: input("Please enter your name \n") #asking the user to enter the...
6cd051b101cc38b2673b4eac810c10f57700c1c1
HaoRay/kidspython
/ColorSpiral/ColorSpiral.py
350
4.25
4
import turtle colors = ['red','yellow','blue','orange','green','purple'] # sides=6 # changes 6 down to 2 s = input("Enter a number of sides between 2 and 6: ") sides = int(s) t=turtle.Pen() turtle.bgcolor("black") for x in range(360): t.pencolor(colors[x%sides]) t.forward(x * 3/sides + x) t.left(360/sides ...
8e3c5620a214e803d17c31d88ce6120d94400a58
ChangxingJiang/LeetCode
/LOCF_剑指Offer/Offer56II/Offer56II_Python_2.py
466
3.671875
4
from typing import List class Solution: def singleNumber(self, nums: List[int]) -> int: one = 0 # 每个数的状态的二进制的个位 two = 0 # 每个数的状态的二进制的十位 for n in nums: one = one ^ n & ~two two = two ^ n & ~one return one if __name__ == "__main__": print(Solution().si...
0041bae75f2cd9ce0d213e9921385e5620203a5e
aambrioso1/Miscellaneous_Python_Programs
/Writing to Files.py
596
3.78125
4
import os #Access the name of the current working directory and its contents path = os.getcwd() print('The current working directory and its contents are: ', path,os.listdir(path)) name=input('What is your name?\n') with open('names.txt', 'a') as f1: f1.write(name+'\n') with open('times.txt', 'a'...
7e4a5bb3d04907461582d7a438c5338eeed84a8b
Carrie2001/2020PycharmProjects
/2020PycharmProjects/autumncourse/guessNumber_guan01.py
688
3.53125
4
def guessNumber(): found = 2 high = 247483647 low = -247483647 ans = 0 while 1: mid = (high+low) // 2 print("您的数是这个么", mid,"?") found = eval(input( "如果和此数相等请输入0,大于此数请输入1,小于此数请输入-1\n")) if found == 0 or high == low: ans = mid if high...
f10034a790e87355f05f69e2df594b8478118f0b
irshadrasyidi/progjar11
/TM04/thread-1.py
276
3.515625
4
import threading import datetime class ThreadClass(threading.Thread): def run(self): now = datetime.datetime.now() print(self.getName() + 'says Hello World at time: ' + str(now) + '\n') for i in range(5): t = ThreadClass() t.start()
cacc8e8275506f2f948bcb5c459ea4caa30b4d65
smellvin42/Python-Projects
/Test.py
2,430
4
4
import random # a**2 >= 9 and not a>3 # prediction: false # a+2 ==5 or a-1 !=3 # 'Prediction: True' x, y = (325, 325) def age_limit_output(age): age_limit = 13 if age < age_limit: print(age, 'is below age limit') else: print(age, 'is old enough') print('minimum age is', age_limit) ...
92de8ccb8d55a649a5ba8a815133d15cbf52afd7
forever0136789/python-100
/python-68.py
317
3.734375
4
from collections import * #deque双向队列;两端都可以操作的序列,在序列的前后你都可以执行添加或删除操作。 la=[1,2,3,4,5,6,7,8,9] deq=deque(la,maxlen=len(la)) print(la) #把右边元素放在左边,参数为选右边的几个元素 deq.rotate(int(input('rotate:'))) print(list(deq))
58f1daf411c17e02f4934f28a1a2e8960dd2fbd6
StanislavMyakishev/Complete_MO1
/Part1/bisection.py
770
3.609375
4
import math a1, b1 = 0, 1.0 e = 0.0001 func_glob = lambda x: x ** 3 - x def bisection(a, b, f): text_file = open('../output/bis.txt', 'w') count = 0 while b - a >= e: x = (a + b) / 2 d = e/2 count += 1 x1 = x - d x2 = x + d s = ('%d iteration, f(x) = %f, x...
14084c01090ddcaef30b499a49db2b1ab15f8aef
jjerazo3/Proyecto-Bimestral
/Untitled.py
1,064
3.921875
4
#!/usr/bin/env python # coding: utf-8 # In[3]: h24=0 m24=0 h12=0 m12=0 periodo="a.m." print("Programa para convertir las horas en formato de 24h a formato de 12h") print("Ingrese la hora en formato 24h") h24=int(input()) print("Ingrese los minutos") m24=int(input()) if((h24 < 25) and (h24 >= 0)): if (((h24 <=...
58a1ebed07833735a63d530a07f6906162a441a6
NicolasKs/Solutions_Pyhon101_HackBulgaria
/week08/Graphs/deep_find_DFS.py
709
3.5
4
def deep_find(data, key): for curr_key in data: res = deeper(data[curr_key], curr_key, key) if res is not None: return res def deeper(data, curr_key, key): if curr_key == key: return data if type(data) == dict: return deep_find(data, key) if type(data) == ...
e5ec04e691511a50491381e166e49e7604ea2de2
nivedithahr/python-games
/guessgame3.py
450
4.125
4
answer = 5 print("Please guess number between 1 and 10") guess = int(input()) if guess != answer: if guess < answer: print("Please guess higher") else: #guess must be greater than answer print("Please guesss lower") guess = int(input()) if guess == answer: print("Well...
1a961ed580667fc8df48df10db4e5baf23815f89
SimeonFritz/ConnectProject
/submissions/Fritz/Example/play.py
1,384
3.515625
4
from connect4 import * def main(): """ Play a game! """ g = Game() g.printState() player1 = g.players[0] player2 = g.players[1] win_counts = [0, 0, 0] # [p1 wins, p2 wins, ties] exit = False while not exit: while not g.finished: g.nextMove() g.findF...
95626d3c8460b7ffcee0a8a64ac0ee91eef6105c
ongsuwannoo/PSIT
/Circular I.py
288
3.578125
4
''' Circular I ''' def main(): ''' input finction ''' me_x = float(input()) me_y = float(input()) rad = float(input()) mos_x = float(input()) mos_y = float(input()) print('Yes' if ((me_x - mos_x)**2+(me_y - mos_y)**2)**0.5 <= rad else 'No') main()
0601a8c8774bf0ed365e65b4e3e4e89925017ff5
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4171/codes/1644_869.py
306
3.5
4
# Teste seu código aos poucos. # Não teste tudo no final, pois fica mais difícil de identificar erros. # Use as mensagens de erro para corrigir seu código. preco = float(input("preco a ser pago: ")) if preco < 200: print(round(preco,2)) else: precoff = preco - preco*(5/100) print(round(precoff,2))
b253c4d731cc390033967817149210a682fa3f31
russo588/russo588.github.io
/old/teaching/samplescripts/rk4example.py
825
3.796875
4
#this script computes the solution for a differential equation using #4th order Runge Kutta. import math import matplotlib as mpl import matplotlib.pyplot as plt #intial conditions t0 = 0 y0 = 1 #defining the function def f(t,y): return -2 * y * t #stepsize h = 0.01 #end and start End = 2 Start = t0 #storing ...
259856fa53b75760ae2351c375b5c5b4c344ab5f
ranog/automatize_tarefas
/catnapping.py
546
4.09375
4
#!/usr/bin/env python print("""Dear Alice, Eve's cat has been arrested for catnapping, cat burglary, and extortion. Sincerely, Bob.""") """ Observe que o caractere único de aspas simples em Eve's não precisa ser escapado. Escapar aspas simples e duplas é opcional em strings multinhas. """ print(""" A chamada a pr...
1176b98a1d919c54ed7568b8cda807043ab3e5e8
rvladimir001/Python-Learning
/zadachki/stepik/1.12.1.py
2,082
3.5625
4
""" В то далёкое время, когда Паша ходил в школу, ему очень не нравилась формула Герона для вычисления площади треугольника, так как казалась слишком сложной. В один прекрасный момент Павел решил избавить всех школьников от страданий и написать и распространить по школам программу, вычисляющую площадь треугольника по ...
3704219d1474bb88c8f3102a2d2c86f3aad28ace
stojanovskit/day26_part2
/main.py
710
4.34375
4
import pandas # dict_nato = pandas.read_csv("nato_phonetic_alphabet.csv").set_index('letter').to_dict() # nato = input("What word you want to decode into Nato Phonetic Alphabet ? ").upper() # result = [] # for letter in nato: # if letter in dict_nato['code']: # result.append(dict_nato['code'][letter]) # pri...
799b5ef0bd2aac42d277bc12ba9ca6df494dd7eb
Neeharika-387/python
/repprint.py
61
3.734375
4
x=int(input()) i=1 while(i<=x): print("hello") i=i+1
0a402ce75a5a6effe12dccad97edaf4f00d24124
Micky143/LPU_Python
/Gobal-Local.py
121
3.609375
4
newV = 10 def square(Val): newV2 = newV ** 2 return newV2 print(square(3)) newV = 20 print(square(3))
59c0df465dbf02d157bdda0ddca06d20a90755dc
dominicdaviescodes/py-fundamentals
/Ex_Files/Exercise Files/Chap04/sec4ex.py
238
3.90625
4
print(17 < 17) # false print(15 == 3 * 5) # true print(15 <= 3 * 5) # true print("Frank" == "Sarah") # false age = 13 print(age != 10 ) # true age = 13 print(15 >= age + 2 ) # true """ prints False True True False True True """
2ae2f8c9087ed3caa8a1b2f3afbe56012152c9ea
jh136135/data_structure
/单链表及相关操作.py
1,366
4.0625
4
#定义单链表及相关操作 #自定义异常 class LinkedListUnderflow(ValueError): pass class Node(): def __init__(self, elem, next_=None): self.elem = elem self.next = next_ class List(): def __init__(self): self._head = None def is_empty(self): return self._head is None ...
80dccbceb92f2a9b75892ca7dc5236c1bb82be6f
rajatsharma98/CS677
/HW/lyndon97_8_1_8.py
1,235
3.59375
4
import os import pandas as pd import numpy as np wd = os.getcwd() input_dir = wd file_read = os.path.join(input_dir,"tips.csv") df = pd.read_csv(file_read) df['tip_percent'] = 100.0 * df['tip']/df['total_bill'] df_smoke = df[df['smoker'] == 'Yes'] df_nonsmoke = df[df['smoker'] == 'No'] # calculate cor [total_bill,...
9e9cc459ac2ef144b4e93d9e0d1f00f55732ef5d
raneffable/-Software-Engineering-IT1-BhetrandDwilangga
/main.py
958
3.84375
4
# variable # integer a = 2 b = 3 b = b + a # string animal = "Panda" # boolean c = True d = False # float e = 2.0 # List/Array f = [] # Dictionary g = {} # Tuple h = () # Print print("Bear") print(2 + 5) print(True) print(b) print("Nama Hewannya adalah : " + animal) # ini kalo pa...
1c0456c83d63ed29ee202242cdb7695cb18155dc
annamcheng/Codewars-Challenges-Python
/7kyu/odd_or_even.py
610
4.21875
4
""" Odd or Even? https://www.codewars.com/kata/5949481f86420f59480000e7/train/python Given a list of integers, determine whether the sum of its elements is odd or even. Give your answer as a string matching "odd" or "even". If the input array is empty consider it as: [0] (array with a zero). Input: [0] Output: "even"...
2cd26d82ac82175d9fcf2b7434065691f77fd35f
nym-jmorris/project_euler
/problem_026.py
1,688
3.71875
4
''' #problem 26 # A unit fraction contains 1 in the numerator. # The decimal representation of the unit fractions with denominators 2 to 10 are given: # 1/2 = 0.5 # 1/3 = 0.(3) # 1/4 = 0.25 # 1/5 = 0.2 # 1/6 = 0.1(6) # 1/7 = 0.(142857) # 1/8 = 0.125 # 1/9 = 0.(1) # 1/10 = ...
5d95a1f37dc3ae4085044b3983cbfc6b5f973bce
PriestTheBeast/RLRunner
/rlrunner/agents/base_agent.py
1,407
4.03125
4
from abc import ABC, abstractmethod class BaseAgent(ABC): """This class is the base agent that you should extend in order to create your own agents.""" def __init__(self, name=None): if name is None: self.name = self.__class__.__name__ else: self.name = name # add possible initial setup @abstractmet...
a4f79c6b5cf80995b050b2394944c6e5df72aa42
shraddha742/Covid-data
/covid data.py
1,495
3.625
4
#COVID DATASET #OBJECTIVE:TO PREDICT DEATHS DUE TO COVID #DATA COLLECTION #Import dataset import pandas as pd data=pd.read_csv('D:/covid data1.csv') #DATA CLEANING #Delete the useless data from dataset #in this dataset 'S.No' is unwanted data.drop('S. No.',axis=1,inplace=True) #DATA ANALYSIS #COUNTPLOT #To determin...
7241716d095b13a4412e935e83f76cdb40959fc4
jkbockstael/leetcode
/2020-04-month-long-challenge/day17.py
1,838
4.09375
4
#!/usr/bin/env python3 # Day 17: Number of Islands # # Given a 2d grid map of '1's (land) and '0's (water), count the number of # islands. An island is surrounded by water and is formed by connecting adjacent # lands horizontally or vertically. You may assume all four edges of the grid # are all surrounded by water. ...
f136d40f6c92276dab131e3eb8d6bac198d1c372
barzgara71961/Quiz
/quiz_with_buttons.py
7,706
3.640625
4
from tkinter import * from functools import partial # To prevent unwanted windows import random class Quiz: def __init__(self): # Formatting variables... background_color = "#8FF7A7" # Converter Main Screen GUT... self.quiz_frame = Frame(width=500, height=500,bg=background_colo...
c980f552e83235c1908d365b02b0311df759499c
sturlaf/stochastic-modeling
/Project 1/project1 problem2.py
1,902
3.6875
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 25 16:20:45 2019 @author: Sturla """ import numpy as np import matplotlib.pyplot as plt days = 59 #Days between 1.jan - 1.mars lambd = 1.5 #The parameter in the poisson process def sim_poisson(): '''Simulates the poisson process''' process_time...
254dabbbc291f3001594ca6ff9349e4c45d21800
yoanngi/codingame
/the-descent.py
940
3.9375
4
import sys import math # The while loop represents the game. # Each iteration represents a turn of the game # where you are given inputs (the heights of the mountains) # and where you have to print an output (the index of the mountain to fire on) # The inputs you are given are automatically updated according to your l...
d9ac9544967e3b888a3c6b7c79578ee0b6d54f52
haiyan858/learn-python-demo
/python3_tutorial/define_function_practice.py
6,400
4.09375
4
# define_function_practice.py # 2018年 03月 21日 星期三 10:39:01 CST # 位置参数 # 位置参数 # 位置参数 # 计算x2的函数: def power(x): return x*x # 对于power(x)函数,参数x就是一个位置参数。 power(5) # 如果要计算x4、x5……怎么办?我们不可能定义无限多个函数。 # 可以计算任意n次方: # 修改后的power(x, n)函数有两个参数:x和n, # 这两个参数都是位置参数,调用函数时,传入的两个值按照位置顺序依次赋给参数x和n。 def power(x,n): s = 1 while n>0: s =...
1fb04fa9846d6e346e2226999c6d297ffddb2169
JMtifr/Comp-Assignment-2
/A2_5.py
2,701
3.515625
4
#Assignment 2 # Problem 5 #y"=-10 # bc :: y(0)=0, y(10)=0 # p=y', y"=p' # We solve this problem by shooting method and assume that we don't know behaviour of y(x) with initial y' import numpy as np import matplotlib.pyplot as pt def es(x): # exact solution return(-5*x*x+50*x) def dp(x,y,p): # this function return ...
f86b07d599909213aa3b299d4b73f0ae73994ed9
mrwtx1618/py_all
/break的用法是跳出整个循环.py
327
3.9375
4
# -*- coding:UTF-8 -*- for x in range(1,11): print x if x == 6: break #这里break之后,后面的else语句的内容就不执行了,因为这里程序是非正常结束的。所以不执行else下的语句。 print '*' * 10 else: print 'ending' for x in range(1,11): print '----------------->',x
3f1f068d1d557358a42db8bbb9534e5236e2f0f9
SubrataSarkar32/college3rdsem3035
/class12pythoncbse-master/Chapter 4/Question5.py
1,123
3.65625
4
class Bowler: def __init__(self): self.fname='' self.lname='' self.oversbowled=0 self.noofmaidenovers=0 self.runsgiven=0 self.wicketstaken=0 def inputup(self): self.fname=raw_input("Player's first name: ") self.lname=raw_input("Player's last name: ...
c0fa050c96089532863a3ec2163a224a01079747
ZachW93/Python-Projects
/DailyProgrammer/leetcode/30-Day Challenge/Day9-BackspaceStringCompare.py
512
3.78125
4
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: def backspace(word): length = len(word) result = '' i = 0 for j in range(length - 1, -1, -1): if word[j] == '#': i += 1 elif i ...
23576838b757a73c6e2860da9ea1d56fb85d3833
Okle/interview_prep
/apple_stock_profit.py
2,104
3.921875
4
print('Start') # O(n^2) def get_max_profit(stock_prices): # Return maximum profit from stock purchases/sales profit_arr = [] for buy_index, buy_price in enumerate(stock_prices): for ind, sell_price in enumerate(stock_prices, start=buy_index): profit_arr.append(sell_price - buy_price) ...
a3a9d0dbf44224a165b0f0c131e8be233e575349
r2dtu/AdventOfCode2016
/Day 21/Day21.py
3,508
3.875
4
baseds = [] def rotate(str, num, scrambled): return str[num:] + str[:num] if not scrambled else str[-num:] + str[:-num] # scrambled - is input scrambled? we must unscramble def getScrambled(passcode, content, scrambled): if scrambled == True: content.reverse() for instr in content: if 'rotate' in instr: i...
273552fd82031ba8a168ce8c868d92751e57fcd1
halibutsushi/primes
/improved2.py
701
3.53125
4
def get_primes(n): prime_list = [] n = 1000000 # n = 100 for i in range(n): if i == 0 or i == 1: continue is_decided = False for prime in prime_list: if i % prime == 0: is_decided = True break if prime * prim...
565df863a37ca2e7f40a6d4ba11e12b54a191bdb
sanujkul/Artificial-Intelligence
/05b2_hillClimbing_8queens.py
8,751
4.28125
4
from graphics import * import time; n = 8; # number of queens #emptyPlaces = []; #Following is position where queens will be placed queensPositions = ["",(2,1), (2,3), (3,8), (4,3), (5,2), (6,3), (7,2), (8,3),]; queensPColors = ["",'red', 'blue', 'yellow', 'green', 'orange', 'pink', 'magenta', 'violet']; grid_side =...
88ec1623a86df7169585f59ff851a0567d43882f
hpoleselo/effectivenotations
/epython_src/argument_parser.py
1,261
3.65625
4
import argparse def parser(): # In order to run this function we have to execute the python file as: # python effectivepython.py -d alvar # Because -d is an optional argument and by not giving it to the program the parser parses nothing. class Parser(object): def __init__(se...
26867efdf2a42bd4298b370ba4ad5d7b12b4e063
ewartj/cs50_2020
/week7/houses/import.py
1,161
3.796875
4
import pandas as pd from sys import argv, exit import sqlalchemy def main(): if len(argv) != 2: print("Please provide a csv file") exit(1) df = pd.read_csv(argv[1]) # split the full name into seperate names first_name = [] second_name = [] last_name = [] full_name = df.name.tolist() for i in r...
64095c635b0cd7a30017e726e501ba8802a71236
akorott/2-Player-Pong-Game-Python
/2P_Pong.py
3,381
3.65625
4
import turtle import winsound wn = turtle.Screen() wn.title('Pong') wn.bgcolor('khaki') wn.setup(width=600, height=800) wn.tracer(0) # 1st Player Paddle paddle_1 = turtle.Turtle() paddle_1.speed(0) paddle_1.shape('square') paddle_1.color('black') paddle_1.penup() paddle_1.shapesize(stretch_wid=1, stret...
62a0b25894a26a0011aece8cd646d1807cf83f64
AwesDea/Smart-Green-House
/RPi/rpi.py
1,799
3.5
4
# RPi code import time import RPi.GPIO as GPIO import paho.mqtt.client as mqtt # Configuration: # Initialize GPIOs GPIO.setmode(GPIO.BCM) # Setup callback functions that are called when MQTT events happen like # connecting to the server or receiving data from a subscribed feed. def on_connect(client, userdata...
e561b387fea986ffb5ddd84bad0470fac67183f5
amitdshetty/PycharmProjects
/PracticePythonOrg/Solutions/07_List_Comphrehensions.py
1,240
4.15625
4
""" Problem Statement Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it. """ def main(): a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] print("Input \...
db9f52be56e30fb1101e99d689cc3695e81991ac
ysx001/project_euler
/python/p_004.py
785
3.84375
4
# Project Euler # Problem 4 # A palindromic number reads the same both ways. # The largest palindrome made from the product of # Find the largest palindrome made from the product of two 3-digit numbers. # http://articles.leetcode.com/palindrome-number/ # Check is Palindrome for a number by reversing it # Have the...
87fdc153298c4cb0327a517558d408497efad990
legenove/MyLearn
/user_system/user_system_1.py
5,078
3.65625
4
# -*- coding: utf-8 -*- # 用户登录系统 # 1. 用户信息保存在一个user_file里,name, password, email, intro # 2. 文件的行数即为 用户的uid # 3、用户可登录,用户可以修改信息, 修改需要验证密码 # 4、用户可以登出 # 5、用户可以删除自己, 需要验证密码 # 6、程序启动时读取全部用户 # # 作业: 补充新增用户,修改用户,删除用户时对文件的操作 # 选做题:写一个class User,使用User来记录每一条数据 class User(object): def __init__(self, uid, name, password, ema...
0895257837a25e1418b9421f208be9f288a97e11
kobeomseok95/codingTest
/programmers/level1/64061.py
529
3.65625
4
def get_doll(board, idx): for i in range(len(board)): if board[i][idx] != 0: doll = board[i][idx] board[i][idx] = 0 return doll return 0 def solution(board, moves): answer = 0 bucket = [] for m in moves: doll = get_doll(board, m - 1) if ...
62b1a0c494c3c4f13192bec6cd15b3f284f81bc9
benjamn/project-euler
/42.py
587
3.5625
4
from util import * from words import words def trig(n): return n*(n+1)/2 def trigs(): i = 1 while 1: yield trig(i) i += 1 triangles = set(bound(trigs(), 1000)) @memo def chval(ch): return "_abcdefghijklmnopqrstuvwxyz".find(ch) @memo def wval(word): word = word.lower() return...
788b55d280901a718ad1d5ddbbbf679ee9817d28
patricklink05/potential
/dumbellproject2.py
1,636
4.125
4
import random import math import string scale = 4 #this is used to scale the end result, the larger the n, the larger the end shape is number=1 #this is used to set how many points we generate for each shape, the higher this is, the more points class cylinder: def __init__(self,scale,number,center): self.scale = sc...
31596af21acd4c609ce76fa90d8ca0e8a3d43a4b
stubear66/600X
/FingerExercises/finger2.2.py
248
3.609375
4
L = [ 51, 19, 3] myMax = 0 for x in L : if x % 2 == 1 : print myMax if x > myMax: print "Setting myMax to ", x myMax = x if myMax > 0: print "Largest odd is ", myMax else: print "No odds"