blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
eb41298d298fba902e2b098f03a6da6003e3b22d
jacindaz/algos_practice
/tests/test_ordered_list.py
1,401
3.703125
4
from algos.unordered_list import Node, UnOrderedList from algos.ordered_list import OrderedList def test_search(): list1 = OrderedList() list1.add(1) list1.add(20) list1.add(14) list1.add(58) list1.add(30) assert list1.size() == 5 # [1, 14, 20, 30, 58] assert list1.search(14) a...
53bf9da6479ece578681c89fb91ce068f3f92ce6
HeDefine/LeetCodePractice
/Q11.盛最多水的容器.py
1,365
3.515625
4
#!/usr/bin/env python3 # https://leetcode-cn.com/problems/container-with-most-water # 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。 # 在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。 # 找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 # # 说明:你不能倾斜容器,且 n 的值至少为 2。 # # 示例: # 输入: [1,8,6,2,5,4,8,3,7] # 输出: 49 # class Solution: # 暴力法 ...
cafb5aeda141443754ac405cd15acc3ad60eef47
vishalsingh8989/karumanchi_algo_solutions_python
/Dynamic Programming/coin_change2.py
355
3.6875
4
""" how many ways can we make the change? The order of coins doesnt matter. """ def count(S, n): table = [0]*(n+1) table[0] = 1 for i in S: for j in xrange(i, n+1): table[j] = table[j] + table[j - i] print(table) return table[n] arr = [1,3,5,7] m = le...
0fccf7212741d37de319240a0957023519f1cee7
haruki96/ch12
/cha12.3.py
238
3.75
4
class Triangle: """docstring for Triangle""" def __init__(self, bottom, hight): self.bottom = bottom self.hight = hight def area(self): return self.bottom * self.hight / 2 triangle1 = Triangle(10, 10) print(triangle1.area())
7c8d1c98423ee1839302522f2071155f1f7cfd98
gkanishk44/Python-Projects
/rockpaperscissors.py
2,113
3.828125
4
from tkinter import * import random root = Tk() root.geometry('400x400') root.resizable(0,0) root.title('DataFlair-Rock,Paper,Scissors') root.config(bg ='seashell3') Label(root, text = 'Rock, Paper ,Scissors' , font='calibri 20 bold', bg = 'violet').pack() user_take = StringVar() Label(root, text = 'choose any one...
354cc72868ea0eec07710fb21af448d32f8005ab
LiuDezi/pyDANDIA
/pyDANDIA/utilities.py
1,291
3.765625
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 21 15:16:11 2018 @author: rstreet """ import numpy as np def d2r( angle_deg ): """Function to convert an angle in degrees to radians""" angle_rad = ( np.pi * angle_deg ) / 180.0 return angle_rad def r2d( angle_rad ): """Function to convert an angle...
b102fa68966d9bb9e1654ab187487f71e7a85e92
tahmid-tanzim/problem-solving
/Two_Pointers/valid-palindrome.py
1,679
4.03125
4
#!/usr/bin/python3 # https://leetcode.com/problems/valid-palindrome/ def isPalindrome(s: str) -> bool: """ Time - O(n) Space - O(n) """ newStr = str() for c in s: if c.isalnum(): newStr += c.lower() return newStr == newStr[::-1] def isAlphaNumeric(c: str) -> bool: ...
f201abe0fd5012a61b2e9b101e17197a97870801
CodeMycole/Rock-Paper-Scissors
/rockpaperscissor.py
1,253
3.96875
4
import random #Game repeater play_again = 'yes' while play_again == 'yes': choices = ['rock', 'paper', 'scissors'] player_choice = input('Choose rock, paper, or scissors: ') player_choice = player_choice.lower() computer_choice = random.choice(choices) #function for deciding winner def choos...
a5d321e07ccbe60c0cae2cb1b1957cf55cf909dc
lrrieke/class-work
/ordinal_numbers.py
241
4
4
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] if number in numbers >= 1: print( str(number) + "st") elif number in numbers >= 2: print( str(number) + "nd") elif number in numbers >= 3: print (str(number) + "rd") else: print( str(number) + "th")
ad6584d1bf0f926a8b2b34e22ea8e94fbca552aa
zwlsky13/pycharm
/py3/test01/py3_generator.py
1,282
3.71875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @version: Python 3.6.2 @author: zwl @Project: py3 @file: py3_generator.py @time: 2017/9/10 21:55 """ # s=(x*2 for x in range(100000000000)) # print(s) #generator object # print(next(s)) #等价于s.__next__() 在py2里面 # print(next(s)) # def foo(): # print('ok') # ...
d6dcae9dddf08f00e4ea8e3a93bc58d1e0f1e1d0
IvanWoo/coding-interview-questions
/puzzles/k_inverse_pairs_array.py
1,594
3.84375
4
# https://leetcode.com/problems/k-inverse-pairs-array/ """ For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j]. Given two integers n and k, return the number of different arrays consist of numbers from 1 to n such that there are exactly k inverse...
f4cbafd7af0c9622315acdca2f830b6b6cfc8163
brotheroak/PythonStudy
/pythonstudy/function5.py
212
3.53125
4
def root(a, b, c) : r1 = (-b + (b ** 2 - 4 * a * c ) ** 0.5) / (2 * a) r2 = (-b - (b ** 2 - 4 * a * c ) ** 0.5) / (2 * a) return r1 x = 1 y = 2 z = -8 r = root(x,y,z) print('근은 {}'.format(r))
d5b016967f69bcf8be9ffff05e0d08b4eeed2eb3
Arwen0905/Python_Test
/0603/a0603_ex_Class用法測試.py
350
3.625
4
class Animal(): def __init__(self, name, age, version): self.name = name self.age = age self.version = '寫了就變固定資料' a = Animal("dog",27,'無法設定了') #建立一個名叫dog的Animal實體(物件) b = Animal("老師",'35','5.0.1') print(a.name) print(a.age) print(a.version) print(b.name) print(b.age) print(b.version)
6e3706a92081acd72a6b5012bd7aa98b10e411b1
rivwoxx/python-Le
/oldstuff/2.py
156
3.765625
4
def divstr(string): li = list(string.split(" ")) return li a = input("write something here: ") b = divstr(a) print(b[2]) for i in b: print(i)
472e0875551f1855d33259768ebf793cdb357bef
dgaeck/python_lessons
/lesson 2.3.py
137
3.796875
4
# This first line is provided for you hrs = input("Enter Hours:") rate = input("Enter Rate:") pay = float(rate) * float(hrs) print(pay)
363be17c7fdc2ccf01cc772411ce1a7d51949de3
myTestingAcct/pythonTutorial
/madlibs.py
200
3.5
4
color = input("Enter a Color") plural_noun = input("Enter a Plural Noun") celebrity = input("Enter a Celebrity") print("Roses are", color) print("Roses are", plural_noun) print("I love", celebrity)
d97aa44c3495503680de2e93621afe1c147b643a
wy-wangyao/code_lib
/spider/zhihu_file.py
1,394
3.546875
4
# 爬取知乎发现页面,用文件存储 import requests from pyquery import PyQuery as pq def get_html(url): '''根据网址获取html页面 parameter:url目标网址 return:html页面 ''' headers = { 'User-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/67.0.3396.99 Chrome/67....
76c92bb7296b181d781c502a65a9b36d4771b66b
rupol/Hash-Tables-Lecture
/src/ht3/cipher.py
1,185
4.0625
4
# substitution ciphers # or, how to transform data from one thing to another encode_table = { 'A': 'H', 'B': 'Z', 'C': 'Y', 'D': 'W', 'E': 'O', 'F': 'R', 'G': 'J', 'H': 'D', 'I': 'P', 'J': 'T', 'K': 'I', 'L': 'G', 'M': 'L', 'N': 'C', 'O': 'E', 'P': 'X', ...
812e6d573be194eee3f7e8ed79d49e76cc71c239
6jk/MyPythonLearning
/基础python学习/Afunction1.py
1,375
4.09375
4
#函数指可以重复使用的程序片段 def sayHello(): print('hello') sayHello() sayHello() #带参数 def printMax(x,y): if x == y: print('x isEqual to y') elif x < y: print(y,'is maximum') else: print(x,'is maximum') printMax(2,6) #局部变量 x = 1 def func(x): print('x is',x) x = 2 print('change ...
0b437b6cbebd3f98e36bc5099e4cf94806f24a8c
friendoye/Masters-Algo-Course
/Python/Lab2/special_sum.py
147
3.53125
4
def calculate_special_sum(n): return sum([x * (x-1) for x in xrange(1, n + 1)]) if __name__ == "__main__": print calculate_special_sum(2)
91982cd94c40b29fbdc84201708cbed7b54fb14c
Flash1ee/ca-labs-4th-sem-bmstu
/lab_04/src/utils.py
879
3.59375
4
from __future__ import annotations class Point: x: float y: float weight: int def __init__(self, _x: float, _y: float, _weight: float) -> None: self.x = _x self.y = _y self.weight = _weight def __str__(self): return "{:^8.3f} {:^8.3f} {:^8.3f}".format(self.x, self...
f46fdf1ccc4f6f418b129b31807bffa30c96b54a
SaitoTsutomu/leetcode
/codes_/0011_Container_With_Most_Water.py
615
3.640625
4
# %% [11. **Container With Most Water](https://leetcode.com/problems/container-with-most-water/) # 問題:2つの棒を選び、その間に水を入れる。最大の水の量を返す # 解法:両端から調べる。短い方は内側に移動して良い。 class Solution: def maxArea(self, height: List[int]) -> int: maxarea = 0 lf, ri = 0, len(height) - 1 while lf < ri: maxare...
a816e19e07442843d8b3a90ddb9b243fc412f6ec
Shumpy09/practicepython.org
/4-divisors.py
148
3.765625
4
number = int(input("Podaj liczbe: ")) divisors = [div for div in range(1,number+1) if number % div == 0] print(f"Divisors of {number}: {divisors}")
5301be9e4f716ce2ce061e54b8e62c5901808287
Lakshmikanthaks/Python-Literate
/fep58.py
501
3.609375
4
def findExtremeDivisor(n1, n2): """ Assumes that n1 and n2 are positive ints Return a tuple containing the smallest common divisor > 1 and the largest common divisor of n1 and n2""" divisors = () minVal, maxVal = None, None for i in range(2, min(n1, n2) + 1): if n1%i == 0 and n2%...
7b4ad6a0f0c2535b4037a56cf8834aee031374b0
xyf3333/DisasterResponsePipeline
/data/process_data.py
2,893
3.6875
4
import sys import re import sqlite3 import pandas as pd import numpy as np import sqlite3 def load_data(messages_filepath, categories_filepath): ''' INPUT: messages_filepath - the csv file provide messages data. categories_filepath - the csv file provide categories data. OUTPUT: dataframe ...
0f692ae1efab43c017eda75038cc16b048032e9d
nahida47/student_projects
/Self_IntroductionPy/Week4/010.py
1,782
3.578125
4
def compChooseWord(hand, wordList, n): # Create a new variable to store the maximum score seen so far (initially 0) scoreMax=0 # Create a new variable to store the best word seen so far (initially None) wordBest=0 # For each word in the wordList for eachword in wordList: if isValidWord...
3764bec2a8672d949e13812460a5cd35267859dc
jsoto3000/angela-yu-100-days-python
/day-018/tim_random_walk.py
564
3.734375
4
########### Challenge 4 - Random Walk ######## # https://en.wikipedia.org/wiki/Random_walk import turtle as t import random tim = t.Turtle() tim.shape("turtle") tim.color("blue") colours = ["CornflowerBlue", "DarkOrchid", "IndianRed", "DeepSkyBlue", "LightSeaGreen", "wheat", "SlateGray", "SeaGreen"] directions = [0...
d5fb801a60aed82d478163a20fc87364a4ff35cf
shilpa2020/python-1
/66.py
118
3.71875
4
num=int(input()) cnt=0 for i in range(2,num): if(num%i==0): cnt=cnt+1 if(cnt<=0): print("yes") else: print("no")
611e40c507cd1b13ed510ca77d2fb1cadb5cdf1a
omri143/next-py-course
/Unit1-OneLiner/Exercise114.py
355
3.671875
4
import functools def sum_of_digits(number): return functools.reduce(sum_digits, export_digits_to_list(number)) def export_digits_to_list(number): lst = [] while number > 0: dig = number % 10 number = int(number / 10) lst.append(dig) return lst def sum_digits(a, b): retu...
5b3655b53d8bab14fa47b8de31eead61a4a36804
Yanboding/Gomoku
/MyGomoku.py
6,506
3.75
4
from Game import * def initial_board(size): board = [] for i in range(size): row = [] for j in range(size): row.append(0) board.append(row) return board def max_heapify(A, i): ''' This function can maintain heap property of A ''' l = 2*i+1 r = 2*i+2 ...
3f63e83dbb10c2ac1b815706209e4f4284b152ac
czs108/LeetCode-Solutions
/Hard/72. Edit Distance/solution (1).py
1,119
3.5
4
# 72. Edit Distance # Runtime: 216 ms, faster than 29.11% of Python3 online submissions for Edit Distance. # Memory Usage: 17.6 MB, less than 15.38% of Python3 online submissions for Edit Distance. class Solution: # Dynamic programming def minDistance(self, word1: str, word2: str) -> int: len1, len2...
6f0373c0c91d4f81575bc93c22ea43288272b967
amrkhailr/python_traning-
/Week5_/exo24.py
1,936
4.625
5
#12. Rock, Paper, Scissors Game Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. #If the number is #1, then the computer has chosen rock. If the numb...
6851446eb81d4841cc1fee95142c0a9c0dba7c94
camarly/Passwordchecker_python
/validator.py
1,321
4.59375
5
print("Welcome to the Password Validation Tool.\n") print(""" These are the password requirements: • A password must have at least eight characters. • A password consists of only letters and digits. • A password must contain at least two digits. """) user_pwd = input("Enter a password to validate or type the word 'EXI...
8373b9d1afa377ad55151096dd5665d4276d98f1
colabearwd/CodingQuiz
/Program2019/0825_GenShuiXue/P08.py
385
3.65625
4
from math import sqrt def prime_list(N): res = [p for p in range(2, N) if 0 not in [p % d for d in range(2, int(sqrt(p)) + 1)]] return res if __name__ == '__main__': num = 100 res_list = prime_list(num) for i in res_list: other = num - i if other in res_list: prin...
9bc625a9abb86aa56d347623d8bfad3d01ca6498
crenault73/training
/python/tutograven/src/06_fonction/cre_voyelles.py
667
3.796875
4
# Tp: une fonction pour calculer le nombre de voyelles dans un mot # definir une fonction get_vowels_numbers(mot) # créer un compteur de voyelles # pour chaque lettre du mot vous vérifier s'il s'agit d'une voyelle # à la fin de la fonction, vous allez renvoyer le compteur vowels = ["a", "à", "ä", "â", "e", "é", "è", "...
5ee3e2565bdc074d08bbb3a3b02fe1ee282405cc
HariKumarValluru/Python
/Variables/variables.py
1,339
4.125
4
greeting = "Hari" _myName = "Naga" Hari24 = "Venkata" Hari_Kumar = "Anil" Greeting = "Hello" print(Greeting + ' ' + greeting) age = 27 print(age) #print(Greeting + age) # data types a = 12 b = 3 print (a+b) print (a-b) print(a*b) print(a/b) print (a//b) # if we want to trun the value into integer we use // print(a%b)...
bd0c291c33915307bae6f0d1a9e7a6221c4c9c82
nicolaespinu/LightHouse_Python
/spinic/Day21.py
1,845
3.609375
4
# Challenge # Dot wants to play retro video games with all their new friends! Help them figure out which games would be best. # Questions: # What is the correlation coefficient between Critic_Score and User_Score? # Note: You may have to clean some of the columns and fill it with the median value (if numerical). # Plot...
a8311d5e4d378da99b91686728f9d72fc41293a8
zhaohanson1/higher-or-lower
/bot_player.py
3,908
3.65625
4
import double_or_nothing_util as dnUtil import sys import math class BotPlayer: def __init__(self): self.resetBot() def resetBot(self): """Set up the bot for the beginning state of the game""" self.state = [None, None, None, False] self.score = 0 counts = {} f...
c3a1b969d6f23f8088bc3170e91f8b6d5874a09d
biao111/learn_python2
/chapter01/chapter06/test_decorator3.py
925
3.515625
4
def log(name = None): #装饰器的参数 '''记录函数执行的日志''' def decorator(func): #传入函数 def wrapper(*args,**kwargs): #带参函数需要传入*args,**kwargs print('{0}开始执行'.format(name)) print(args) print(kwargs) ...
cf560693137a25fc4f2e4f6226ed8b2f4b1da133
masankar666/Python
/area_of_triangal.py
206
3.921875
4
# sides of a triangle a = 3 b = 4 c = 5 # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is', area)
c66edd0ca9b07d116ebc063a13d714fa56ad8be9
xcmdManiac/Minesweeper
/main.py
1,597
3.53125
4
from random import randint print("\n\n||----||MINESWEEPWER||----||") SPOT1 = 1 SPOT2 = 2 SPOT3 = 3 SPOT4 = 4 print("\n\n",SPOT1,SPOT2,"\n",SPOT3,SPOT4) mine = "M" picker = randint(1, 4) if picker == 1: SPOT1 = mine elif picker == 2: SPOT2 = mine elif picker == 3: SPOT3 = mine elif picker == 4: SPOT4 = m...
ad6cbe3ae4d13d2a29f2f91fd1b3ce8e69933fbe
afcarl/dataStructuresTalk
/simply_linked_list.py
336
3.734375
4
class Node: def __init__(self,item,next=None): self.item = item self.next = next def __str__(self): return repr(self.item) root = Node(0) curr = root for i in xrange(1000): node = Node(i) curr.next = node curr = curr.next curr = root while curr != None: print curr c...
e9900fca6e84692ce976efe729b8f4816ffe6826
Kabir12401/FIT1008
/Prac 1/task3.py
2,197
4.25
4
def print_menu(): """ :return: no return :raises: no exceptions :complexity: best case O(1) worst case O(1)""" print('\nMenu:') print('1. Decimal to HexaDecimal') print('2. Decimal to Binary') print('3. quit') def dec_to_bin(number): """ :param number: a decimal value ot be co...
934a109c32f56cb4d193422e38125f9af5875289
ctam4/csc645su20-ctam4
/labs/lab4/client_handler.py
3,792
3.5625
4
######################################################################################################################## # Class: Computer Networks # Date: 06/30/2020 # Lab4: Threading clients in server side # Goal: Learning Networking in Python with TCP sockets # Student Name: Calvin Tam # Student ID: 917902523 # Stud...
bc84b066fce422288a4ef92ba25df81d34b2297d
vmsgiridhar/DSHackerRank
/Python_Prac/Prac1.py
281
3.890625
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 17 18:10:37 2018 @author: C5232886 """ class A: def __init__(self,a,b): self.a = a self.b = b def printmul(self): print( self.a * self.b) obj = A(10,15) print(obj.printmul())
4a9628e49a7d6127ddefb7b3e6a28ba325777501
shayhan-ameen/Beecrowd-URI
/Beginner/URI 1051.py
326
3.859375
4
salary = float(input()) if 0<= salary <= 2000: tex = -1 elif salary <= 3000: tex = (salary-2000) * 0.08 elif salary <= 4500: tex = (1000 * 0.08) + ((salary - 3000) * 0.18) else: tex = (1000 * 0.08) + (1500 * 0.18) + ((salary - 4500) * 0.28) print('Isento') if tex == -1 else print(f'R$ {tex:...
76be77bc56cd25f0caa4f3318e92039bfeabb77d
AdamZhouSE/pythonHomework
/Code/CodeRecords/2408/60618/267686.py
231
3.515625
4
n=int(input()) count=0 for i in range(2,n+1): for j in range(2,int(n**0.5)+1): if i%j==0: count+=1 sum=0 for i in range(1,count+1): sum=sum*i if n==1 or n==2: print(1) else: print(sum%(10**9)+6)
9afd422ed136956fcc919298fe9be1058ab544ba
VSmith21/CTI110
/P2T1_SmithVondre.py
296
3.703125
4
#CTI-110 #P2T1 -Sales Prediction #Vondre Smith #2.13.18 # #Get the projected total sales. total_sales=float(input("Enter the projected sales: ")) #Calculate the profit as 23 percent of total sales. profit= total_sales * .23 #Display the profit. print ("The profit is $", profit)
b20ff0ab77c04bc04e94a59777e17b15db2b7fb1
zhaoxinlu/leetcode-algorithms
/lintcode/07BinaryTree/066BinaryTreePreOrder.py
1,300
4
4
# -*- coding: utf-8 -*- """ Editor: Zhao Xinlu School: BUPT Date: 2018-03-04 算法思想: 二叉树的前序遍历 """ """ Definition of TreeNode: """ class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None class Solution: """ @param: root: A Tree @return: Preorder in ArrayL...
9fde7788f20c932241c15cd9d82d5cd5cdb4910a
zxhubo/xdebug-solidity
/xdebug/utils/parser_util.py
1,212
3.6875
4
# -*- coding:utf-8 -*- # Author: bobby def parse_string_2_pc_opcode(string): list_string = str(string) pc = "" opcode = "" value = "" l = list_string.split(" ") if len(l) == 3: pc = l[0] pc = pc[:-1] opcode = l[1] value = l[2] elif len(l) == 2: pc =...
f8ff1a11f9c0c0acfae666c730185b079b364f94
akashjakkula/class
/armstrong.py
340
4.21875
4
print("**ARMSTRONG NUMBER OR NOT**") num=int(input("enter a number")) temp=num digits=0 s=0 while num: digits+=1 num=num//10 num=temp while num: rem=num%10 s=s+rem**digits num=num//10 if temp==s: print(temp," is a armstrong number") else: print(temp,"is not a armstrong nu...
d3d13fb835ccdeaf83d254ed75b40d5b98fcca78
mishidemudong/mudong_leetcode
/判断是否为子序列.py
417
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 9 16:18:18 2021 @author: liang """ ''' 几个关键点: 1 两个指针分别指向两个字符串,i只有相等时才前进, j指针每一步都前进 2 假设 ''' def isSubsequence(s, t): i,j = 0,0 while i < len(s) and j < len(t): if s[i] == t[j]: i += 1 j += 1 r...
0cd5386fd0838bafae4aa15559d58e4976f130c2
StefanNijssen/functions-tryout
/Namen.py
160
3.71875
4
naam = input("Wat is uw naam?") leeftijd = input("Wat is uw leeftijd?") def info(): print("Hallo " + naam + " je leeftijd is " + leeftijd + " jaar.") info()
9d886675e7dee5113ec8bd01dd22e09ee71f6a64
eric-baack/cs160
/exercises/stacks/stacks.py
4,720
3.921875
4
#!/usr/bin/env python3 """Stack exercise""" from pythonds3.basic import Stack ## CS 160. E Baack, March 2019 ## Initial implementation was easy. Challenge in implementing try / except ## Test module tested multiple functions - including do_math class StackError(Exception): """Stack errors""" def __init__...
2a79a3c4e33c9cffba94733573307cfba87eeaf3
jokasimr/utils
/scripts/alpha_beta_pruning.py
1,380
3.640625
4
from random import randint ''' Necessary properties of node node.terminal: return true if the node is a final node (if it has no children node.value: returns the value of the node (this is what we are maximizing) node.__iter__: returns the children of the node ''' class NodeExample: def __init__(self, value, ch...
da44226fb3056b90718c58b9119f52e536702a9e
vijay-Jonathan/Python_Training
/bin/20_file_operations.py
5,500
4.1875
4
""" Till now, we were storing data in a varaible and displaying output in shell/console. Now, We will write a program to interact with external file (any text file(not excel file and all) extension like .txt,.csv,.log etc) Program --Communicate (READ/WRITE)--> External file Steps: Step-1 : Connect to file (open func...
0713a91eadd41b14b6b46709492aab59d4ace926
xlr10/pyton
/190728/190728_04.py
402
3.8125
4
# set # 중복, 순서 x from copy import copy print("Set") print() set1 = set("hello") print(set1) tu1 = tuple(set1) print(tu1, tu1[0], tu1[2]) s1 = set([1, 2, 3, 4, 5, 6]) s2 = set([4, 5, 6, 7, 8, 9]) print(s1 & s2) print(s1 | s2) print(s1 - s2) # bool b1 = [1, 2, 3, 4] while b1: print(b1.pop()) b2 = copy(b1) prin...
b25b91b379a001918a77f337989cdf8628fd169d
charliecharlieO-o/grokking-nn-study
/chapter3/ex2.py
705
4.125
4
""" Making a prediction with multiple inputs what does it do? - multiplies three inputs by weights and sums them - this is a weighted sum (DOT PRODUCT) """ weights = [0.1, 0.2, 0] def w_sum(a, b): # Performing a weighted a sum of inputs assert len(a) == len(b) output = 0 for i...
40cf8570470c78045119e54f4e4236c431e083bf
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/criar-ler-arquivos.py
538
3.78125
4
# try: # file = open('abc.txt', 'w+') # file.write('Linha Nova AQUI\n') # file.write('Linha Nova AQUI 2\n') # file.seek(0) # print(file.read()) # finally: # file.close() # with open('abc.txt', 'w+') as file: # # file.write('Linha 1\n') # # file.write('Linha 2\n') # # fil...
d108fca2bc25c8835f3749595b8885e205d4f1d9
nickyfoto/lc
/python/998.maximum-binary-tree-ii.py
966
3.953125
4
# # @lc app=leetcode id=998 lang=python3 class Solution: # def insertIntoMaxTree(self, root: TreeNode, val: int) -> TreeNode: def insertIntoMaxTree(self, root, val): def add_val_to_root(root, val): if val > root.val: node = TreeNode(val) node.left = root ...
20bcb82c1c6fd9b617383cf404bd7fc9bd8b42b3
maxpt95/6.00.1xPython
/Final/RemoveVowels.py
697
3.921875
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 30 18:37:40 2021 @author: maxpe """ def print_without_vowels(s): ''' s: the string to convert Finds a version of s without vowels and whose characters appear in the same order they appear in s. Prints this version of s. Does not return an...
4f1519c69ead40cf5b5fbf19abf6ce84e6dc8a3d
00012726WIUT/seminar10
/task4.2.py
557
4.09375
4
def binarySearchIterative(sequence, x): left = 0 right = len(sequence)-1 mid = 0 while left <= right: mid = ((left + right) // 2) print('mid', sequence[mid]) if x == sequence[mid]: return mid elif x < sequence[mid]: right = mid-1 elif x >...
bb3c96b0dd0945ee2b6021bf7c9bb5d325536d5c
hhy5277/LeetCode-9
/083_删除排序链表中的重复元素/Solution.py
1,318
3.96875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/5/29 19:20 # @Author : zenRRan # @Version : python3.7 # @File : Solution.py # @Software: PyCharm # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(ob...
852467b30d62ee23d54512084c567059f79bc0fd
bgoonz/UsefulResourceRepo2.0
/_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/_Learning/problems/problem_03_list_comprehension.py
675
4.53125
5
# LIST COMPREHENSION # # In this problem, write a function named "my_comprehension" that accepts an # iterable of strings as a parameter and returns a new list with strings from # the original list that are all transformed to upper case. The function must # use a list comprehension in its implementation. Your function ...
b79c4ce47671e685f5b641d85189533d7de63380
huangyt39/algorithm
/73.py
1,812
3.796875
4
""" Definition of TreeNode: """ class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None def __str__(self): stack = [] arr = [] stack.append(self) while len(stack) != 0: if stack[0] != '#': arr.append(...
942e7b27b01dbef402fde9e953d6c3fc8fe773aa
sundharparamasivam/guvihunterset9
/numb_of_2_in_a_range.py
110
3.546875
4
su=int(input()) co=0 for i in range(1,su+1): a=str(i) if "2" in a: co+=a.count("2") print(co)
0e1f5a83f056a3f22947b93a920ffa7ac3fd22d9
gessicamayara/PythonExercises
/World - 2/ex047.py
157
3.703125
4
#Crie um programa que mostre na tela #todos os numeros pares que estao no intervalo # entre 1 e 50. for count in range(2, 51, 2): print(count, end=' ')
7b5a9730af21905e576006ffa2a1ef11788a49bc
raveenavenugopal/Mytest
/NewComplx.py
462
4.09375
4
print print "Enter the Real & Imaginary Part of Divident \n\tSeperated with commas" (a,b)=input() print "Enter the Real & Imaginary Part of Divisor \n\tSeperated with commas" (c,d)=input() print "Divident Is:\t %d%+di"%(a,b) print "Divisor Is :\t %d%+di"%(c,d) if (a,b)==(c,d): print "Equal" else : n=(a*c+b*d) m=(a*...
cca1039c1e96a2ea93a1696c5d1680f0fb1ccbbc
SB1996/Python
/Function/Arguments/ArbitraryArgument.py
1,730
4.125
4
# Arbitrary Argument List ...! # 1. Arbitrary Argument List Using '*args'...! def arbitraryArgument(*args): print(f"*args : {args}") print(f"type(*args) : {type(args)}") print(f"iterable value : ",end="") for i in args: print(i, end=" ") # call the function with 5 argument arbitraryArgument(1,...
a5d827e7226e698e0942a24c4e3f117f96c5aba2
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/word-count/572072af172e446991f8d40fa14e4252.py
138
3.734375
4
from collections import Counter def word_count(sentence): dict = Counter() for word in sentence.split(): dict[word] += 1 return dict
ef4557b838fb915a80b8b1e5aa0579832a4d27d6
waysman1/pyapi
/makejson03.py
813
4.09375
4
#!/usr/bin/python3 import json def main(): # use the with statement to open file 'datacenter.json' in read olny mode with open("datacenter.json") as datacenter: #read the contents of the file-- this creates a string datacenterstring = datacenter.read() # print the string we just created ...
078d584ad74f1614860a84721fdeff362c26eff8
saravananprakash1997/Python_Logical_Programs
/tables_of_numbers.py
175
3.953125
4
number=int(input("enter the table number:")) limit=int(input("enter the limit of the table:")) for i in range (1,limit+1,1): print(str(number)+ "*"+str(i)+"="+str(number*i))
7bb2d25c6155069f91b211d11534286af21ff0f3
nlscng/ubiquitous-octo-robot
/p100/problem-185/AreaRectangleOverlap.py
1,475
4.03125
4
# Given two rectangles on a 2D graph, return the area of their intersection. If the rectangles don't intersect, return 0. # # For example, given the following rectangles: # # { # "top_left": (1, 4), # "dimensions": (3, 3) # width, height # } # and # # { # "top_left": (0, 5), # "dimensions": (4, 3) # wid...
5531cbff995c4fad243e156852681c47733503ea
erchandrasekhar/matplotlib
/straightLine.py
315
3.703125
4
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0,5,100) y = 2*x + 1 y1 = 2*x + 2 y2 = 2*x + 3 plt.title('Straight Lines Graph') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.plot(x,y,label='y=2x+1') plt.plot(x,y1,label='y=2x+2') plt.plot(x,y2,label='y=2x+3') plt.legend() plt.grid() plt.show()
9b4223cbed8707c32575e42ee5a7e2129c27f342
jimjshields/interview_prep
/interview_cake/old/5.py
821
4.0625
4
def permutations(string, length): """Returns all permutations of a given string, with dupes.""" last_char = string[-1] all_chars_but_last = string[:-1] if len(string) <= 1: return string else: for i, c in enumerate(string): for perm in permutations(string[:i] + string[i + 1:], len(string)): return c +...
6d3026c3d65cf008086c4ac3e434763e8f1f75ec
nftbiker/CodeAsCreativeMedium
/09_curves/12_shaping_functions/shaping_functions_python/shaping_functions_python.pyde
2,317
3.640625
4
def setup(): size(800, 800, FX2D) noLoop() def draw(): background(253) margin = 40 rL = 160 rR = width-margin rB = height-margin rT = 160 rW = rR-rL rH = rB-rT myPow = 0.18 nLines = 12 # Draw the background of the square fill(255) noStroke() rect(rL, rT, rW, rH) # Draw ...
fc5477a80362bcf888e414b6e6d368c9f14288d5
Wailtmir/downloadByGSpread
/DateParser.py
895
3.53125
4
import datetime import re import numba def dateParse(s): forma = r'[;,.,,,\s,\\,/,-,_+,]' s = re.split(forma,s) try: s.remove('') s.remove("") except ValueError: pass if len(s)==2: s+=['16'] for i in range(0,len(s)): try: s[i] = int(s[i]) except ValueError: #print("errorDateFormat") retu...
f84b869c792faf4e49614a6098ca7b3e13c482e7
SamuelWeiss/termetris
/main.py
5,048
3.578125
4
from board import tetris_board from keyboard_actions import * from shape import shape, all_shapes import time import math import sys, select import random def calculate_next_frame(level): now = time.time() return now + (1.0 / (level * 0.5 + 0.5)) # avoid weird screen flickering def composite_display(board, score, ...
2da7cc38aab9d74e07276e4fc1901aa871dcbe5d
firiceguo/my-pycuda
/utils.py
2,698
3.65625
4
''' Description: This is a utils package to do the correctness test using CPU, based on convolution definition. Usage: from utils import * Function introduction: conv_cpu: test the correctness of serial, naive, and redundant boundary algorithm; FilterTest: test the correctness of separable filter al...
963588a9420ddcd5acb02a1fa6a7e2ed6991d9bb
li199773/Data-Analysis
/26 panads时间序列练习.py
2,918
3.625
4
""" 1.统计出数据不同类型的紧急情况的次数 2.统计出不同月份不同类型紧急电话的次数的变化情况 """ import pandas as pd from matplotlib import pyplot as plt import numpy as np import matplotlib matplotlib.rc("font", family=' DengXian') nine11_data = pd.read_csv("./911.csv") # 显示所有的行和列的详细信息,不会有省略号 pd.set_option('display.max_columns', None) # 检查数据 ...
ed984d463dd1313df56b86d92092cccf38c26dee
alexeyZay/Python
/OOP/MethodResolutionOrder.py
534
3.71875
4
''' a / \ b c \ / d Lets see how methods will be invoked ''' class a: def some_method(self): print('Class A') class b(a): def some_method(self): print('Class B') class c(a): def some_method(self): print('Class C') class d(b,c): def some_method(self): ...
ae713df5b495cb6455c75185a09d02aaa49fa4e9
renatodev95/Python
/aprendizado/curso_em_video/desafios/desafio003.py
204
4
4
numero1 = int(input('Informe o primeiro número: ')) numero2 = int(input('Informe o segundo número: ')) s = numero1 + numero2 print('A soma entre {} e {} é igual a {}!'.format(numero1, numero2, s))
cf5019a5fb629de48e61b27df4876acfb826b2b9
YoungGaLee/Python-Study
/Hackerrank/[2] Class 2_Find the Tutorial Angle/Class2_find the Tutorial angle_gayoung.py
2,127
3.921875
4
import math class Complex(object): # print(type(object)) def __init__(self, real, imaginary): self.real = real self.imaginary = imaginary def __add__(self, no): a = self.real + no.real b = self.imaginary + no.imaginary return Complex(a, b) def __sub__(self, n...
7b36a407d7c69f739790235ebf2531a47344e23f
YusefQuinlan/PythonTutorial
/Intermediate/2.1 Some Useful-Inbuilt/2.1.9_Intermediate_Slicing.py
2,486
4.0625
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 29 18:22:06 2020 @author: Yusef Quinlan """ Array1 = [3,4,7,8,9,"p","l",True] # Slicing is when you take out a slice of an array to be used, rather than # use the whole array #Prints out 3, a small slice of our array. print(Array1[0]) #Prints an array of the array tha...
9b6ff9072380f568917991db54cba789c9460212
maxuedi/7.25
/周长与面积.py
107
3.734375
4
input_r= input("请输入圆半径:") r=int(input_r) pi = float(3.1415926) c= r*pi*2 a= r*r*pi print(c,a)
c60c28df75d639854ae6219785ecf403de3cda6e
vpalex999/LearnQA_PythonAPI
/tests/test_ex12.py
755
3.78125
4
""" Необходимо написать тест, который делает запрос на метод: https://playground.learnqa.ru/api/homework_header Этот метод возвращает headers с каким-то значением. Необходимо с помощью функции print() понять что за headers и с каким значением, и зафиксировать это поведение с помощью assert """ import requests class...
fb991776138343f04b4eb6c86b4055be05a2e2ee
Nero5023/Swift_Advanced_Functional_Sicp
/LeetCode/zigzagConversion.py
519
3.640625
4
def convert(self, s, numRows): if numRows == 1: return s strings = [""]*numRows cycle = numRows*2-2 for i in xrange(0,len(s)): beyond = i % cycle row = 0 if beyond < numRows: row = beyond else: ...
049f26567c68f438069530093902a16713805c8b
Vika-Zil2020/python
/h1.py
235
3.90625
4
wine=input("Enter the price of wine") wine=int(wine) whisky=input("Enter the price of whisky") whisky=int(whisky) tequila=input("Enter the price of tequila") tequila=int(tequila) print(wine==whisky or wine==tequila or whisky==tequila)
5cde664d07b0b008eb2533cf8ac03f1dd387863b
danishpathan007/PythonProject
/Day5.py
790
3.859375
4
#-----------------------List---------------------------# # Finite , Orderded , mutable and sequence of Elements ''' list.remove(12) list.clear() list.count() ''' #---------------------Dictonary------------------------# #Mutable map from hashable values to arbitrary object ''' myself.get("key") del myself['key...
87b923e94f151fe802b7c6129171649033d4abcf
manojprithvee/my-python-codding
/function.py
128
3.796875
4
def add(a,b): return a+b w=raw_input("enter the first number:\n") e=raw_input("enter the second number:\n") q=add(w,q) print q;
18cb46b115bc85d96a046322731f7592c3522cd5
GHMusicalCoder/My100Days
/Day10/fizzbuzz.py
168
3.734375
4
def fizzbuzz(n): if not n % 3 and not n % 5: return 'Fizz Buzz' if not n % 3: return 'Fizz' if not n % 5: return 'Buzz' return n
b6792840e4fd41e307bb626cf3c2782577d95e19
phung-phu/DNA-Transcription-Translation
/count base pairs.py
1,129
4.375
4
sequence='ACTTGTCGAATCGGTGCCTGAAGTCGTGCGTAGC' #Loop through all of the bases in a sequence for base in sequence: #Print every base print(base) #Sometimes it is useful to have print statements explain what you are seeing #on the screen. For example: print('This is the sequence we are interested in:'...
f8b18945fcabff11a17d8a83b751b88ee7d27077
nilecui/nile_python_swk
/yield/test9_Fibonacci.py
2,977
3.9375
4
#!/usr/bin/python #-*- coding:utf-8 -*- #**************************************************** # Author: nile cui - nile.cui@gmail.com # Last modified: 2012-12-06 13:38 # Filename: test9_Fibonacci.py # Description: #**************************************************** # -------------------------------...
038c4efb486bea75d42abe856ab3c007eea2e29c
khushboo1243/loop
/+ve and -ve no print.py
435
3.5625
4
# Loop ka use kar ke yeh pattern print karo. 1, -2, 3, -4, 5, # i=1 # while i<=10: # if -1*2==0: # print(i) # else: # print(-i) # i=i+1 # i=1 # while i<=10: # if i%2==0: # print(-i) # else: # print(i) # i=i+1 # a=5 # b="7" # c=int(b) # print(c+a) # pr...
d3c826dac4ce70e40e2bc745f7ec7214f0a1b905
limittox/leetcode
/Search/994. Rotting Oranges.py
1,955
3.828125
4
""" In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. Return the minimum number of minu...
ac629ea25387215137c2feb8b0fae509f8d17829
rahulxdagar/Crytographic-Algorithms
/RSA_18BCE0018.py
1,233
3.78125
4
def gcd(e,phi): while phi!= 0: c = e % phi e = phi phi= c return e #input variables d=0 p = int(input("Enter Prime P : ")) q = int(input("Enter Prime Q : ")) message = int(input("Enter Message (Number) : ")) #calculate n n = p*q #phi calculation phi = (p-1)*(q-1) #calcul...
b34cfb15d90f584751d53ddda9024e44dc51c923
Chandler-Song/sample
/python-sample/python-function/_list.py
620
3.546875
4
#/usr/bin/env python3 'list应用' import logging logging.basicConfig(level=logging.INFO) # 多个list合并为一个 # 使用+号: 运算符的重载 l1=[1,2,3] l2=[4,5,6] logging.info(l1+l2) # INFO:root:[1, 2, 3, 4, 5, 6] # 使用extend方法: 比较简洁,但会覆盖原始list l3=[7,8,9] l3.extend(l1) logging.info(l3) # INFO:root:[7, 8, 9, 1, 2, 3] # 使用切片: 功能比较强大,可以将一个列表插入另...
4e3ab70c2d5e93830fd8ff2dbb139a5a968a2253
pawellgit/homew
/1. fib.py
215
3.671875
4
def fib(a): b = 0 c = 1 l1 = [] while c <= a: l1.append(b) l1.append(c) b += c c += b return(l1) print('Введите число') a = int(input()) print(fib(a))
c1b544c2f878e0965ae5b4a1be7a05197afbcc6e
utpalsacheen/Python_programs
/matrix.py
1,145
4.0625
4
def matrixSum(matrix): sum = 0 pr = set() print("set: ") print(pr) for i in range(len(matrix)): for j in range(len(matrix[i])): if matrix[i][j] == 0: pr.add((i+1, j)) else: if (i,j) not in pr: sum = sum + matrix[i][j...
36f22856268ead7bd8c13e120866fcab9e4cd8e8
panumas300/project1
/september 15/write_name.py
399
3.859375
4
def main(): print('Enter the names of three friends. ') name1 = input('Friends #1: ') name2 = input('Friends #2: ') name3 = input('Friends #3: ') myfile = open('september 15/friends.txt','w') myfile.write(name1 + '\n') myfile.write(name2 + '\n') myfile.write(name3 + '\n') ...