blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
e8a0d89589794ffb73017aea26f04e34248ec674
joyceraraujo/logistic-regression
/CostGradient_LR.py
789
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 20 19:08:00 2020 @author: root """ import numpy as np # functions to use in Gradient Descent method def sigmoid(z): g = 1 /(1 + np.exp(-z)) return g def hypothesis(theta, x): h = (theta*x).sum(axis=1).reshape(-1,1) ...
0fe21ef7b1478a03a2d9714d068a0f75bf80dcd6
perrie625/leetcode
/code179.py
467
3.53125
4
import functools class Solution(object): def largestNumber(self, nums): """ :type nums: List[int] :rtype: str """ nums = [str(n) for n in nums] nums = sorted(nums, key=functools.cmp_to_key(self.compare)) result = "".join(nums) if result[0] == "0": ...
5e1e369483aa80bef62cb6bbdcd2b53dc4c5d37d
stuntgoat/search
/algorithms/ucs.py
1,650
4.03125
4
""" This is a simple example of Uniform Cost Search. http://en.wikipedia.org/wiki/Uniform-cost_search """ from Queue import PriorityQueue from util import path_from_start def uniform_cost_search(problem): """ Accepts a UCSProblem; see problems/ucs_problem.py. Returns a path to goal, or None if a goal i...
32dca4ce4462c290a58eff0e11d6ff2948bc7c1d
wydmynd/crazyflie_tom
/crazyflie_demo/scripts/utils/Stepper.py
839
3.828125
4
"""Stepper is a tool for deviding route from point A to point B into N steps. """ class Stepper: """a Class for a Stepper object.""" def __init__(self, n_steps_devider=10, logger=None): self.logger = logger self.n_steps = n_steps_devider self.current_point = None self.desired...
efe12c4dca7912df7a5e2d466e93fb3084d6d0a2
haruna-yoshida/NLP
/colabnotebooks/math/tokei.py
614
3.71875
4
#TODO 分数の形で答えるようにする(帯分数) from sympy import solve, Symbol a = float(4)#短針1 b = float(15)#長針1 m = float(0.5)#短針が一分に進む角度 n = float(6)#長針が一分に進む角度 s = float(360)#角度1 t = float(90)#角度2 def main(): sympy_function(a, b, m, n, s, t) def sympy_function(a, b, m, n, s, t): x = Symbol('x')#重なる時間が◯分後 y = Symbol('y')#90度になる...
cddfb7b5f939fe76dd7898d5790295cd889559f5
haruna-yoshida/NLP
/colabnotebooks/math/soutou.py
373
3.734375
4
from sympy import solve, Symbol a = float(1)#分子1 b = float(7)#分母2 c = float(1)#分子2 d = float(3)#分母2 s = float(44)#ページ数1 def main(): sympy_function(a, b, c, d, s) def sympy_function(a, b, c, d, s): x = Symbol('x')#全ページ数 equation1 =x*(a/b) + s + x*(c/d) -x X = solve([equation1]) print(X) if __name__ == "__m...
f4fc133bdf9f31606456ca41cc55a9e4e82f2ca4
haruna-yoshida/NLP
/colabnotebooks/math/bunpai.py
584
3.71875
4
from sympy import solve, Symbol A1 = float(284)#合計 s = float(21)#人物B-人物A t = float(5)#人物C-人物A a = float(1)#変数1 b = float(1)#変数2 c = float(1)#変数3 def main(): sympy_function(A1, a, b, c, s, t) def sympy_function(A1,a, b, c, s, t): x = Symbol('x')#人物1のもらった数 y = Symbol('y')#人物2のもらった数 z = Symbol('z')#人物3のもらった数 ...
411345668a4ec5ddb4230d61116f4968e816603d
debjbhow/Emoji-Creation-using-Python
/main.py
443
3.78125
4
import turtle root=turtle=turtle.Turtle() root.up() root.goto(0,-100) root.down() root.begin_fill() root.fillcolor("Yellow") root.circle(100) root.end_fill() root.up() root.goto(-67,-40) root.setheading(-60) root.width(5) root.down() root.circle(80,120) root.fillcolor("black") for i in range(-35,105,70): root.up(...
90178cb0c924c10b4047fc3218fff55eb2c2b6e1
DeepDeepLearning21/PythonProgramming
/program5_LogisticRegression.py
3,928
3.71875
4
#import torchvision import numpy as np import torch from torch.autograd import Variable import matplotlib.pyplot as plt import pandas as pd #df = pd.read_csv('/Users/dionelisnikolaos/Downloads/cancer_data.csv') df = pd.read_csv('/Users/dionelisnikolaos/Downloads/Iris.csv') # we use "df[['Species']]" to change ...
22eb86c5674452b3ed56a024d65e7f698c7db732
playone/forpython
/GUIpratice/test4.py
929
3.59375
4
#encoding: utf-8 """ 繪圖板練習 """ from Tkinter import * def drawCircle(self, x, y, r, **kwargs): return self.create_oval(x-r, y-r, x+r, y+r, **kwargs) root = Tk() root.title('Canvas Test') cvs = Canvas(root, width = 600, height = 400) cvs.pack() cvs.create_line(150, 0, 50, 400) #(起點的X軸, 起點的Y軸, 終點的X軸, 終點的Y軸, fil...
a9b51fe7f9c2200aa6e178d5ff94664db7b78d66
playone/forpython
/GUIpratice/test7.py
1,561
3.609375
4
#encoding: utf-8 """ Calendar的lib 是從http://svn.python.org/projects/sandbox/trunk/ttk-gsoc/samples/ttkcalendar.py 下載放至tk lib裡 此篇是calendar的練習 """ import Tkinter import ttkcalendar import tkSimpleDialog def ok_clicked(): result = calendar.selection #獲取選取日期的資料,此時資料型態是datetime result = str(result) #將資料型態轉...
2022ee151003dadfd3e1a55b23644e0b37ebe16c
liwei86521/Design-Patterns-Py
/结构型模式/结构型模式-适配器模式.py
1,393
4.125
4
# -*- coding:utf-8 -*- #适配器模式:由于系统调用方式的原因,需要把不同类里面的方法(名字不一样),用同样的方式来调用 class Bird: def fly(self): print('bird is flying ...') class Dog: def bark(self): print('dog is barking ...') class People: def speak(self): print('people is speaking ...') class Adapter: d...
969b15ae631cb3472506d2d8ddc90020a9d224db
liwei86521/Design-Patterns-Py
/行为型模式/行为型模式-模板模式.py
1,033
3.921875
4
# -*- coding:utf-8 -*- import abc #员工基类相当于一个员工模版,定义了一个员工的通用行为 class Employee(): def __init__(self, name): self.name = name def clock_in(self): print(f"{self.name} 打卡上班") @abc.abstractmethod def work(self): # 抽象方法 pass def noon_break(self): print(f"{s...
d03f7a6624e4a55251492791c696a78982ab26fd
clueskee/Podstawy_Pythona_PRZYKLADOWY
/answers.py
1,414
3.78125
4
from random import choice def revers_sentence(sentence): reversed_sentence = sentence[::-1].title() return reversed_sentence # print(revers_sentence('Ala ma kota')) # print(revers_sentence('Python is easy')) def count_char(sentence, character): uni_sentence = sentence.lower() uni_character = characte...
f46d2d90336b6182ce775e508ee94002fb795dfb
Mukhilm/cs440
/Mp3/solve.py
10,389
3.890625
4
import numpy as np from queue import PriorityQueue from pythonds.basic.stack import Stack import copy """ Implement me!!!!!!! The solve function takes in a set of constraints. The first dimension is the axis to which the constraints refer to. The second dimension is the list of constraints for some axi...
b465cfed8eab97863455c7e894b98828f80e8ceb
dprestsde/sosio_assignment
/square_diffs.py
213
3.90625
4
def sum_of_squares(n): return ( n*(n+1)*((2*n)+1))//6 def square_of_sums(n): return int(((n*(n+1))/2)**2) n = int(input()) answer = square_of_sums(n) -sum_of_squares(n) print("Difference = ", answer)
de1b36184db087b7cb033b522fd35945e2974d83
dressaco/Python-URI
/URI1021.py
1,731
3.59375
4
amount = float(input()) cents = valorfloat - int(valorfloat) valor = valorfloat - cents valor = int(valor) print('NOTAS:') if valor>=100: notascem=valor//100 print(f'{notascem:.0f} nota(s) de R$ 100.00') else: print('0 nota(s) de R$ 100.00') restocem = valor%100 if restocem>=50: notascinquenta=restoce...
0a3caa0649b0442ab39a9d4baebce376191a4767
jeevan-221710/AIML2020
/1-06-2020assignment.py
994
4.15625
4
#password picker import string from random import * print("Welcome password Picker!!!!") adj = ["Excellet","Very Good","Good","Bad","Poor"] noun = ["jeevan","sai","narra","anaconda","jupyter"] digits = string.digits spl_char = string.punctuation Welcome password Picker!!!! while True: password = choice(adj) + choic...
f820b900bce0f1a3de25fca50a91cf8a8a23eab9
MLameg/computeCones
/computeCones.py
811
4.375
4
import math print("This program calculates the surface area and volume of a cone.") r = float(input("Enter the radius of the cone (in feet): ")) h = float(input("Enter the height of the cone (in feet): ")) print("The numbers you entered have been rounded to 2 decimal digits.\nRadius = " +str(round(r,2))+ "...
125aa17d30cce8af8b40cab2febe19d8aef8af21
amitks815/pycode
/list_to_dict.py
471
3.5
4
list1=[1,2,3,4,5,6,7,8] # list2=list1[0:9:2] # list3=list1[1:8:2] # print(list2) # print(list3) # # dict1=dict(zip(list2,list3)) # # print(dict1) # # # import re # str='19:191:9018 he is there ' # # pattern=re.compile('[1-9]|1[0-9]|2[0-9]|3[0-1](.|:)[1-9]|1[0-2](.|:)19|20[0-9]+') # # print(re.match(pattern,str)) di...
ddd5902d65926e1682b43bbe82c765f66548e969
amitks815/pycode
/regexemail.py
352
3.515625
4
import re with open ("file.txt") as f: content=f.read() print(content) pattern=re.compile(r'[A-za-z0-9.]+@[A-za-z0-9]+.[A-za-z]+') matches=pattern.finditer(content) for match in matches: print(match.group(0)) pattern=re.compile('(\d{1,3}\.){3}\d{1,3}') matches=pattern.finditer(content) for match in matc...
d6bb9cf0a912514518d10775db5793b50a1303d9
amitks815/pycode
/python/even_odd_count.py
315
3.890625
4
num1=int(input('Enter the starting range :')) num2=int(input('Enter the ending range :')) count1=0 count2=0 for i in range(num1,num2): if i%2==0: count1+=1 else: count2 += 1 print('number of odd number count is {}'.format(count2)) print('number of even number count is {}'.format(count1))
859037c06aa5dd0070f78b86054ab1781239cce9
amitks815/pycode
/class5.py
1,514
3.859375
4
class employee: raise_amount =1000 def __init__(self,firstname,lastname,pay): self.firstname=firstname self.lastname=lastname self.pay=pay self.email=firstname+'.'+lastname+'@'+'comapany.com' def fullname(self): return self.firstname+' '+self.lastname def payme...
087e47d57d799a45c22428fa9f90260f34842f51
amitks815/pycode
/python/perfect_number.py
752
3.609375
4
# num=int(input('enter the number:')) # # temp=[] # temp1=[] # # for i in range(10,30): # for val in range(2,i): # if i%val==0: # temp.append(val) # print(temp) # # # # if sum(temp)==val: # # temp1.append() # # print('number is perfect') # # print(temp1) # def perfect_number...
55ef667a16d0cf1ab02bf9fcd840344c8cf67d1e
amitks815/pycode
/python/list_example.py
108
3.96875
4
list=[1,2,3,4] list2=list[:] print(list2) list3=[1,[2,3,4,5],[6,7,8,9]] print(list3[2][3]+list3[1][2])
583a8deaca48c4b3c26368835ad9e9e04aa1bf86
amitks815/pycode
/generator.py
132
3.8125
4
def square_num(nums): for i in nums: yield(i*i) my_nums=square_num([1,2,3,4,5]) for num in my_nums: print(num)
88b0a2f6062ef21304424fa8386ebd84fb1523d4
akashshetty63/Python-Programming
/filename_ext.py
99
3.90625
4
fn=input("Input the Filename:") fn1=fn.split('.') print("the extension of file name:"+ fn1[-1])
3a233aa9d761fa9ec777ea205cffd394cd013dd5
frageman/PythonClasses
/lab2/matrix.py
3,203
3.734375
4
import math class Matrix: def __init__(self, *args): self.N = math.sqrt(len(args)) if math.floor(self.N) != self.N: raise ValueError("wrong size of matrix") self.N = int(self.N) self.matrix = [[0 for x in range(self.N)] for y in range(self.N)] k = 0 for ...
1ca49521e467baac5b5022196920c0302e112f4d
Tha-Ohis/demo_virtual
/Hello.py
619
4.15625
4
name=input("Enter your name: ") print("Hello" ,name) # # x=4 # # y=3 # # z=10 # # k=15 # # if x ==y: # # print (x) # # elif y > z: # # print(y) # # elif k > z: # # print(k) # # else: # # print(z) # # Johns_age=20 # # Wicks_age=25 # # pauls_age=23 # # if Johns_age>Wicks_age: # # print("John is old...
4b69f0783a133a08f34e2dc0a1190df3340dc0f1
Tha-Ohis/demo_virtual
/Functions/Using Funcs to guess highest number.py
400
4.15625
4
def highest_number(first, second, third): if first > second and first > third: print(f"{first}is the highest number") elif second > first and second > third: print(f"{second} is the highest number") elif third > first and third > second: print(f"{third} is the highest number") e...
81634c60ec9ab4a5d9c75c7de1eada0e8ec45865
Tha-Ohis/demo_virtual
/Program that checks the hrs worked in a day and displays the wage.py
631
4.25
4
# #Write a program that accepts the name, hours worked a day, and displays the wage of the person name=input("Enter your Name: ") hrs=float(input("Enter the No of Hours Worked in a day: ")) rate=20*hrs wage=(f"You've earned {rate}$") print(wage) # #Write a program that takes in the sides of a rectangle and displays it...
79bd4547ec546773af10136530178518ee21a1b9
cmatth/A.I.
/nqueens.py
6,873
3.609375
4
# Casey Matthews # Artificial Intelligence # Homework 1 # NQueens Module import numpy as np import copy import math _size = 0 _board = 0 def newBoard(size): global _size _size = size board = np.zeros(size ** 2) board = board.reshape(size, size) for x in range(0, _size): board[x][0] = 1 ...
e7de0d92e1b4a443d28785cef1f08b0ed5671534
swest06/Lunar-Lander-
/LunarLander.py
3,535
4.03125
4
'''Sean West swest06. Text based lunar lander game.''' def fuel_use1(fuel): while fuel > 0: f_use = float(input("How much fuel do you want to use?: ")) if f_use < 0: print("Cannot use negative values!") print("No fuel burned") return 0 elif fuel - f_use < 0: print("You only have " + str(fue...
17b96fcb0e8d6222334da8888153e507f3f60db2
ll996075dd/xuexi
/day1-6.py
934
3.71875
4
#_*_ conding:UTF-8 _*_ #题目:输入某年某月某日,判断这一天是这一年的第几天? '''year = int(input('year:\n')) month = int(input('mouth:\n')) day = int(input('day:\n')) months = (0,31,59,90,120,151,181,212,243,273,304,334) if 0 < month <= 12: sum = months[month - 1] else: print('输入错误') sum += day leap = 0 if(year % 400 == 0) or ((...
823c40111fed843ebeda32fc81f21833107b71ab
ll996075dd/xuexi
/15.py
381
3.890625
4
#题目:一个5位数,判断它是不是回文数。即12321是回文数, # 个位与万位相同,十位与千位相同。 #-*- coding: UTF-8 -*- a = input("输入一串数字: ") b = a[::-1]#从最后一个元素到第一个元素复制一遍。 #例如b=a[1:2]则取最后两位 if a == b: print("%s 是回文"% a) else: print("%s 不是回文"% a)
d13f03f491d65d86a6b87f467bacbc23e57cc78a
erschmitt/Beginner-Python
/99bottles.py
522
3.828125
4
start_bottles = 99 while start_bottles != 0: print(str(start_bottles) + " bottles of beer on the wall, " + str(start_bottles) + " bottles of beer! " + "take one down, pass it around") start_bottles -= 1 if start_bottles == 1: print(str(start_bottles) + " bottle of ...
f887f5c163d452818f0a0de76196b476c6d5b86d
niefy/LeetCodeExam
/explore_medium/sorting_and_searching/Merge.py
2,002
3.875
4
""" https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/50/sorting-and-searching/101/ 题目:合并区间 给出一个区间的集合,请合并所有重叠的区间。 示例 1: 输入: [[1,3],[2,6],[8,10],[15,18]] 输出: [[1,6],[8,10],[15,18]] 解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6]. 示例 2: 输入: [[1,4],[4,5]] 输出: [[1,5]] 解释: 区间 [1,4] 和 [4,5] 可被视为重叠区间。 @a...
fee363dc717bbae969d71338fd0756e7ddc577a6
niefy/LeetCodeExam
/explore_medium/sorting_and_searching/SortColors.py
1,256
4.25
4
""" https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/50/sorting-and-searching/96/ 题目:颜色分类 给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。 此题中,我们使用整数 0、 1 和 2 分别表示红色、白色和蓝色。 注意: 不能使用代码库中的排序函数来解决这道题。 示例: 输入: [2,0,2,1,1,0] 输出: [0,0,1,1,2,2] 进阶: 一个直观的解决方案是使用计数排序的两趟扫描算法。 首先...
b4ca0346bf3820aaade607c0985853fd1d292705
niefy/LeetCodeExam
/explore_medium/array_and_string/SetZeroes.py
2,036
3.90625
4
""" https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/29/array-and-strings/76/ 题目: 给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0。请使用原地算法。 示例 1: 输入: [ [1,1,1], [1,0,1], [1,1,1] ] 输出: [ [1,0,1], [0,0,0], [1,0,1] ] 进阶: 一个直接的解决方案是使用 O(mn) 的额外空间,但这并不是一个好的解决方案。 一个简单的改进方案是使用 O(m + n) ...
debe571986f0d2d88781a528d351445f6ef9c6e9
niefy/LeetCodeExam
/explore_easy/dynamic_programming/ClimbStairs.py
1,136
3.953125
4
""" https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/23/dynamic-programming/54/ 题目:爬楼梯 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 示例 1: 输入: 2 输出: 2 解释: 有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶 示例 2: 输入: 3 输出: 3 解释: 有三种方法可以爬到楼顶。 1. 1 阶 + 1 阶 + 1 阶 2. 1 阶 + 2 阶 3...
f16c842ca381403349c06cde780409bedd40328c
niefy/LeetCodeExam
/explore_easy/array/Intersect.py
1,703
4.03125
4
""" https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/1/array/26/ 题目: 两个数组的交集 II 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2,2] 示例 2: 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出: [4,9] 说明: 输出结果中每个元素出现的次数,应与元素在两个数组中出现的次数一致。 我们可以不考虑输出结果的顺序 进阶: 如果给定的数组已经排好序呢?你将如何优...
05bafdafbe2f1607ae51c1782993c8f7d8d0f50e
niefy/LeetCodeExam
/weekly_contest/85/IsRectangleOverlap.py
2,638
3.609375
4
""" https://leetcode-cn.com/contest/weekly-contest-85/problems/rectangle-overlap/ 题目:836. 矩形重叠 矩形以列表 [x1, y1, x2, y2] 的形式表示,其中 (x1, y1) 为左下角的坐标,(x2, y2) 是右上角的坐标。 如果相交的面积为正,则称两矩形重叠。需要明确的是,只在角或边接触的两个矩形不构成重叠。 给出两个矩形,判断它们是否重叠并返回结果。 示例 1: 输入:rec1 = [0,0,2,2], rec2 = [1,1,3,3] 输出:true 示例 2: 输入:rec1 = [0,0,1,1], rec2 = ...
bc728e2d3f1678dff6fd797cce4249849223a9bc
niefy/LeetCodeExam
/explore_easy/linkded_list/ReverseList.py
774
3.984375
4
""" https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/6/linked-list/43/ 题目:反转链表 反转一个单链表。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 进阶: 你可以迭代或递归地反转链表。你能否用两种方法解决这道题? @author Niefy @date 2018-09-20 """ class ReverseList: def reverseList(self, head): """ :type head...
1bda58233ce7092b786a19b605e0e247025b4ed0
mihirpanchal4/python_intermediate_project
/q03_create_3d_array/build.py
163
3.671875
4
# Default Imports import numpy as np # Enter solution here def create_3d_array(): n1 = np.arange(0,27).reshape(3,3,3) return n1 #print create_3d_array()
a0d910f9c1bcc847e0b835b7a1527810d880432d
edward408/Pirate-Bartender
/pibart.py
1,437
3.75
4
#The Bartender app import random questions = { "strong": "Do ye like yer drinks strong?", "salty": "Do ye like it with a salty tang?", "bitter": "Are ye a lubber who likes it bitter?", "sweet": "Would ye like a bit of sweetness with yer poison?", "fruity": "Are ye one for a fruity finish?" } ingre...
1f7794c3cc84466da6bea8a5035d857794b9d38e
SupavitchSSW/Prob-Stat-assignment2
/3Dplot.py
1,117
3.953125
4
''' ============== 3D scatterplot ============== Demonstration of a basic scatterplot in 3D. ''' from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np import csv def randrange(n, vmin, vmax): ''' Helper function to make an array of random numbers having shape (n, ) wi...
6e847ae1f3ceabf378fe9769862740e8b2e244f7
YanQinYuan/pyex
/countWord.py
320
3.515625
4
from collections import Counter def getData(file): with open(file, 'r') as f: data = f.read().split() return data if __name__ == '__main__': data = getData('file.txt') # print(data) # data = ['apple', 'egg', 'apple', 'banana', 'egg', 'apple'] counts = Counter(data) print(counts)
bc665e689f96624c4b7d070c04d43a25b37da1d0
RohithS98/Racket-Interpreter
/Codes/lexer.py
3,398
3.828125
4
#Functions are defined with def. __init__ is constructor. @staticmethod means the #function belongs to the class not the object.__class__ They must be called as #<Class name>.<Function name>(<param>) #Other functions can be called as <object>.<Function name>(<param>) from parsetree import Parser class Tokenizer:...
3356a7a00bab570b73e25d67e99100a9a920b827
kuod/pthw
/ex6.py
548
3.921875
4
#joke statement x = "There are %d types of people." % 10 #two types binary = "binary" do_not = "don't" y = "Those who know %s and those who %s." % (binary, do_not) #print strings print x print y #repeat x except with quotes print "I said: %r." % x #repeat y except with quotes print "I also said: '%s'." % y hilarious =...
5b297196ff616564974573ab1aabf3197d84ffc2
ssilwa/SudokuSolver
/SudokuSolver.py
5,221
3.5625
4
# Python Program to solve Sudoku by Constant Propogation and DFS # Ideas based on this article: http://norvig.com/sudoku.html import math import copy import time import sys Column = {} Row = {} Square = {} All = {} Family_Types = [Column, Row, Square] for i in range(9): for j in range(9): Column[(i,j)] = [(k,j...
915ad9bd70767257c25bfb6cabdd865174ad14b6
PoojaShirwaikar/Learn-Python
/Project-Python/oopsEx/dataHiding.py
678
3.6875
4
class JustCounter: __secretCount = 0 # Private Variable _temp = 0 # not a private Variable can call directly outside the class def count(self): self.__secretCount += 1 print (self.__secretCount) counter = JustCounter() counter.count() counter.count() #print (counter.__secr...
54d985b5af86145f9ee58fea117f3214caf6e5e1
PoojaShirwaikar/Learn-Python
/Project-Python/builtinsFunctionsEx/builtinsFunctionsEx.py
11,754
4.28125
4
#abs(number) :Return the absolute value(means return positive value) of a number. The argument may be an integer or a floating point number. If the argument is a complex number, its magnitude is returned. print("******************************************abs() Example***********************************") print(abs(-1)...
b2e5c5c77257c40d96efab5637b528aa19824099
PoojaShirwaikar/Learn-Python
/Project-Python/advanceTopic/generator.py
5,679
4.65625
5
""" a generator is a functionEx that returns an object (iterator) which we can iterate over (one value at a time). Important:Generators are a simple and powerful tool for creating iterators. They are written like regular functions but use the yield statement whenever they want to return data. Each time next() is c...
6921ce721720aba653f55bc5460751243b235a31
BhuvaneswaraReddy/data_science
/spec/l_r.py
2,693
3.890625
4
from sklearn.datasets import load_boston from sklearn.linear_model import LinearRegression import numpy as np import random import matplotlib.pyplot as plt import ml_helpers # Load the Boston housing data set to regression training # NOTE that this loads as a dictionairy def linear_regression(): boston_d...
8b7ac76ba7bb7557d538bb78303aac6be51636b8
amaresh02/my_captain
/pos_nums.py
333
4.09375
4
# Program which takes a list of integers as input and returns all the positive integers lst = [] n = int(input("Enter the number of elements : ")) print("Enter the elements:") for i in range(n): elem = int(input()) lst.append(elem) pos_lst = [] for num in lst: if num > 0: pos_lst.append(num) p...
dc18de6ad24d128f55ce5828bef36775d2bf93f8
DmitriyPosypaiko/test
/task_2.py
1,112
3.78125
4
from collections import Counter def add_x(): namber = int(input("Ввод:\n")) for i in range(namber): X.append(input()) def add_y(): namber = int(input()) for i in range(namber): Y.append(input()) def readfile(): with open("file_task_2.txt", "r") as file: b = int(input("Введ...
d88a2f237cab4085614468d4820a99eeaef5caf2
rahul0124/Guvi_programs
/p44.py
95
3.578125
4
l=[i for i in range(1,11)] num=int(input()) if num in l: print("yes") else: print("no")
7a74a72659009d9da060a8a106741deadd1a7b35
Danielo814/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
272
3.765625
4
#!/usr/bin/python3 """ 0-read_file module that reads a file and prints to stdout """ def read_file(filename=""): """ opens file 'filename' and prints contents to stdout """ with open(filename, 'r', encoding='utf-8') as f: print(f.read(), end="")
b2aba4b8dcfe1e6b3692bc518bba21b802de62ba
Danielo814/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
638
4.09375
4
#!/usr/bin/python3 """ 5-text_indentation module """ def text_indentation(text): """ function that prints text with 2 new lines after the characters '.', '?' and ':' """ if type(text) is not str: raise TypeError("text must be a string") flag = False special = ['.', '?', ':'] fo...
1d79eeb221b448dd11d03cffe8ff4434ed0dd1f4
Danielo814/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/4-only_diff_elements.py
248
3.75
4
#!/usr/bin/python3 def only_diff_elements(set_1, set_2): new = [] for i in set_2: if i not in set_1: new.append(i) for j in set_1: if j not in new and j not in set_2: new.append(j) return new
2a0b81a9f7cc2293a5ecc6f0e6b6cb7eee57a46f
Danielo814/holbertonschool-higher_level_programming
/0x0B-python-input_output/14-pascal_triangle.py
519
3.953125
4
#!/usr/bin/python3 """ 14-pascal_triangle module """ def pascal_triangle(n): """ returns a list of integers representing pascal's triangle of n """ newlist = [] for row in range(n): newlist.append([]) for column in range(row + 1): if column == 0 or column == row: ...
8cb6c0042852589ff82d4095d42b09aa5bc7eec6
pramod3009/Algorithms
/search algorithms/djikstra.py
3,550
4
4
import heapq import sys class Graph: def __init__(self): self.vertices = {} def add_vertex(self, name, edges): self.vertices[name] = edges def shortest_path(self, start, finish): distances = {} # Distance from start to node previous = {} # Previous node in ...
0c05c25ddb7749ff9b5dd82c0ef6c5a72246aa2d
gcabad/sudoku-solver
/src/main/solver.py
2,906
3.765625
4
import math class Solver(object): def __init__(self, matrix): self.count = 0 self.matrix = matrix """Solutions es para el sudoku vacio""" self.solutions = [] def get_empty(self, coor): for row in range(len(self.get_matrix())): for col in range(len(self.get...
39337a7dbaf65a18a502ae441cf935bf3876f503
JimVliet/Python-DataAnalyse
/Python-DataAnalyse/Python-DataAnalyse/maxProfitsFromStocks.py
1,388
3.84375
4
def getMaxProfit(stockPriceList): currentMinPrice = None bestProfit = stockPriceList[1] - stockPriceList[0] for price in stockPriceList: if currentMinPrice is None: currentMinPrice = price continue calcDifference = price-currentMinPrice if bestProfit < calcDifference: bestProfit = calcDifference if ...
3a56c386019b41196bc9dd798bb6ea4bc302e04e
lauramog/Registration_Form
/RegForm.py
3,304
3.53125
4
import openpyxl from tkinter import * from tkinter import messagebox ################################################## ## Lectura de libro de excel, hojas y columnas ## ################################################## path='elprogram.xlsx' wb= openpyxl.load_workbook(path) sheet1=wb['MateriasyCupos'] sheet2=wb['E...
c1d198722f14ec94203067f0eb0faa10d681850e
xvrlad/Python-Stuff
/TC3.py
687
3.78125
4
def get_change(items, price_per_item, amount_tendered): cost_of_items = items * price_per_item change = abs(cost_of_items - amount_tendered) change = round(change, 2) return change def get_inner_number(number): integer = str(number) if len(integer) < 3: inner_number = int("0") else:...
d7882efbc03cae072ba7ad9d404945b4771c538f
xvrlad/Python-Stuff
/Lab 3 Q6.py
618
4.0625
4
""" Lab 3: Program 2 (Question 6) Author - Xavier Ladores xlad198 Apr 4, 2020 Program that """ def main(): print("1.", get_first_last_number(74678)) print("2.", get_first_last_number(-455)) print("3.", get_first_last_number(1437)) print("4.", get_first_last_number(0)) def get_first_last_number(number)...
60f6aa1eeacf736d5ff5e52da56dfd9cc33675e4
xvrlad/Python-Stuff
/TQ4.py
1,459
3.859375
4
#q1 def count_code(n): total = 0 i = 0 count = 2 count += 1 while i < n: count +=1 total += total count +=1 j = n - 1 count += 1 while j >= 0: count += 1 total /= 2 count += 1 total -= 1 co...
7122a5fb3444b72e924fa92f93fb032a52ce5893
xvrlad/Python-Stuff
/Lab01A - Q8.py
642
3.9375
4
star = "*" space = " " prompt = "Enter number of rows: " number_of_rows = int(input(prompt)) mid_rows = (number_of_rows // 2) + 1 i = 4 print(star * number_of_rows) for rows_in_between in range(mid_rows - 2): print(star + space * rows_in_between + star + space * (number_of_rows - i) + star + space * rows_in_betwee...
a0b3d022d89f844f0c0c0e577a64b17b64518869
xvrlad/Python-Stuff
/Lab01A - Q10.py
294
4.125
4
prompt = "Enter a word: " string = input(prompt) letter_list = list(string) letter_list.sort() new_dict = {} for letters in letter_list: if letters not in new_dict: new_dict[letters] = ord(letters) for letters, asciis in new_dict.items(): print("{}:{}".format(letters,asciis))
70bb60355c1916227a299d28f117e693ca4836b5
xvrlad/Python-Stuff
/TC9.py
1,159
3.984375
4
def main(): print_right_angle_traingles('*', '-', 5) print() print_right_angle_traingles("$",'-', 3) print() print_hollow_square('#', 8) print() print_hollow_square("$", 3) print() return def print_right_angle_traingles(symbol1, symbol2, number_of_rows): initial = 0 for row...
09f365379157822059b2f26f9c418f10bfb4404b
xvrlad/Python-Stuff
/A2.py
9,598
3.59375
4
#q1 def highest_value_word(word1, word2, ordinal_position=1): index_position = ordinal_position - 1 if word1 == word2: return 0 elif index_position == len(word1) or index_position == len(word2): return ordinal_position if index_position == len(word1) else -ordinal_position elif or...
0f042f157b6aa31b1cafe18bc9741aafac382e60
rescenic/Softuni-Python-v2
/python-advanced/02 - Tuples and Sets - Exercise/02. Sets of Elements.py
531
3.578125
4
from typing import List, Set def get_unique_items_from_input(n: int) -> Set[str]: return {input() for _ in range(n)} def get_junct_of_two_sets(s1: Set[str], s2: Set[str]) -> Set[str]: return s1 & s2 def fmt_output(items: List[str]) -> str: nl = '\n' return nl.join(items) def main() -> None: ...
bcbfc8ccc5a84985c197218b7129801736481508
rescenic/Softuni-Python-v2
/python-fundamentals/04 Functions - Exercise/06. Password Validator.py
1,548
4.03125
4
def passwd_chk(passwd): LEN_RANGE = range(6, 11) MIN_DIG_COUNT = 2 e1 = 0 e2 = 0 e3 = 0 dig_counts = 0 valid = True if len(passwd) not in LEN_RANGE: valid = False e1 += 1 for c in passwd: if c.isnumeric(): dig_counts += 1 if not c.isa...
ad3c0839819127d11a934b1e5ca424eb1dc75a6a
rescenic/Softuni-Python-v2
/python-fundamentals/03 Lists Basics - Exercise/08. Seize the Fire.py
802
3.640625
4
cells = input().split('#') water_amount = int(input()) HIGH_RANGE = range(81,126) MEDIUM_RANGE = range(51,81) LOW_RANGE = range(1,51) effort = 0 putout_fires = [] for cell in cells: fire_type, fire_value = cell.split(' = ') fire_value = int(fire_value) if fire_type == 'High' and fire_value not in HIGH_R...
d618d2de72c862311b548ec434241783e7150791
rescenic/Softuni-Python-v2
/python-advanced/04 - Comprehensions - Exercise/01. Word Filter.py
163
4.03125
4
def even_word(word): return len(word) % 2 == 0 text = input() even_words = [word for word in text.split() if even_word(word)] print('\n'.join(even_words))
5ca3d2d3363cae14e37d051e223e905f9c06d49a
rescenic/Softuni-Python-v2
/python-advanced/03 - Multidimensional Lists - Lab/04. Symbol in Matrix.py
721
3.765625
4
from typing import List, Optional, Tuple def gen_matrix(n: int) -> List[List[str]]: matrix = [] for _ in range(n): row = list(input()) matrix.append(row) return matrix def get_location_in_matrix(matrix: List[List[str]], search_term: str) -> Optional[Tuple[int, int]]: for i in range(l...
5b90a08fe12a80934cdf8742777dc52ecee44f23
rescenic/Softuni-Python-v2
/python-fundamentals/02 Data Types and Variables - Exercises/04. Sum of Chars.py
159
4.09375
4
chars_count = int(input()) chars_sum = 0 for i in range(0, chars_count): char = input() chars_sum += ord(char) print(f'The sum equals: {chars_sum}')
32ea3c81437f90fecc15563420fe6d504b51571a
rescenic/Softuni-Python-v2
/python-advanced/03 - Multidimensional Lists - Exercise/04. Matrix Shuffling.py
957
3.671875
4
def val_coord(x: int, y: int, n: int, m: int) -> bool: return 0 <= x < n and 0 <= y < m def read_arr(): n, m = [int(x) for x in input().split()] arr = [input().split() for _ in range(n)] return arr def print_arr(arr): for line in arr: print(*line) def main(): arr = read_arr() n...
eee61c922c4ccd3ae3155266f93edab734cea89c
rescenic/Softuni-Python-v2
/python-fundamentals/ZZ Midexam Prep/02. Treasure Hunt.py
1,659
3.5625
4
class TreasureChest: def __init__(self, items: str) -> None: self.items = items.split('|') def loot(self, l: list): def already_looted(loot: str): for item in self.items: if item == loot: return True return False for item in l...
364c216be70fe11b67a9be441e4fd29669f9a3f6
rescenic/Softuni-Python-v2
/python-fundamentals/ZZ Midexam Prep/02. Shopping List.py
1,424
3.875
4
class ShoppingList: def __init__(self, l: list) -> None: self.l = l def urgent(self, item: str): if item not in self.l: self.l.insert(0, item) def unnecessary(self, item: str): if item in self.l: while item in self.l: self.l.remove(item) ...
6a403f960c6850291aa8e4242fb3de749afd56fd
rescenic/Softuni-Python-v2
/python-oop/10 - Testing - Exercise/Exercise-Resources/hero/test/test_hero.py
2,893
3.765625
4
import unittest from project.hero import Hero DEFAULT_USERNAME = 'Test' DEFAULT_LEVEL = 1 DEFAULT_HEALTH = 100 DEFAULT_DAMAGE = 10 HERO_REPRESENTATION = "Hero Test: 1 lvl\n" \ "Health: 100\n" \ "Damage: 10\n" class HeroTests(unittest.TestCase): def setUp(self) -> None: self.hero = Hero(username=...
7f31559e7ee348670b32b37ab4e85d12c3109ea1
rescenic/Softuni-Python-v2
/python-fundamentals/08 Text Processing - Exercise/01. Valid Usernames.py
263
3.78125
4
def validate(s: str): if not (3 <= len(s) <= 16): return False for c in s: if not (c.isalnum() or c in ['-', '_']): return False return True data = input().split(', ') for name in filter(validate, data): print(name)
265c865d50d07f30fe3215bc886bc2118b402f9d
rescenic/Softuni-Python-v2
/python-fundamentals/02 Data Types and Variables - Exercises/01. Integer Operations.py
170
3.640625
4
int_one = int(input()) int_two = int(input()) int_three = int(input()) int_four = int(input()) int_sum = int((int_one + int_two) / int_three) * int_four print(int_sum)
65be6923a797548ebe2fb9f8972f6126043a54ef
rescenic/Softuni-Python-v2
/python-oop/04 - Encapsulation - Lab/04. Email Validator.py
2,709
3.6875
4
from typing import Tuple class EmailParser: def parse(self, email: str) -> Tuple[str, str, str]: name, *rest = email.split('@') mail, domain = rest[0].split('.') return name, mail, domain class EmailValidator: min_length: int mails: list domains: list __parser: EmailParse...
39f8338d920fd1c02d951d467b30c9ec8dea0784
rescenic/Softuni-Python-v2
/python-advanced/ZZ - Exam - Prep/19 August 2020/01.py
1,283
3.796875
4
from collections import deque class TaxiCompany: def __init__(self) -> None: self.customers = None self.taxis = None self.total_time = 0 def populate(self): self.customers = deque(int(x) for x in input().split(', ')) self.taxis = deque(int(x) for x in input().split(', ...
1334637a0b4fc3eac776b63bd5b418ddd2331af6
rescenic/Softuni-Python-v2
/python-advanced/ZZ - Exam - Prep/14 February 2021/02_alt.py
3,981
3.5
4
from typing import List, Tuple PLAYER_MARKER = 'P' WALL_MARKER = 'X' COINS_TARGET = 100 EMPTY = '0' class Player: def __init__(self) -> None: self.coins = 0 self.__path = [] self.has_lost = False def _set_position(self, i: int, j: int) -> None: self.i = i self.j = j ...
c74e373ff531a160bd5f990f7686c001d16d8bba
rescenic/Softuni-Python-v2
/python-fundamentals/04 Functions - More Exercises/04. Tribonacci Sequence.py
653
4.0625
4
def find_tribonacci(number): t_nums = [1] num = 1 while len(t_nums) < number: if len(t_nums) < 3: if len(t_nums) == 1: if num == t_nums[-1] + 0 + 0: t_nums.append(num) elif len(t_nums) == 2: if num == t_nums[-1] + t_nums[...
65d562597a059c2df3130fa1f72dd784359e5b23
rescenic/Softuni-Python-v2
/python-advanced/03 - Multidimensional Lists - Lab/05. Square with Maximum Sum.py
1,770
3.6875
4
from typing import List, Optional def get_matrix_size(sep: str = ' ') -> List[int]: return [int(x) for x in input().split(sep)] def gen_matrix(n: int, m: int, sep: str = ' ') -> List[List[int]]: matrix = [] for _ in range(n): row = [int(x) for x in input().split(sep)] assert m == len(row...
fd71662c3e47b98d1c2602fc53adf025e4507e56
rescenic/Softuni-Python-v2
/python-advanced/ZZ - Exam - Prep/27 June 2020/01.py
2,117
3.671875
4
from collections import deque class BombPouch: def __init__(self) -> None: self.bombs = None self.bombs_ready = False self.effects = None self.casings = None def populate(self): self.effects = deque(map(int, input().split(', '))) self.casings = deque(map(int, i...
f42a7704d7d716f2914419820f8c044806fb209e
rescenic/Softuni-Python-v2
/python-fundamentals/07 Dictionaries - Lab/02. Stock.py
394
3.90625
4
from collections import defaultdict tokens = input().split(' ') stock = defaultdict(int) for i in range(0, len(tokens), 2): stock[tokens[i]] += int(tokens[i+1]) products_needed = input().split(' ') for product in products_needed: if product not in stock.keys(): print(f"Sorry, we don't have {product}...
9a3e90c2ffd697f7d685e7abcf3d3c81b4e0713f
rescenic/Softuni-Python-v2
/python-advanced/05 - Functions Advanced - Exercise/01. Even Numbers.py
116
3.796875
4
def is_even(x): return x % 2 == 0 nums = [int(x) for x in input().split()] print(list(filter(is_even, nums)))
3f1c07a4e17bc3af534982495e378b0fc41472fe
rescenic/Softuni-Python-v2
/python-basics/Exam/05_exam.py
468
3.828125
4
children_count = 0 adults_count = 0 toy_price = 5 sweather_price = 15 command = input() while command != 'Christmas': age = int(command) if age <= 16: children_count += 1 else: adults_count += 1 command = input() print(f'Number of adults: {adults_count}') print(f'Number ...
0a633a43dd5ba0512cc04d0e84ce8e63c3375ac8
rescenic/Softuni-Python-v2
/python-fundamentals/07 Dictionaries - Exercise/07. Student Academy(oop).py
1,380
3.59375
4
class Student: def __init__(self, name: str) -> None: self.name = name self.grades = [] self.av_grade = 0 def add_grade(self, grade): self.grades.append(grade) class Academy: def __init__(self) -> None: self.students = [] self.filtered = [] def enroll(...
6a7ec06a677eefed8eacbbe0e96ef78f2e3e59fc
rescenic/Softuni-Python-v2
/python-fundamentals/01 Basic Syntax, Conditional Statements and Loops - More-Exercise/01. Find the Largest.py
124
3.78125
4
num = input() dig_list = [dig for dig in str(num) if dig.isnumeric()] dig_list.sort(reverse=True) print(''.join(dig_list))
bc19dfb5358299f39636a93f13cf87a3c7b1e381
rescenic/Softuni-Python-v2
/python-advanced/ZZ - Exam - Prep/24 October 2020/01.py
576
3.5
4
from collections import deque jobs = deque(int(x) for x in input().split(', ')) index = int(input()) threshold = jobs[index] clock_cycles = 0 i = 0 end = len(jobs) while True: if i == end: break job = jobs.popleft() if job <= threshold: clock_cycles += job i += 1 print(clock_cycles)...
676cd9e85bf304b52b75471c932f1c7c023d2630
rescenic/Softuni-Python-v2
/python-advanced/05 - Functions Advanced - Exercise/12. Recursion Palindrome.py
286
4.03125
4
def palindrome(word, index): r_index = len(word) - 1 - index l_chr = word[index] r_chr = word[r_index] if l_chr != r_chr: return f'{word} is not a palindrome' if index >= r_index: return f'{word} is a palindrome' return palindrome(word, index+1)
ef0e32ed6edda908a858ed6f4d56713979cf7434
rescenic/Softuni-Python-v2
/python-fundamentals/07 Dictionaries - Exercise/02. A Miner Task.py
280
3.609375
4
from collections import defaultdict resources = defaultdict(int) while True: token = input() if token == 'stop': break resource = token quantity = int(input()) resources[resource] += quantity for r, v in resources.items(): print(f'{r} -> {v}')
0fd97e0d32273549fe2fab4979e09eda052fd778
rescenic/Softuni-Python-v2
/python-fundamentals/06 Classes and Objects - Lab/03. Email.py
981
3.671875
4
class Email: def __init__(self, sender, receiver, content) -> None: self.sender = sender self.receiver = receiver self.content = content self.is_sent = False def send(self): self.is_sent = True def get_info(self): return f'{self.sender} says to {self.receive...
70c327c676db09a58056716186c948810f40357b
rescenic/Softuni-Python-v2
/python-oop/04 - Encapsulation - Exercise/01. Wild Cat Zoo/project/worker.py
479
3.625
4
class Worker: name: str age: int salary: int def __init__(self, name: str, age: int, salary: int) -> None: self.name = name self.age = age self.salary = salary def __eq__(self, o: object) -> bool: return isinstance(o, type(self)) and o.name == self.name def __h...