blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
03081f2925b7d9bf023b9f93ad5146619d003bc2
kacpersiwiec/pp1
/02-ControlStructures/44.02.py
193
3.53125
4
lim= int(input('Limit prędkości :')) pre= int(input('Podaj prędkość:')) if(pre - lim) <=10: print(f'Mandat: {(pre-lim)* 5} zł') else: print(f'Mandat: {50+((pre-lim-10)*15)} zł')
450c8b882ee77bd7cae9b0d1a137c277fd45e6c2
ValentinaFrempong/The-color-changing-Application
/homework 13.py
1,328
3.671875
4
import tkinter as tk from tkinter import ttk myWindow = tk.Tk() myWindow.title("The color changer") myWindow.configure(background="#de9f0d") ttk.Label(myWindow, text="Enter your name").grid(column=0,row=0) def click_me(): button.configure(text="Hello " + name.get()) name = tk.StringVar() name_e...
550a460c796b03f1c8b85ab226f772878df31b5e
wjang88/4404_asn1
/mushrooms/nbc_binclass_dirmult.py
17,153
3.59375
4
import numpy as np import matplotlib.pyplot as plt import operator ''' Naive Bayes Classifier (Beta Bernoulli; Multinomial Dirilecht). Includes class methods and various processed data Author: Woohyuk Jang, wjang@cs.yorku.ca See data.py for data read and format procedures ''' class NBCBinClassDirMult: data = No...
eab3c6a9687e69791d256ab37d8a3f235d8c0426
nick3499/generate_random_design_nick3499
/generate_design_256.py
640
3.671875
4
#!/usr/bin/env python '''Generate random colored background design.''' from random import randrange def generate_design(): '''Generate random background design.''' gradients = [] n = 16 for i in range(0, 36): gradients.append((n, n+6)) n += 6 gradients.append((232, 256)) gradi...
d042fa371e5356d0c1f604f7a522896178fa121d
wilson-gardner/App-Language-Comparison
/Python/vehicle_components/Engine.py
664
3.84375
4
class Engine(object): """description of class""" def __init__(self, model_number, cylinders, horse_power, city_mpg, hwy_mpg): self.model_number = model_number self.cylinders = cylinders self.horse_power = horse_power self.city_mpg = city_mpg self.hwy_mpg = hwy_mpg ...
5016abaff7d81eb84986bbb472090b14df0f2e4e
covaissvel/qa2qePython
/FunctonsAndPassingValues/CC/overlapping.py
446
3.90625
4
string1 = raw_input() string2 = raw_input() list1 = string1.split(",") list2 = string2.split(",") print list1 print list2 list1 = [str(x).lower() for x in list1] list2 = [str(x).lower() for x in list2] def findoverlap(list1, list2): status = True for i in list1: if i in list2: status = ...
9eaa0b1c7da2c45fe62ee929143597f3beddeb9c
Zahidsqldba07/PythonPrac
/Python Tips.py
1,336
4.21875
4
#!/usr/bin/env python # coding: utf-8 # # Swapping Values # In[1]: x,y = 10, 5 print(x,y) # In[2]: x,y =y,x print(x,y) # # Combining a list of strings into a single one # # In[3]: sentence = ['Why','is','the','rum','gone','?'] concat_sen = "".join(sentence) print(concat_sen) # # Initiallizing a list # ...
dd37db5a5fd9f8e08fbf1cf3642863af6f840492
Princess-luleigh/Intro_python
/Week 2/perimeter.py
472
4.0625
4
#Get the dimensions of the shape width1 = float(input("Enter width 1:")) width2 = float(input("Enter width 2 :")) height1 = float(input("Enter height 1:")) height2 = float(input("Enter height 2:")) price_per_meter = float(input("Enter price per meter: ")) #get the total perimeter perimeter = width1 + height1 +...
9e737acf0b143fab927bce35bbd66dfb2b04da5a
KeSavanh/python-challenge
/PyPoll/main.py
2,570
3.828125
4
# Dependencis import os import csv #open file path election_path = os.path.join('election_data.csv') #open csv reader with open(election_path, 'r') as election: election_reader = csv.reader(election, delimiter=',') #skip headers next(election_reader) #create lists voters = [] counties = [] candidat...
6a68b8adb201ba0fab64e9c527097f51425adc44
komalsorte/LeetCode
/Oracle/235_LowestCommonAncestorOfABinarySearchTree.py
1,938
3.765625
4
""" LeetCode - Easy """ """ Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we all...
a6683174b7e5c65e23935253dca9629ae801047e
ategt/katas
/6_by_6_skyscrapers.py
9,086
4.71875
5
""" 6 By 6 Skyscrapers (2 kyu) In a grid of 6 by 6 squares you want to place a skyscraper in each square with only some clues: The height of the skyscrapers is between 1 and 6 No two skyscrapers in a row or column may have the same number of floors A clue is the number of skyscrapers that you can see in a row or colu...
453daad4c7f284dc2f1132470afe53d5ff1ddc46
cheesepuff90/code-kata
/day11.py
785
3.65625
4
def complex_number_multiply(a, b): # num1 = a[:-1].split('+') # num2 = b[:-1].split('+') # a1 = int(num1[0]) # a2 = int(num1[1]) # b1 = int(num2[0]) # b2 = int(num2[1]) a1, a2 = map(int, a[:-1].split('+')) b1, b2 = map(int, b[:-1].split('+')) return(f'{a1*b1 - a2*b2}+{a1*b2 + a2*b1}i') # 두 개의 in...
eb9a1bc3abe49760617a6c8897401d8e1d683009
trj8497/Life-Expectancy
/utils.py
5,206
3.5
4
""" File Name: utils.py Author's Name: Tejaswini Jagtap """ from rit_lib import * def read_data(filename): """ reads the file :param filename: name of the file :return: number of entities, number of countries/territories, metadata dic, data dic, set of only countries in the file, set of income of countr...
60ee9404b6595e7408eb5f1c9494e747d0d52aef
nannanyy/python_code
/Crawler/jihe.py
948
4.1875
4
# set()是一个无序的不重复元素集合 #创建集合 jihe1 = set() jihe2 = {'A','123','[LIST,22]','apple','草莓'} print(jihe2) jihe2.add('A') #1.添加元素 print(jihe2) jihe2.update('[1]') #添加元素 print(jihe2) jihe2.remove('[') #2.移除元素,元素不存在会报错 print(jihe2) jihe2.discard(666) #移除元素,元素不存在不会报错 print(jihe2) jihe2.pop() #随机删除一个元素 x = jihe...
fa4554d2be91a720cbe23008a5308c9f25ab6be8
junyeon-no/tensorflow_study
/relu.py
326
3.546875
4
import numpy as np import matplotlib.pyplot as plt from step_func_draw import step_function def relu(x): return np.maximum(x, 0) x = np.arange(-5.0, 5.0, 0.1) y1 = relu(x) y2 = step_function(x) plt.plot(x, y2, label = "ReLu") plt.plot(x, y1, label = "step", lineStyle = '--') plt.legend() plt.ylim(-0.5, 5.0) plt....
8be933018f4919820b651596ff5734b680b52798
zsXIaoYI/Python_Daily
/cn/zsza/oop/operatorr/ol/_2__iter__next.py
726
4.03125
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- # @Time: 2020/2/18 18:33 # @File: _2__iter__next.py # __author__ = 'zs' class Squares: def __init__(self, start, stop): self.value = start - 1 self.stop = stop def __iter__(self): return self def __next__(self): if self.val...
faaa29180cd9021b1a203e9da796be91a4895de5
fredrikomstedt/forest-eco-system
/water.py
4,432
3.609375
4
import organisms import behaviour_tree as bt import earth from helpers import Direction import constants WATER_POOL_CAPACITY = 10000 class Water(organisms.Organism): """Defines the small water pool""" def __init__(self, ecosystem, x, y, amount=WATER_POOL_CAPACITY): super().__init__(ecosystem, organism...
19b5348d966d591deff298b6251c038faecf7a95
WTrygar/pp1
/02-ControlStructures/02-35.py
490
3.671875
4
import math a = float(input("Podaj a: ")) b = float(input("Podaj b: ")) c = float(input("Podaj c: ")) delta = (b**2) - 4 * a * c if delta > 0: print("Są dwa miejsca zerowe") x1 = ((-b) - (math.sqrt(delta))) / 2 * a print("Pierwsze miejsce zerowe: ", x1) x2 = ((-b) + (math.sqrt(delta))) / 2 * a p...
dfc46fe520c24331bb9a14c32d3cb25bdf3f2b60
shayaansaiyed/Python-Sudoku-Solver
/sudoku4.py
2,507
3.515625
4
def createTestData(): return [[0, 4, 0, 0], [0, 0, 0, 2], [0, 0, 0, 0], [0, 0, 2, 3]] def SudokuSolverRec(grid, row, col): printGrid(grid) if (row == 4): return True found = False nextRow, nextCol = getNextCoord(row, col) if (grid[row][col] != 0):...
91cac0ba2b29bcf4c0b420e55b63220c9c1ba7f9
ResolveWang/algorithm_qa
/arrandmatrix/被围绕的区域.py
2,985
3.9375
4
""" 问题:给定一个二维的矩阵,包含 'X' 和 'O'(字母 O)。找到所有被 'X' 围绕的区域,并将这些区域里所有的 'O' 用 'X' 填充。 示例: X X X X X O O X X X O X X O X X 运行你的函数后,矩阵变为: X X X X X X X X X X X X X O X X 解释: 被围绕的区间不会存在于边界上,换句话说,任何边界上的 'O' 都不会被填充为 'X'。 任何不在边界上,或不与边界上的 'O' 相连 的 'O' 最终都会被填充为 'X'。如果两个元素在水平或垂直方向相邻,则称它们是“相连”的。 思路: 从特性出发,边界区域的'O'不可能被包围,它相邻的'O'不会被包围,...
7556e40ba4c6209ee51ab57a551800abe535389c
sanketc029/python_assi1
/Assi_1/assignment1_3.py
231
3.96875
4
def add(no1,no2): res = no1 + no2; return res; print("enter first no"); no1 =int(input()); print("enter second no"); no2 =int(input()); #res=add(no1,no2); print("Addition of both number is : ",add(no1,no2));
9c2bc83a34c7b69f5ebdf53216c151dde41fd764
fanliu1991/LeetCodeProblems
/31_Next_Permutation.py
3,201
4.21875
4
''' Rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). The replacement must be in-place and use only constant extra memory. Example: Input -> Output: 1,2,3 -> 1,3,...
2fbb37bb8cfbd3fd68d8457799edbdbc8462166f
jpegbert/MachineLearning
/similarity/lanshi_distance/lanshi_distance.py
277
3.78125
4
""" 兰氏距离python实现 """ def canberra_distance(p, q): n = len(p) distance = 0 for i in n: if p[i] == 0 and q[i] == 0: distance += 0 else: distance += abs(p[i] - q[i]) / (abs(p[i]) + abs(q[i])) return distance
edc5908e1c4b81993b80cc2d5ce2fa399f169d23
dinesh-crypto/pythonProject01
/python_pro/condition.py
301
3.953125
4
a=int(input("enter any number:")) if a<=10: print("kiran") else: print("dinesh") #elif a=int(input("enter your number:")) if a>=80 and a<=100: print("class first") elif a>=40 and a<80: print("second class") elif a>=40 and a<70: print("third class") else: print("fail(-_-)")
1345c78f91f72ba50ad40ece82b8fc1e3bb3bf52
Lumexralph/python-algorithm-datastructures
/dates/date_calc.py
696
3.890625
4
from datetime import datetime """ I needed to work on a way to get the difference between dates I came up with the below solution Input example: date_1 = Sun 10 May 2015 13:54:36 -0700 date_2 = Sun 10 May 2015 13:54:36 -0000 date_1 = Sat 02 May 2015 19:54:36 +0530 date_2 = Fri 01 May 2015 13:54:36 -0000 """ date_pat...
1deb167e829173393fe6e5e6666ab23f58109f35
sujink1999/DSA
/Data Structures/Segment Tree/array-impl.py
1,172
3.625
4
# Implementation of Segment tree using arrays import math max_value = (2 ** 32) -1 class SegmentTree: def __init__(self, array): next_power_of_2 = int(math.ceil(math.log2(len(array)))) max_size = 2 * ( 2 ** next_power_of_2) -1 self.tree = [0] * max_size self.constructTree(0, len(a...
28b1ece26dfe701b708f76205b8b065202cfdf03
moadams847/python_works_cousera
/py_databases.py
14,772
3.6875
4
# unicode charaters and strings-------18/12/20----------------------- # x = 'abc' # # print(type(x)) # print(dir(x)) # our first class and object----------------------------- # class partyAnimal: # x = 0 # def party(self): # self.x = self.x + 1 # print('so far',self.x) # an = partyAnimal() ...
36abb84e1b25c2412ffdc698f28776486a5d57b2
stjordanis/goofspiel-library
/goofspiel.py
2,430
3.5
4
import hashlib import random import pprint from json import dumps as package, loads as unpackage def hash_(x): return hashlib.sha256(package(x, sort_keys=True)).hexdigest() def guess(n): pair=[n, random.random()] h=hash_(pair) out=[pair, h] print('guess, salt, and hash: ' +str(out)) print('only shar...
1712b5da53d108830d396590acce4841734ead20
nsa5953/PythonScripts
/Developing_Application/lotto(layout).py
1,391
3.78125
4
# Python Script: Developing Application # 1. Genrate six unique random numbers in range 1-49 # 2. A Function to clear last six random numbers from display # USE GUI - Change layout position from tkinter import * # Create window object and image object window = Tk() img = PhotoImage(file = 'C:\logo.gif') # Add stateme...
0ab18dcd4e2cbb97bd7fdb00826703ea8e118b4e
mallireddy09/Python
/Conditions.py
2,561
4.5
4
## Conditions -> Python supports the usual logical conditions from mathematics: Equals: a == b Not Equals: a != b Less than: a < b Less than or equal to: a <= b Greater than: a > b Greater than or equal to: a >= b -> These conditions can be used in several ways, most commonly in "if statements" and loops. -> An ...
b1c04fd2c90495fc982118133bae07ecc8351b99
UthpalaHewage/ruleBasedApproach
/question_detection.py
1,541
4
4
"""Filter out the questions found on the transcript""" import word_filteration class QuestionDetection(object): """class for the detection of the questions out of the sentences""" # import the method for the filteration of unwanted words found in the content word_filteration_obj = word_filteration.WordFi...
bab86515b9eccee8f5b475f5fb91abc6b73243ce
lgy-h/GoGoGo
/ikaros/week-24-double/second.py
622
3.640625
4
""" """ class Solution: def findMinFibonacciNumbers(self, k: int) -> int: nums = [] idx = 1 while True: fib = self.fibonacci(idx) if fib > k: break if fib == k: return 1 idx += 1 nums.append(fib) ...
b0a5030aa116aa48c9c7ce7cc999476a01a65ba8
s-avra/CEBD1100-intro2
/Class 5/copying_lists.py
383
4.125
4
list1 = [2,3,4] list2 = [value for value in list1]#wordy, not needed print(list1) print(list2) list2[1]=6 print(list1) print(list2) #or list3=list1.copy()#simpler list3[2]=8 print(list3) list5= [] list6= list(["a","b","c"]) list7=list() list5.append("hi") list5.append("test") list6.append("test2") list7.append("test3...
b64237e7992c65f7e8cee6c61ccd7946a91aa858
EvgenijjKum/Python_lessons_basic
/lesson01/home_work/hw01_normal.py
3,947
3.859375
4
__author__ = 'Кумпяков Евгений' # Задача-1: Дано произвольное целое число, вывести самую большую цифру этого числа. # Например, дается x = 58375. # Нужно вывести максимальную цифру в данном числе, т.е. 8. # Подразумевается, что мы не знаем это число заранее. # Число приходит в виде целого беззнакового. # Подсказки: #...
5d39ed5aa3abf281a49052c041a14b957e58f34b
datAnir/GeekForGeeks-Problems
/Bitmasking/reverse_bits.py
1,343
4.0625
4
''' https://practice.geeksforgeeks.org/problems/reverse-bits/ Given a 32 bit number x, reverse its binary form and print the answer in decimal. Input: 2 1 5 Output: 2147483648 2684354560 Explanation: Testcase1: 00000000000000000000000000000001 =1 10000000000000000000000000000000 =2147483648s ''' # method - 1 => if 1<...
b3fd49f65a0b4ca1517ffa5dd5d1ce84ea53549c
BillRozy/algorithms
/maxheap.py
3,141
3.640625
4
from math import ceil class MaxHeap: def __init__(self): self.array = [] def _sift_up(self, index): if index == 0: return while self.array[index] > self.array[self.parent(index)]: parent = self.parent(index) # print('sifting up : ', (index, self....
fac5701ad05a8e58b41dcff82b5c8909c9d4bf8f
Haley-Hartin/Un-Chess-Ted
/classes/King.py
6,435
3.59375
4
from classes.Piece import Piece class King(Piece): def create(self, id, color, position): self.id = id self.type = "King" self.color = color self.position = position self.isCaptured = False def getID(self): return self.id def getPosition(self): ...
c169eea3596353a9357de6729901886adc08cc36
wesenu/Python-3
/Exam1-practice/anciantWin.py
223
3.59375
4
n =int(input()) m = float(input()) usdToBGN =float(input()) month = n * m year = (month * 12) + (month * 2.5) tax = year * 25 / 100 clearMoney = (year - tax) * usdToBGN dayMoney = clearMoney / 365 print("%.2f" % dayMoney)
ad0e1c52f13e80b96eeea36d41f4c3d2d3aaab52
ArthurZheng/python_hard_way
/month_list.py
573
4.1875
4
def choose_month(): months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October','November', 'December'] month_input = int(raw_input("Enter a number for the month (1-12)")) print "The month you pick is ", month_input, " month name: ", months[month_input-1] def main(): ...
4d18fd68b09bfbafb0c2c3b69675e200fb53267d
heyf/cloaked-octo-adventure
/leetcode/0024_swap-nodes-in-pairs.py
1,022
3.734375
4
# # @lc app=leetcode id=24 lang=python3 # # [24] Swap Nodes in Pairs # class ListNode: def __init__(self, x): self.val = x self.next = None def append_node(node, value): node.next = ListNode(value) return node.next def traversal(head): result = [] while head: result.append...
0a1a28c1be338a6a2894c6cd56c97d0320660f90
kietteik/ppl
/ThamKhao/PPL/GiuaKy/5. Nguyên lý ngôn ngữ lập trình - Nguyễn Hứa Phùng (extract.me)/5. Nguyên lý ngôn ngữ lập trình - Nguyễn Hứa Phùng/Tham khảo/Slide _ Quiz/04. Functional Programming/03_Tutorial/list_of_list.py
333
3.515625
4
from functools import reduce ##def foo(a): ## return reduce(lambda x,y: x+y,a) ## ##print(foo([[1,2,3],[4,5,6],[10,122],[1]])) ## ## ## ##convList = lambda lst: reduce(lambda x,y: x+y,lst) ##print(convList([[1,2,3],[4,5,6],[10,122],[1]])) tinh = lambda lst: reduce(lambda x,y: y + x,lst,'c') print(tinh(['a'...
3251b19f4bffc9b7d48d8747ce4ac9609cc941da
milesgrater/Flappy-Jay
/database_code.py
4,565
3.765625
4
import mysql.connector def clearLeaderboard(): """ Resets leaderboard by removing all usernames and scores """ delete = ("DELETE FROM leaderboard") cursor.execute(delete) connection.commit() def addScore(username, user_score): """ Adds user and game score to leaderboard. Usernames ca...
af0eac97e24990cb28a54fd4d76268467c5cc68f
NeilWangziyu/JZOffer
/62.py
536
3.609375
4
# Josephuse circle def LastRemaining(n, m): if n < 1 or m < 1: return -1 nums = [i for i in range(n)] init = 0 while(len(nums)>1): init += (m - 1) init = init % len(nums) nums.pop(init) return nums[0] def LastRemaining_function(n, m): if n < 1 or m < 1: r...
a4d16cdfdcfc6780890fdbedccdf4c95366ed597
PdxCodeGuild/class_Binary_Beasts
/Students/Sean/python/LabCCValidation.py
856
3.734375
4
def valid8(x): CC_number = [] for i in x: CC_number.append(i) for i in range(0,len(CC_number)): CC_number[i] = int(CC_number[i]) check_digit = CC_number[-1] CC_number.pop() CC_number.reverse() reverse = 0 for i, e in enumerate(CC_number): if i % 2 == 0: ...
195d847670b67f23e5d18d605018a0a585bb542e
DaltonBorges/Curso-de-Python
/pythonDesafios/des010.py
168
3.546875
4
brl = float(input('Quantidade em Reais R$: ')) # usd = brl / 5.71 print('Com R$ {:.2f} (reais) você pode comprar apenas U$ {:.2f} (dólares)'.format(brl, (brl/7.71)))
2943ddb8e3357d2d7a4bedcffdbf24ec50d9f436
dcahill/optimized-interview-questions
/guessnumber-warmer-colder.py
807
3.953125
4
from random import randint # init vars answer = randint(1,100) guess = 0 guess_list = [] # main program while guess != answer: # Player guess input guess = int(input('Guess [1-100]: ')) # Check win if guess == answer: # Player wins print('Answer:', answer) print('Turns', ...
4c93e710dd1619bf959adffcc7768a45f65d3f06
ajay-pk/Python-Problems-
/Celcius to Fahrenheit.py
174
3.609375
4
inp = input('Enter Fahrenheit Temperature:') try: fahr = float(inp) celcius = (fahr - 32.0) * 5.0 / 9.0 print(celcius) except: print('Please enter a number')
bfdbb8b98e509e067ece41db4e84405ea691d4e1
e-gautier/daily-coding-problem
/15.py
652
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This problem was asked by Facebook. Given a stream of elements too large to store in memory, pick a random element from the stream with uniform probability. """ """ This one in my opinion is particulary hard, I don't think I have fully understood the problematic yet ...
e09788d01d7ff226326328586e29226e7e23bcf9
jacky881011/12-Hours-Python-Class
/#36 Class Variables/Main.py
446
3.78125
4
from car import Car car_1 = Car('Tesla','Model Y',2022,'White') car_2 = Car('Tesla','Model 3',2021,'Blue') # class method car_1.Driving() car_1.Stopping() car_2.Driving() car_2.Stopping() car_1.wheels = 2 # only car_1 wheels be the 2 print(car_1.wheels) print(car_2.wheels) Car.wheels = 6 # c...
b6a1e4647103511a85f8630f400737bef33caacd
3361538172/nyan
/notes/字符串.py
3,484
4.3125
4
1. eval('数式') eg. eval('3+2') >>> 5 # 自动将字符串转成数式并求和 2. len(str) # 求字符串长度(空格也算) 3. str.lower() # 将大写字母转成小写 eg. str1 = 'Good' print(str1.lower()) >>> good 4. str.upper() # 大写字母转小写 eg. print(str1.upper()) >>> GOOD 5...
a02d2c89d7a050a39766ead5c44b8e6e46d12c75
liliandelgg/shapes
/README.py
707
4.1875
4
# shapes from turtle import * import math # Name your Turtle. timmy = Turtle() # Set Up your screen and starting position. timmy.penup() setup(500,300) x_pos = -250 y_pos = -150 timmy.setposition(x_pos, y_pos) ### Write your code below: def square(steps, angle, speed): timmy.pendown() ...
5ff755d02a20b58c19166d3db9f4c2f815957389
pmdwxy/Python-
/day1/day2_3.py
173
3.71875
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- for i in range(1,10): for j in range(1,i+1): print('%s*%s=%s ' %(j,i,j*i),end="") print('\n')
a6326d2bc1939b2a8df14661ff318c52863c333c
ryumanji/PythonSutudy
/Pythonではじめるアルゴリズム入門/bubble_sort.py
307
3.578125
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 16 22:15:25 2020 @author: ckn32 """ data = [6, 15, 4, 2, 8, 5, 11, 9, 7, 13] for i in range(len(data)): for j in range(len(data) - i - 1): if data[j] > data[j + 1]: data[j], data[j + 1] = data[j + 1], data[j] print(data)
de7a7c08c8be5b3b221f3374edf083db7b7fe8c8
SirAeroWN/ComputerScience
/101/September/PickFourLotto.py
500
3.578125
4
import random firstDig = str(random.randint(0,9)) secondDig = str(random.randint(0,9)) thirdDig = str(random.randint(0,9)) fourthDig = str(random.randint(0,9)) winner = firstDig + secondDig + thirdDig + fourthDig print(winner) guess = input("Guess the four digit lotto number: ") while(True): guess = ...
9fd066254cdfae41e38cfc2dcf4384ea0b70ff0d
q36762000/280201102
/lab6/example6.py
167
3.78125
4
n = int(input("number: ")) sum = 0 for a in range(n): for b in range(n): x = int(input(str(a+1)+ " x "+ str(b+1)+ ": ")) if a == b: sum += x print(sum)
1f54d433a76592475cad41cedb5cc0bfcf82c02f
mani5348/Python
/Day3/Dict2.py
163
4.25
4
#write a Program to Concatenate Two Dictionaries Into One dict1={'Manish':1,'Kartik':2,'Shubham':3} dict2={'Yash':3,'Aman':4} dict1.update(dict2) print(dict1)
b990b3db9af77f2c2963e7f48907a66e03a51434
harishsg99/My-Week-end-products
/PageRotator.py
587
3.75
4
## Code to rotate a specific page in a PDF file import PyPDF2 import sys file_name = sys.argv[1] page_to_be_rotated = sys.argv[2] # First Page = 0 pdf_in = open(f'{file_name}.pdf', 'rb') pdf_reader = PyPDF2.PdfFileReader(pdf_in) pdf_writer = PyPDF2.PdfFileWriter() for pagenum in range(pdf_reader.numPages): ...
8a3c7051d4abfb76f066a4b9c81c7ef96e30b9f9
annastartseva/15_solver
/test_solver15.py
2,481
3.703125
4
import unittest from a_star import a_star from solver15 import chain15, manh_dst_matrix class test_chain15(unittest.TestCase): """ Unit tests for check correctness of chain15 class. """ def test_manh_dst_matrix(self): """ Unit test: check the correctness of the manhattan distance calcu...
e39ab0d35f3c44b3a1325eb9c04f29eea734505c
fagan2888/population-ecology-approach
/src/simulators.py
51,192
3.578125
4
import matplotlib.pyplot as plt import numpy as np import pandas as pd class Simulator(object): """Class for simulating the Pugh-Schaffer-Seabright model.""" def __init__(self, family): """ Create an instance of the Simulator class. Parameters ---------- family : fami...
e519ede0c9c4c79c6c0593a4e212114bc0b9e8ec
LeandroAlencar/CursoPython
/Curso Python Udemy/Exercícios Variados/jokenpo2.py
1,778
3.78125
4
import random from time import sleep itens = ['PAPEL','PEDRA','TESOURA'] cpu = 0 jogador = 0 tent = 0 jogada = 0 rodadas = 0 escolha = 'não' empates = 0 print('BEM-VINDO AO PEDRA PAPEL E TESOURA!') nome = input('Insira seu nome: ') print('(0) PAPEL, (1) PEDRA, (2) TESOURA') while escolha!='sim': te...
428fd0f02701a9d450e3bc8e3bb775170fb64082
sandeepkumar8713/pythonapps
/26_sixthFolder/39_car_fleet.py
2,904
4
4
# https://leetcode.com/problems/car-fleet/ # Similar : https://leetcode.com/problems/car-fleet-ii/ # Question : There are n cars going to the same destination along a one-lane road. The destination # is target miles away. You are given two integer array position and speed, both of length n, # where position[i] is the p...
d12742b038555d437c19a507cb90830df1ff43d1
Said-Akbar/Data-science
/Advanced_topics_DQ/Part_3_advanced/1_OOP_classes.py
2,741
4
4
# 8/1/2020 Saidakbar P. Object-Oriented Programming: classes import math class Player(): # The special __init__ function runs whenever a class is instantiated # The init function can take arguments, but self is always the first one # Self is just a reference to the instance of the class # It's a...
6bd838fa5924158610dceafb1f795c3583404712
BenikaH/NHL_stats
/ReinforcementLearning/carRental/gambler_exercise4_9.py
4,593
3.828125
4
""" This is a first attempt to implement policy iteration strategy to solve Jack's car rental problem 4.5 found in Sutton and Barto 2003 p.93 This second version considers two car rental agencies that both cumulate 20 cars. Each rented car makes a 10$/day profit and overnight car transfers between the two agencies cos...
438bc30ff3acc26ca8310439a7d874a8f63e2903
girish121003/newprogram
/patternMatching.py
420
3.921875
4
def findPattern(pattern,str): str = str.split() dict = {} for k in range(len(pattern)): if dict[pattern[k]]==str[k]: print("ok") elif dict[pattern[k]]!=str[k] and pattern[k] not in dict.keys(): dict[pattern[k]]=str[k] else: return False return ...
af75cbaf74c5caaf19312abca102c6f1bf7296fa
leviycool/Automate-the-boring-stuff-with-Python
/C7_strong_password_detection.py
1,093
4.40625
4
""" Program that uses regular expressions to make sure the password string it is passed is strong. A strong password is defined as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit. """ import re def is_strong(password): """ Function th...
b092e37c73d69de7ad32f032d39b806b9bb2a70d
Mickey-7/python
/python_tutorialspoint/Files_I-O.py
2,224
4.28125
4
print("python is really a great language,", "isn't it?") # python is really a great language, isn't it? # ---------------------------------------------------------------------------------------------------------------------- # The input Function str = input("enter your input: ") print("your input is : ", str) # ente...
21bcaccc3154fff19e5cbbbdd817f2068ea3699e
askarakshabayev/PP2_2021
/week3/9.py
689
3.625
4
class Person: def __init__(self, name, surname): self.name = name self.surname = surname def show(self): print(f'{self.name} - {self.surname}') class Subject: pass class Student(Person): # Person def __init__(self, name, surname, gpa, faculty): super().__init__(name, ...
7344b055580a1939cbc6394147f1adc690ebfeef
Vijayarani27/Python
/Day3.py
1,409
4.34375
4
# Dictionary Comprehension list = [1,2,3] dictionary = {key:key**2 for key in list } print(dictionary) listcomp =[key for key in dictionary.values()] print(listcomp) #Set comprehension ======================== print("\n") list =[1, 2, 5, 2, 3, 1, 4, 5] setcomp= {value**2 for value in set(list)} print(se...
83b3314096ec8f5cf3c4a05bd89fb586cb4bf7e5
sebasluke/verificar-cedula-ecuador
/cedula.py
4,817
4.09375
4
# -*- coding: utf-8 -*- #permite ingresar un número de cédula from sys import argv script, numeroCedula = argv #Crea un int para que bote error si es número y un str para partirle y validar cedulaInt = int(numeroCedula) cedulaStr = str(numeroCedula) #validar que tiene 10 dígitos if len(cedulaStr) == 10: print(f"L...
b0e3d2f4e215fb0459a91e3745ca40986039f003
feliperfdev/100daysofcode-1
/Introdução ao Python/week6/day40/trigonometry.py
469
3.796875
4
from math import sin, cos, tan, pi def trigonometry(iteravel): for e in iteravel: e = float(e) seno = list(map(lambda x: sin(x), iteravel)) cosseno = list(map(lambda x: cos(x), iteravel)) tangente = list(map(lambda x: tan(x), iteravel)) for i in range(0, len(iteravel)): print...
169371c2431a492188e65cfca6d448e4d27e6527
kedgarnguyen298/nguyenquockhanh-fundamental-c4e24
/session3/delete_vt.py
264
3.953125
4
items = ["coca", "fanta", "pepsi"] print(*items, sep = ",") while True: user = int(input("Favourite drink you want to delete? ")) if (user - 1) >= len(items): print("The number was wrong") else: break items.pop(user - 1) print(items)
95953e59c9e1584f37825df78debbeae51479e70
shavgath/python_basics
/03_data_types_ints.py
1,047
4.40625
4
# Numericals - Integers, Big Integers, long numbers, Complex numbers # Integers - Whole numbers my_int = 13 print(type(13)) # NOT the same as print(type('13)) --> STRING! print(type(my_int)) # Floats are composite numbers print(13.1) print(type(13.1)) # Long and complex # Less used check syntax when needed # Operat...
28f97b115eca0ed9c272cdc263d5ab7a4b7a1ad6
shivani-nadkarni/ETL-Pipeline
/main.py
3,355
3.5625
4
import requests import datetime import pandas as pd import json from io import StringIO import sqlite3 def check_if_valid_data(df: pd.DataFrame) -> bool: # check if dataframe is empty if df.empty: print("No songs downloaded. Ending execution.") return False # primary key check if p...
270e6bc0ac14bf839dca704741766f78acc81d4f
limapedro2002/PEOO_Python
/Lista_06/Artur e Guilherme Ferreira/Q2 L6/revista.py
609
3.625
4
class Revista: def __init__(self,codigo,titulo,tipo, edicao): self.__codigo = codigo self.__titulo = titulo self.__tipo = tipo self.__edicao = edicao self.__lista_edicoes = [] def add_revista(self,edicao): self.__lista_edicoes.append(edicao) def listar_edicoes(self): print("titulo:",self.__titu...
9dae8f7d608f91f2b47fe4bcb3499042a0e5c494
Margarita89/LeetCode
/0036_Valid_Sudoku.py
1,284
3.8125
4
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: """ General idea: use defaultdict from set for each column, each row and each box to store the values and check up with them. Alternative: traverse 3 times - through columns, rows and boxes and store encountered values in sets ...
acf581dbe4488f82fd09bf9a30b6d2c867dbcc1a
ioahKwon/PythonforEngineering
/2015312904_Week 13.py
1,472
3.96875
4
''' Date : 2019. 12. 01. Subject : Recursion, Turtle Student ID : 2015312904 Name : 권준우 (Kwon Joon Woo) ''' # assignment_01 dan=int(input("Enter number: ")) def gugudan(n,t=1): if t<=10: print(n,"x",t,"=",n*t) gugudan(n,t+1) gugudan(dan) # assignment_02 N=int(input("Enter N...
e9ac54aa91e98bd1f1facb33d533ceec5beb6647
HwangYoonSeong/Algorithm
/알고리즘과문제해결/작은과제4-4.py
3,251
3.71875
4
import math def dist(p1, p2): # 두 점의 거리 계산 return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def brute(ax): mi = dist(ax[0], ax[1]) p1 = ax[0] p2 = ax[1] ln_ax = len(ax) if ln_ax == 2: return p1, p2, mi for i in range(ln_ax-1): for j in range(i + 1, ln_ax): ...
5731cf104e91ea697cd6820bc9f6a5038a35683e
amsully/competitive-programming
/leetcode/two_sum.py
997
3.703125
4
# Given an array of integers, return indices of the two numbers such that they add up to a specific target. # You may assume that each input would have exactly one solution, and you may not use the same element twice. class Solution(object): def twoSumAccepted(self, nums, target): """ :type nums: ...
85be8ed3ad9f98e9c31d08497b3b7423c938f31d
ritika137/LITG-Python
/logistic-regression-binary.py
2,473
3.53125
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 2 14:39:30 2017 @author: RITIKA """ import numpy as np import matplotlib.pyplot as plt import pandas as pd from scipy.optimize import minimize from sklearn.preprocessing import PolynomialFeatures fileData = pd.read_csv('ex2data1.txt', names = ['Exam 1', 'Exam 2', 'Adm...
30a2baecd8a8112fd0313e66e98dc131ddd84439
negoken/SigmoidHomework
/mostenire.py
1,819
3.53125
4
class Avion: def __init__(self, companie,ruta_de_zbor, ora_de_zbor): self.companie = companie self.ruta_de_zbor = ruta_de_zbor self.ora_de_zbor = ora_de_zbor def decoleazaAvionul(self): print("Avionul decoleaza") def aterizeazaAvionul(self): print("S...
6c30226782d6c50c241ae6d46e7b0e9b93184da7
atrivedi8988/DSA-Must-Do-Questions
/27_Nth Fibonacci/Ideal Solutions/nthFibonacci.py
550
4.21875
4
# Finds Nth Fibonacci Number def nthFibonacci(Number): first, second = 0, 1 # Base Case if Number < 0: print("Wrong Input") elif Number == 0: return first elif Number == 1: return second # Finding Nth Fibonacci using recurring addition else: for i in range(...
7d022b75210b82235e090a88cb684feedc4acff3
mark10hyun/DatabaseStudentRecords
/venv/displayRecords.py
862
3.953125
4
import sqlite3 class displayRecords: @staticmethod def printAll(): conn2 = sqlite3.connect('StudentDB.sqlite') # cursor is something that performs an action c = conn2.cursor() userExit = 1 while userExit == 1: print("-------------------All Student Records--...
8331bcfdbb2c89796b7bd8252a3bf682404caac4
nickLuk/hr_departament
/lib/hr_manager.py
774
3.90625
4
from lib.employees import Employees if __name__ == "__main__": add_hrmanager() class HRmanager(Employees): def __init__(self, name: str, surname: str, age: int, salary: int, skills: str): Employees.__init__(self, name, surname, age, salary, skills) self.__skills = skills def add_hrma...
4c46188b36e6e2000748a5acce9d80b465b599c0
thanhtd32/advancedpython_part1
/Exercise30.py
1,532
3.625
4
#Coder: Tran Duy Thanh #Email: thanhtd@uel.edu.vn #Phone: 0987773061 #Blog for self-study: https://duythanhcse.wordpress.com #Facebook for solving coding problem: https://www.facebook.com/groups/communityuni from tkinter import * window=Tk() window.title("Take the quiz") window.geometry("400x650+10+10") #ques...
2f01822a86890c7cf946bfa6668f3a755b0e8ed8
BaraIda365/pythoncamp
/helloworld.py
140
3.796875
4
print("Hello World") Food_1=input("What is your favourite food") Food_2=input("What do you hate") print(Food_1,Food_2) print(Food_1+Food_2)
cca82bcf32c9f686707d821e20d7232e978d6624
PhilipMottershead/Practice-Python
/Tutorials/Exercise 01 - Character_Input.py
802
4.1875
4
# Create a program that asks the user to enter their name and their age. # Print out a message addressed to them that tells them the year that they will turn 100 years old. # Extras: # Add on to the previous program by asking the user for another number # and printing out that many copies of the previous message. (Hint...
1eefd71d6ebaff00eafcafb83adc128e04588795
stefanpejcic/python
/loops/multable.py
148
3.796875
4
x = int(input("Input number: ")) i = 1 print('1\t2\t3') for i in range(1,x+1): for j in range(1,x+1): print(i*j,end="\t") print()
9a1c670fe83ff84d9ca1aed600a5edb83a28ea5d
Jishasudheer/phytoncourse
/fundamental_programming/Pattern_Dir/num_pattern.py
628
3.921875
4
row=5 # for i in range (row): # for j in range (i): # print(i,end=" ") # print() # # for i in range (row): # for j in range (1,i+1): # print(j,end=" ") # print() # # star printing # for i in range (row): # for j in range (1,i+1): # print("*",end=" ") # print() # #piramid ...
ae4039300d39186be76f10cf7a4e9f8fd54a7be8
udayakumaran/programs
/fibo.py
438
3.796875
4
import math def CheckPerfect(x): i = int(math.sqrt(x)) return (x == i*i) def CheckFibo(n): if(CheckPerfect(5*n*n + 4) or CheckPerfect(5*n*n - 4)): print("Fibonacci") else: print("Not Fibonacci") n = int(input("enter test case")) if n<100: list=[] for x in range(n): n =int(...
18bba8c799773eb8981fabed6d8a6d1dd7edae64
hongki-jung/algorithm
/이코테/기타/투포인터/main.py
970
3.578125
4
# 합이 5인 연속하는 두 수를 찾는문제 n = 5 # 데이터의 개수 N m = 5 # 찾고자 하는 부분합M data = [1, 2, 2, 3, 2, 5] # 전체 수열 one = 0 two = 0 cnt = 0 print(" data[one: two+1]?", data[one: two+2]) while one < len(data)-1: new_data = sum(data[one: two+1]) if new_data < m: two +=1 elif new_data == m: two +=1 cnt +=1 else: ...
122124446bb5d6a34c4e68e42ed62e70d1ac1c2a
Jody-Lu/Array
/13_roman_to_integer/romanToInt.py
670
3.5
4
class Solution(object): def romanToInt(self, s): result = 0 ROMANS = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} for idx in xrange(1, len(s)): #print res...
e04d9cba822e39d6c587ea22d601c461a4246bcc
deriktruyts/Python
/Python3_-_Mundo1_-_Fundamentos/EXERCÍCIOSPython01/Ex_Aula_010/Ex35(FORMA_UM_TRIANGULO).py
638
4.28125
4
# Desafio 035 - Aula 10 # Desenvolva um programa que leia o comprimento de três retas e diga ao # usuário se elas podem ou não formar um triângulo. # ------------------------------------------------------------------------ r1 = float(input('Insira o comprimento da primeira reta: ')) r2 = float(input('Insira o comp...
63d0607da00063999e212b2d7c0d27db6287e32d
romulosimiquel/massnheat
/wall_heat_flow.py
519
3.984375
4
#Calculating heat (heat energy) flow per square metter (W/m²) #enter starting temperature, the temperature from where the heat is coming (K) T1 = int(input('Insert T1(K): ')) #enter final temperature, temperature where the heat is comming in (K) T2 = int(input('Insert T2(K): ')) #wall thickness (m) L = float(input('...
8f02afff991c7bbb81328074ee48c5200d318af8
lynkez/Ebube
/area_calc.py
708
4.03125
4
#program that computes the area of a parcel given the coordinates or using #the cross coordinate method import math import time import sys def strt(): n=float(input("Enter the number of points enclosing the area: ")) d_area=0 count=0 while count!=n: x = float(input("Enter fir...
3e35db3a70c5c39ca511ef43254993303f671b7a
sunkanggao/Algorithm
/LeetCode/longestCommonPrefix.py
1,057
3.78125
4
# -*- coding:utf-8 -*- """ Write a function to find the longest common prefix string amongst an array of strings. """ class Solution1(object): def longestCommonPrefix(self, strs): if not strs: return "" r = '' flag = True for i in range(min([len(s) for s in strs])): ...
fb03a7502bf4d37acc9b5ae953accb7c47c951c5
suryansh1404/python
/sevenfruits.py
291
3.84375
4
f1=input("enter fruit number 1:") f2=input(" enter fruit number 2:") f3=input("enter fruit number 3:") f4=input("enter fruit number 4:") f5=input("enter fruit number 5:") f6=input(" enter fruit number 6:") f7=input("enter fruit number 7:") fruitlist=[f1,f2,f3,f4,f5,f6,f7] print(fruitlist)
56db7c4d31b6b8a908d1cdcbd184282318db7404
nitinbhojwani/lods
/graph/graph.py
3,286
4.09375
4
class Graph: def __init__(self): self.graph_dict = {} def get_vertices(self): """ returns the vertices in graph """ return list(self.graph_dict.keys()) def get_edges(self): """ returns the edges in graph """ edges = [] for vertex in self.graph_dict: ...
232d23ab8a825d9ca06659b434ac921133eed882
ritulsingh/Python
/Add_Two_Number.py
734
4.03125
4
# Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program. # Program is very simple, Given two integers A and B, write a program to add these two numbers. # Input # The first line contains an integer T, the total number of ...
b0e5d79aa55c8891f40b17b80daaaecdac4df3ff
Dishvater/sda_pycharm_python
/python podstawy d2/d2/python_basic/python_basic/zad/z00_calc.py
992
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): end = False while not end: number_1 = float(input('Input 1st number: ')) operation = input('Input math operation sign [+,-,*,/,%]: ') number_2 = float(input('Input 2nd number: ')) if operation == "+": result...
be8ed6101423becdb32e70aa906d5b4adefe3a51
AhhhHmmm/MITx-6.00.1x
/Week 2/Payments Problems/payments3.py
1,843
4.125
4
# import time so you can time the program import time # set start time of program for timing purposes start = time.time() balance = 320000 annualInterestRate = 0.2 def balanceAfterYear(balance, annualInterestRate, monthlyPayment): ''' This function calculates the remaining balance after one year. ''' month = 1 ...