blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
4a31285c6557c05b4c813e848c1f1af938d4e621 | jlyons6100/Wallbreakers | /Week_1/number_of_islands.py | 1,252 | 3.5625 | 4 | # Number of Islands: Given a 2d grod map of 1's(land) and 0's (water), counts the number of islands.
class Solution:
# b_first(grid, tup, visited): Adds (row, col) tuples to set of visited islands
def b_first(self, grid, tup, visited) -> None:
invalid_row = tup[0] < 0 or tup[0] > len(grid) - 1
... |
35e7796ff0e8abb10a0be1df0824ab4d5156948e | ezhilmaran1612/days | /day12.py | 729 | 3.875 | 4 | def decimalToBinary(num, k_prec) :
binary = ""
Integral = int(num)
fractional = num - Integral
while (Integral) :
rem = Integral % 2
binary += str(rem);
Integral //= 2
binary = binary[ : : -1]
binary += '.'
while (k_prec) :
fractional *=... |
850d8f28011c695e9a35d8c45e474f7f0f887e63 | dopqob/Python | /Python学习笔记/进程丨线程丨协程/线程的使用.py | 1,105 | 3.515625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/11/14 10:06
# @Author : Bilon
# @File : 线程的使用.py
import threading
from time import sleep, ctime
"""
# =====================================
# 线程的创建、启动、阻塞
# =====================================
"""
def loop(nsec):
"""
先申明一个loop函数,传入一个sleep时... |
94f7c4d11a8a34875bf28f37cb014b650f52a554 | ArslanShafique1998/SPL-Technical-Assessment | /Advanced/Search/pair_of_target_number.py | 1,395 | 4.25 | 4 | def find_pairs(array,target):
pairs=[]
l=len(array)
#initialize the tuple
p=()
#We add each element with the rest of high index elements For example array=[1,2,3,4]
#Then take first element 1 and add other high index 1+2,1+3,1+4, then take 2 and 2+3,2+4
# then take 3 so add high index... |
ff939aca103da9842ec82c5b564a74c32af51161 | llgeek/leetcode | /441_ArrangingCoins/solution.py | 288 | 3.5 | 4 | from math import sqrt, floor
class Solution:
def arrangeCoins(self, n):
"""
:type n: int
:rtype: int
"""
for i in range(floor(sqrt(2*n)), -1, -1):
if i*(i+1) <= 2*n and (i+1)*(i+2) > 2*n:
return i
return 0
|
895ba260d75f74ae06443769dbdfff7b58ee237b | germanoso/GeekBrains | /Max_in_num.py | 753 | 4.125 | 4 | # 4. Пользователь вводит целое положительное число.
# Найдите самую большую цифру в числе.
# Для решения используйте цикл while и арифметические операции.
# К сожалению, не знаю как через цикл while сделать это задание (((
user_num = list(input('Введите целое положительное число: '))
# Приводим введенное число вви... |
0cf2e4123bab6c8186c8b3bcf743296b0748816b | sz982005/quant_study | /lesson5/homework0/FeatureUtils/ATR.py | 1,572 | 3.5625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 4 12:58:42 2018
@author: zhangjue
"""
#Wilder started with a concept called True Range (TR), which is defined as the greatest of the following:
#
#Method 1: Current High less the current Low
#Method 2: Current High less the previous Close (absolu... |
be8ec587f5abcbc1c89293ca9a5c35efa31681be | dixitk13/python-scripts | /python-day/python-1.py | 2,666 | 3.671875 | 4 | #!/usr/bin/python
import re
from sys import argv
import heapq
import random
from os.path import exists
class Point():
def __init__(self, _x, _y):
self.x = _x
self.y = _y
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __str__(self):
return str(self.__dict__)
def __repr__(self):
re... |
59fb1bd4709ed909057deab7fe3972d5c843cd7e | kislayanika/amis_python | /km73/Kysla_Veronika/Homework 4/task12.py | 295 | 3.75 | 4 | n = int(input("Enter height: "))
m = int(input("Enter width: "))
k = int(input("Enter number of cells you need to cut off: "))
if (((k % n) == 0) or ((k % m) == 0)) & ((m * n) >= k):
print("You can cut the piece off in one step")
else:
print("You can't cut in one step")
input()
|
c334e80f099a34d97e88fb15feedfdcd1ca14ed3 | vcooley/Code_Abbey_Problems | /prob19.py | 1,494 | 4.15625 | 4 | def bracket_check(check_str):
"""
Takes a string and checks for bracket validity
by removing all other characters
from the string and eliminating adjacent
pairs of corresponding open and close brackets.
Returns 1 for valid brackets and 0 for invalid brackets.
"""
brackets = ['[' , ']' , '(' ,')', '{', '}', '<... |
3f3d7760636e874e01e669b22b63c439e3b1ee44 | MickeyYQ/PyTest | /test/test1.py | 547 | 4.03125 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
list = ['runoob', 786, 2.23, 'john', 70.2]
tinylist = [123, 'john']
print list # 输出完整列表
print list[0] # 输出列表的第一个元素
print list[1:3] # 输出第二个至第三个元素
print list[2:] # 输出从第三个开始至列表末尾的所有元素
print tinylist * 2 # 输出列表两次
print list + tinylist # 打印组合的列表
list = [] ## 空列表
list.appe... |
88059bbe5b3ca7052ada95e1a8bf3166d300e59d | RAYMOND-A/python-tipCalculator-project | /tipCalculator.py | 3,657 | 4.40625 | 4 | # Data types
# primitive data types
# String
name = "Hello"
print("first character is " + name[0])
print("Last character is " + name[-1])
print("123" + "345")
# Integers
print(123 + 456)
# Large integers
large_number = 123_456_789 # this helps humans to easily read large number values
print(large_number)
# Floa... |
19f751cf3378ae0cfa0ac2eacf44bd0946dfc4b5 | anuj0721/100-days-of-code | /code/python/day-55/print_stars_in_reverse_pyramid_shape.py | 202 | 4.0625 | 4 | rows = int(input("How many rows?: "))
k = 0
for row in range(rows,0,-1):
for col in range(0,k):
print(end=" ")
for col in range(0,row):
print("*",end=" ")
print()
k += 1
|
872e6db27e611b4033f31c1fae8f6d63d2603dcb | Teanlouise/Blackjack | /Hand.py | 2,280 | 3.96875 | 4 | class Hand:
""" A hand holds the cards that have been dealt to a player from the deck.
It also calculates the value of the those cards and adjusts for aces when
appropriate.
"""
def __init__(self, round):
self.cards = [] # start with an empty list
self.value = 0 # start with zero ... |
df43455f8cf5baca3c78cbf1303a0f8a5883c16f | ColeTrammer/cty_2014_intro_to_computer_science | /Day 3/My Programs/Python Project/Practice.py | 1,639 | 3.96875 | 4 |
def gcd_iterative(a, b):
if a > b:
range0 = a
elif b > a:
range0 = b
else:
return a
for i in range(1, range0):
if a % i == 0 and b % 1 == 0:
output = i
return output
"""
@param a first number to be computed
@param b second number to be computed
@return ... |
cd315782dd125609befb9b557ee39952d6abd69d | rahusriv/python_tutorial | /python_batch_2/class6/problem3.py | 943 | 3.859375 | 4 |
def modifyInteger(a):
#print(a)
a = 100
#print(a)
def modifyFloat(b):
b=2.5
def modifyString(s):
s = "Modified this"
def modifyList(l):
l.append("Addeed new value")
def modifyDictionary(d):
d[10]="Ten"
a = 10
print("Before function call : a = {}".format(a))
modifyInteger(a)
print("Afte... |
6a382dac739554fa0afadb206255f0e4413707f1 | Razcle/COMPGI99 | /AW-SGD for Model Free Rl/max_binary_heap.py | 2,273 | 3.703125 | 4 | import itertools
class max_binary_heap(object):
def __init__(self):
self.heap_list = [0]
self.heap_size = 0
self.counter = itertools.count()
self.d = {}
def is_empty(self):
if self.heap_size == 0:
return True
def swap(self,i,j):
sel... |
045f4904c71138abb0f84b47a24b1d1d991a69bf | FernandoFalcone-dev/exercicios-Python | /pacote-Download/pythontestes/desafio035.py | 351 | 4.0625 | 4 | print('-=-' * 15)
print('ANALISADOR DE TRIÂNGULOS')
print('-=-' * 15)
a = float(input('Primeiro segmento: '))
b = float(input('Segundo segmento: '))
c = float(input('Terceiro segmento: '))
if a + b > c and a + c > b and b + c > a:
print('Os segmentos PODEM formar um triângulo.')
else:
print('Os segmentos NÃO PO... |
5261a62ca3dac5eba058b1d78e539d2c79b1ced9 | stvnc/Python-Project | /Modul02/day02/weather.py | 905 | 3.734375 | 4 | from datetime import datetime
from dateutil import tz
import requests
apiKey = "5e155ca16611b1d08678b090b42129c6"
continentDictionary = {
1 : 'Asia',
2 : 'Europe',
3 : 'South America',
4 : 'North America',
5 : 'Africa',
6 : 'Australia',
7 : 'Antarctica'
}
print(continentDictionary)
conti... |
743ec5e5999b814eed8b10aa4fcf9413e3438d2a | cjbarb7/Python-Coding-Assignments | /first.py | 209 | 3.796875 | 4 | ##first assignment
##to add
##declare your variables
firstVariable = 5
secondVariable = 10
##adding the two variables
thirdVariable = firstVariable + secondVariable
##print to the screen
print thirdVariable |
1af62501c6e6aeb6c09952672a007cae3388b737 | masaponto/project-euler | /p002/p002.py | 273 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def solve(n: int) -> int:
a, b = 1, 2
s = 0
while a < n:
if a % 2 == 0:
s += a
a, b = b, a+b
return s
def main():
print(solve(4000000))
if __name__ == "__main__":
main()
|
29b3bea5abfe67c9b0b6484a7489458c772aea90 | KushRawat/CN-Python-Problems | /Find Character Case.py | 170 | 3.84375 | 4 | def printNum(x):
if 'A' <= x <= 'Z':
print(1)
elif 'a' <= x <= 'z':
print(0)
else:
print(-1)
char = input()
c = char[0]
printNum(c)
|
849acdc64d1620d7e97f92c9f95ad7382f7b0ab8 | Viscivous/Computer-Science-Exam---Semester-1 | /main.py | 2,608 | 4.25 | 4 | #### Describe each datatype below:(4 marks)
## 4 = integer (whole number)
## 5.7 = float (decimal number)
## True = boolean (True or false)
## Good Luck = string (Words or numbers)
#### Which datatype would be useful for storing someone's height? (1 mark)
## Answer - integer
#### Which datatype wo... |
fa9436c3905af2e55af27ae720edd5723c1c4828 | wuxu1019/leetcode_sophia | /medium/math/test_50_Pow(x,_n).py | 1,396 | 3.78125 | 4 | """
Implement pow(x, n), which calculates x raised to the power n (xn).
Example 1:
Input: 2.00000, 10
Output: 1024.00000
Example 2:
Input: 2.10000, 3
Output: 9.26100
Example 3:
Input: 2.00000, -2
Output: 0.25000
Explanation: 2-2 = 1/22 = 1/4 = 0.25
Note:
-100.0 < x < 100.0
n is a 32-bit signed integer, within the ... |
c445034de0ffaf04d0b3aac02ba17c9c89e1e04a | bing0109/learning2019 | /a_python_base_db/python_base/1124补充/1124-b08元组.py | 1,447 | 3.734375 | 4 | # coding=utf-8
# author = cjb
学习目标
掌握元组常见操作
课程内容
a.元组的定义
b.元组和列表的区别
c.创建元组
d.访问元组
e.删除元组
f.元组的索引和切片
g.补充
a.元组的定义
元组和列表类似,小括号表示元组,以逗号进行分割
(1,3,4)
('hai','jam')
b.元组和列表的区别
1.元组不可变,列表可变
2.元组速度快
处理动态数据时,需要经常更新数据,就用列表
敏感信息传递给一个不了解的函数时,希望这个数据不被修改,就使用元组
c.创建元组
注意,如果元组值包含一个元素,需要在后面加逗号以消除歧义
a = (1,... |
12f472b9e68d5d1171657b79ea9417a97cce9485 | mignev/mypy | /lib/file_utils.py | 389 | 3.75 | 4 | import os
def ropen(file_path):
""" Reading file backwards """
file = open( file_path, 'r' )
file_size = os.path.getsize( file_path )
file_range = range(file_size)
for i in file_range:
file.seek(file_range[-i])
char = file.read(1)
if char == "\n":
line = file.re... |
03bade0bf4d8951e6103fc6826a87bc5914b41f7 | syed-ali-jibran-rizvi/hacktober2021 | /Python/reversestring.py | 195 | 4.28125 | 4 | def reverse_string(str):
str1 = ""
for i in str:
str1 = i + str1
return str1
str = "potato"
print("default string is: ", str)
print("reversed string is", reverse_string(str))
|
ba94b42994e9cb551279e54f7105a46cb323e071 | rsummers618/rcfbscraper | /Old Stuff/NCAAsavant_Compiler/Stat_Compiler.py | 8,035 | 3.828125 | 4 |
import re
import csv
import C
from Team_Game_Stat import *
#=============================================================================================================
# FUNCTION DEFINITIONS
#=============================================================================================================
# Returns th... |
34d179893d6ff4cdeeae090d7810a7541eb71e50 | joekreatera/python_va_basic_python_2 | /23_01_2021/practice2.py | 441 | 3.640625 | 4 | from random import random
r = int(random()*100)
resp = int(input('Si piensas que mi numero es mayor a 60, responde (2) , si piensas que es menor a 40, responde (0), si piensas que está entre 40 y 60 responde (1)') )
if( resp == 0 and r < 40 ):
print("ganaste")
elif( resp == 1 and r <= 60 and r >= 40 ):
print(... |
3ff660418d259285c73f8cc5ff2e79ab764b349b | FeHioe/dymanic_programming | /coin_change.py | 474 | 3.578125 | 4 | def coin_change(change, coin_list):
store_coins = []
store_coins.append(0)
for i in range(1, change+1):
store_coins.append(-99)
for coin in coin_list:
if (i - coin >= 0) and (store_coins[i - coin] != -99) and (store_coins[i] > store_coins[i - coin] or store_coins[i] == -99):
store_coins[i] = 1 + store_c... |
9692f8269809ec0530a5523d4b9f159fa71e7c07 | tainenko/Leetcode2019 | /leetcode/editor/en/[2744]Find Maximum Number of String Pairs.py | 2,105 | 4.15625 | 4 | # You are given a 0-indexed array words consisting of distinct strings.
#
# The string words[i] can be paired with the string words[j] if:
#
#
# The string words[i] is equal to the reversed string of words[j].
# 0 <= i < j < words.length.
#
#
# Return the maximum number of pairs that can be formed from t... |
38d285df808be73f6358c3073bb6918a3cfaae77 | yurriiko/Aritmatika | /AritmatikaInput.py | 556 | 3.78125 | 4 | A = 8
B = 3
C = 2
print ("==== Program Aritmatika ====")
print (" Nilai A = 8")
print (" Nilai B = 3")
print (" Nilai C = 2")
print ("==== Hasil Perhitungan ====")
hasil = A + B
print ("A + B = ",hasil)
hasil = A - B
print ("A - B = ",hasil)
hasil = A * B
print ("A * B = ",hasil)
hasil = A / B
print ("A ... |
3cfa2b76a7997319e82c89c0730bdaf8669fd1c7 | AssiaHristova/SoftUni-Software-Engineering | /Programming Fundamentals/text_processing/replace_repeating_chars.py | 220 | 3.734375 | 4 | text = input()
text_list = [char for char in text]
for i in range(len(text_list) - 1, -1, -1):
if not i == 0:
if text_list[i] == text_list[i - 1]:
text_list.pop(i)
print(''.join(text_list))
|
7540fe1a9e3fa13febb60ce654c103910774b699 | Zavhorodnii/Project_Euler | /Exe_9.py | 681 | 3.90625 | 4 | from datetime import datetime
def start():
var = int(input("Enter value: "))
time = datetime.now()
point_1 = int(var/2)
while True:
point_2 = point_1 - 1
while True:
point_3 = var - (point_2 + point_1)
if point_3**2 + point_2**2 == point_1**2:
pr... |
3365bcddfa38bcfa2a5f966640d46e39e5f350f8 | dattran1997/trandat-fundamental-c4e17 | /Session1/Homework/multi_circle.py | 122 | 3.578125 | 4 | from turtle import *
speed(0)
for i in range (100):
color("yellow","yellow")
circle(50)
right(5)
mainloop()
|
5a9feae840ba3905fc7bcd9eacc6f728e84f8a81 | PetarSP/SoftUniFundamentals | /REGEX/4.Extract Emails.py | 331 | 3.640625 | 4 | import re
# email format: "{user}@{host}"
emails = input()
pattern = rf"(?P<Email>(?P<User>(?<=\s)[A-Za-z0-9]+[\.\-\_]*[A-Za-z0-9]+)\@(?P<Domain>(([A-Za-z\-?]+)[A-Za-z]+(\.[A-Za-z]+)+)))"
valid_emails = re.finditer(pattern,emails)
valid_emails = [valid_mail.group() for valid_mail in valid_emails]
print("\n".join(val... |
c1044e2a8330015c0c531e7f7618b0bfd5282680 | vunv2404/nguyenvanvu-fundamental-C4E22 | /session3/ex_2_list.py | 125 | 3.703125 | 4 | items = ["spire", "popcorn", "cocacola", "pepsi", "bread"]
print(items)
items.append(input("add your menu : "))
print(items) |
b126dd63f2090d0762e1f2f6b7b9f8a5182d9b24 | saikumar176/python | /eighteen.py | 238 | 3.8125 | 4 | less = int(input())
high = int(input())
for numb in range(less,high + 1):
sum = 0
temp = numb
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if numb == sum:
print(numb,end=" ")
|
f6a58cfb5c2f6b8dc80da9aed4777dac9c73f6c4 | ianzim/Calculadora | /mat_basica.py | 1,490 | 3.640625 | 4 | import math
def soma():
print()
s = 0
quant = int(input('Quantos números quer somar? '))
for cont in range(quant):
s += float(input(f'{cont + 1}º número: '))
return f'RESULTADO: {s}'
def subt():
print()
inicial = float(input('Digite o número inicial: '))
sub = float(input(f"{in... |
e4385f90b43900b52a40343fb1b8d5486f76f72b | AnetaFeliksiak/excercise_lists_1 | /file_manager.py | 729 | 4.03125 | 4 | def read_from_file(filename='default_words.txt'):
'''
Reads lists from file
>>> read_from_file()
[['aaa', 'bbbb', 'cccccc'], ['dd', 'eeeeee', 'fffffffff']]
'''
list_of_lines = []
file = open(filename, 'r')
for line in file:
line = line.strip().split(',')
stripped_element... |
6d78c9ca12a88cd35179f1a0eb2ce5faebc2e4e2 | SissonJ/tikTakToe | /tiktaktoe.py | 9,004 | 3.546875 | 4 | import numpy as np
import sys
def createGameBoard():
gameboard = np.empty([11,11],dtype=object)
counter = 1
for i in range(11):
#gameboard[i]=np.zeros(11)
for j in range(11):
gameboard[j,i]=' '
if i==3 or i==7:
gameboard[j,i]='-'
... |
986a73d1f3a05510f9f795d15cb7dd6f0553cb49 | alecvogel/hello-world | /a_vogel_wk6_lab5_A.py | 593 | 3.59375 | 4 | mexicoPop = int(1.21 * 10**8)
USPop = int(3.15 * 10**8)
years = 0
data = []
header = ['Year', 'Mexico Pop.', 'US Pop.']
data.append(header)
initial = [years, mexicoPop, USPop]
data.append(initial)
def computePop (mexicoPop, USPop, years):
while USPop > mexicoPop:
mexicoPop = mexicoPop * 1.0101
USPo... |
17de151f1647ab1e112c81a5de25d05867e642be | rblis/Python-Coding-Competitions | /Implementations/Naive_Hedging_Algorithm.py | 3,945 | 3.734375 | 4 | '''
Naive Hedging Algorithm
Programming challenge description:
Problem Statement
In order to properly offload risk, we need to implement a trading algorithm which places trades to offset the risk of incoming trades (this is called hedging). Each incoming trade has some risk associated with it, defined as quantity... |
baae332ba4e51d97e4f3b7e0490b22ea3edd8096 | md0505/blockchain | /src/wired3d.py | 847 | 3.71875 | 4 | '''
=================
3D wireframe plot
=================
A very basic demonstration of a wireframe plot.
'''
from utils import *
#from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
def plot3d():
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Grab some test data.
... |
ae09fac0b1e1aec153fee7fec4348e016705804c | CAM603/Python-JavaScript-CS-Masterclass | /Sorting/Python/selection_sort.py | 381 | 3.96875 | 4 | def selection_sort(arr):
for i in range(len(arr) - 1):
smallest = i
for j in range(i + 1, len(arr)):
if arr[j] < arr[smallest]:
smallest = j
if i != smallest:
arr[i], arr[smallest] = arr[smallest], arr[i]
return arr
print(selection_sort([4, 1, 3... |
fb9c31072184c7cb385cda3b5254a654d51df57e | qspin/python-course | /exercise10.py | 860 | 3.65625 | 4 | __author__ = 'kristof'
class Person(object):
def __init__(self, name, location):
self.name = name
self.goto(location)
def goto(self, location):
self.location = location
class RestrictedPerson(Person):
restricted_locations = ['Waardamme', 'Brugge', 'Ieper']
def __isallowed(self,... |
8aa192a61ccf1184faaf8e66f720babca5cbbdff | cameron-teed/ICS3U-6B-PY | /tet.py | 827 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by: Cameron Teed
# Created on: Nov 2019
# This program calculates the surface area of a tetrahedron
import math
def sa_calculator(height):
# calculates the volume
# process
sa = math.sqrt(3) * height**2
return round(sa, 2)
def main():
# This is asks for the us... |
f1a2ceeea899520d3a3a5b3f11c5599ff1ee4903 | apmcdaniels/CAAP-CS | /Lab2/Lab2/game/game.py | 1,873 | 3.828125 | 4 | # imports multiple clases from the python library and some of our
# own modules.
from sys import exit
from random import randint
from map import Map
from leaderboard import Leaderboard
from scores import Score
from game_engine import Engine
# global variables to keep track of score, player, and leaderboard
m... |
ceff82db2f42c5dd330d5f314e7098eb9814be66 | powerticket/algorithm | /Practice/실습/201105/그룹나누기_전원표.py | 694 | 3.765625 | 4 | def findTeam(team, x):
if team[x] == x:
return x
team[x] = findTeam(team, team[x])
return team[x]
def unionTeam(team, a, b):
a = findTeam(team, a)
b = findTeam(team, b)
if a < b:
team[b] = a
else:
team[a] = b
T = int(input())
for t in range(1, T+1):
N, M = map... |
fe9dcd36bd68918dc131efdecb2eb7efce7a8ce4 | ImLeosky/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/rectangle.py | 4,994 | 3.953125 | 4 | #!/usr/bin/python3
"""
Class Rectangle
"""
from models.base import Base
class Rectangle(Base):
"""
Class Rectangle that inherits from Base:
"""
def __init__(self, width, height, x=0, y=0, id=None):
"""
the class Rectangle that inherits from Base:
"""
super().__init__(i... |
601139d7c2c6e059af770e42a5b3d84803fe4023 | haafidz-jp/8-ball-pool-bot | /ball-vision/manual-labelling.py | 4,026 | 3.640625 | 4 | """
A script to allow the user to manually declare the centre of a ball and label it's type.
"""
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.image as mpimg
import os
# checksum, type, x, y
LABELS_FILE_HEADER = "filename,type,x,y"
LABELS_FILE = "./ball-labels.csv"
ball_data = {}
if os.pat... |
1e990387a600b5c749dcb0078471a269dc295dac | Kyam13/PythonStudy | /GUI/radio_button.py | 944 | 3.578125 | 4 | import tkinter as tk
#ラジオボタンに表示する文字列を用意
item = ['庭の掃除','窓拭き',' 車の洗車','庭のワックスがけ']
root = tk.Tk()
root.geometry('200x150')
val = tk.IntVar() #IntVarオブジェクトを作成して変数に代入
#ラジオボタンの作成と配置
#itemリストの要素の数だけ処理を繰り返す
for i in range(len(item)):
tk.Radiobutton(root,
value=i,
variable=val,
... |
621cc7bf0ca12c70df427453ff9c6f29e42b8f5e | Frost-Studios/seven_shell | /seven_shell.py | 4,898 | 4.0625 | 4 | """
Adam Cherun
1/23/2017
This project's purpose is to create a Python module that can process the English language.
----
TODO:
...
"""
class Base:
@staticmethod
def return_punc():
"""
purpose:
to return any possible pu... |
4fc3f6e1b7274ba9a319a562999d827f8fdf4104 | danylipsker/PYTHON-INT-COURSE | /DANY-PYTHAGORAS.py | 751 | 4.3125 | 4 | # Pythagoras example
from math import *
#from math import sin, cos, tan, asin, acos, atan
# input of dat from user
print('enter a')
a = int(input())
print('enter b')
b = int(input())
#squares calculation
sq_a = a * a
sq_b = b * b
#square root calculation
c = sqrt(sq_a + sq_b)
#angle calculation... |
1f661fb60808fe6be375d8f2aeaeb65254075aa6 | lily01awasthi/python_assignment | /27_replace_list.py | 641 | 4.1875 | 4 | """27. Write a Python program to replace the last element in a list with another list.
Sample data : [1, 3, 5, 7, 9, 10], [2, 4, 6, 8]
Expected Output: [1, 3, 5, 7, 9, 2, 4, 6, 8] """
def get_list():
no_of_items=int(input("enter the no of items you want in list: "))
inp_list=[]
for i in range(no_of_items... |
2550614df63557c6d26ed6e6758ec796c7c9bab6 | sunho-park/Notebook | /textbook/9_pandas2.py | 10,457 | 3.8125 | 4 | import numpy as np
import pandas as pd
# 지정된 인덱스와 컬럼을 가진 DataFrame을 난수로 생성하는 함수입니다
def make_random_df(index, columns, seed):
np.random.seed(seed)
df = pd.DataFrame()
for column in columns:
df[column] = np.random.choice(range(1, 101), len(index))
df.index = index
return df
# 인덱스와 컬럼이 일치하는 D... |
33b7ddb169e0830b2afddcf390157c936da345fe | PeterM358/python_advanced_r | /function_advanced/exe/1_even_numbers.py | 140 | 3.625 | 4 | def filter_even(iters):
return list(filter(lambda x: x % 2 == 0, iters))
number = map(int, input().split())
print(filter_even(number)) |
78e8d5feeadf26fb9245bb97a7166d783e2b9f22 | hujosh/magical_tests | /magical/items.py | 4,160 | 3.765625 | 4 | import random
import string
class Item:
''' This class represents an item.
Instantiating an object of this class without parametres creates a random, valid item.
'''
# order of attributes matters
ATTRIBUTES = ['itemName', 'price', 'friends', 'occasions',
'location', 'privacy',... |
717e7ec20933ee99fda0515d9d40970f20e07c95 | abs0lut3pwn4g3/RootersCTF2019-challenges | /forensics/stego2/audio_enc.py | 1,105 | 3.5625 | 4 | # We will use wave package available in native Python installation to read and write .wav audio file
import wave
# read wave audio file
song = wave.open("elliot_main.wav", mode='rb')
# Read frames and convert to byte array
frame_bytes = bytearray(list(song.readframes(song.getnframes())))
# The "secret" text message
st... |
0f7de0327a29dd96ddc3629f7100978a53684d6c | ParsaYadollahi/leetcode | /linked_list_cycle.py | 629 | 3.671875 | 4 | '''
https://leetcode.com/explore/interview/card/microsoft/32/linked-list/184/
'''
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def hasCycle(self, head: ListNode) -> bool:
node1 = head
node2... |
43428c3d82575a7f5d3d433650c49d4c2dc3db3a | BeninGitHub/Text.txt | /Ben's_Text.py | 576 | 3.640625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 20 19:30:42 2021
@author: bnzr
"""
def revword(word):
i=len(word)
newstring= " "
while i>0:
i =i-1
newstring = newstring + word[i]
return newstring.lower()
def countword()->int:
file= open('text.txt')
... |
435ddb313153c4674a2650ca3845ae576350ad07 | Mario263/Python-Projects | /RungeKutta.py | 1,113 | 4.09375 | 4 | #Numerical Integration
import math
def dydx(x, y):
return (y**2-2*x)/(y**2+x)
# Finds value of y for a given x using step size h
# and initial value y0 at x0.
def rungeKutta(x0, y0, x, h):
# Count number of iterations using step size or
# step height h
n = (int)((x - x0)/h)
# Iterate for number o... |
ae7afcbea41bcc6c19b48a73566044f7a1822b8c | yuhuanhuan36/test | /yhh/basic/TupleTest.py | 1,382 | 3.796875 | 4 | #coding utf-8
# @Time: 2019/9/4 15:58
# @Author: yuhuanhuan
#Python 的元组与列表类似,不同之处在于元组的元素不能修改。
# 元组使用小括号,列表使用方括号。
#元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可。
tup1 = ('Rita', 'honey', 1989, 2017)
tup2 = (1, 2, 6, 3, 5)
tup3 = ("a", "b", "c", "d")
print(type(tup3)) #<class 'tuple'>
#创建空元组
tup4 = ()
#元组中只包含一个元素时,需要在元素后面添加逗号,否则括号... |
a5726c3d881d201a8fee0aa975f7e2a204f7e9db | galid1/Algorithm | /python/baekjoon/2.algorithm/implementation/4659.비밀번호 발음하기.py | 1,538 | 3.640625 | 4 | import sys
def solve(word):
print_ans(word, decide_acceptable(word))
def decide_acceptable(word):
bef = ""
bef_type = ""
vowel_cnt = 0
continuous_cnt = 1
for c in word:
c_type = get_type(c)
if c_type == bef_type:
continuous_cnt += 1
else:
con... |
970cbdac0e6e3df54eb256296ff08ed501a7a359 | urbanfog/python | /60001x/person.py | 1,252 | 4 | 4 | import datetime
class Person (object):
def __init__(self, name):
""" Create a person with a name and birthday"""
self.name = name
self.birthday = None
self.lastName = name.split(' ')[-1]
def __str__(self):
""" returns self's full name as a string"""
return self.name
def __lt__(self, o... |
0c90f18ca9d342d2e1cb79aea646c1a9c1ae42bb | Zolton/Intro-Python-I | /src/05_lists.py | 816 | 4.25 | 4 | # For the exercise, look up the methods and functions that are available for use
# with Python lists.
x = [1, 2, 3]
y = [8, 9, 10]
# For the following, DO NOT USE AN ASSIGNMENT (=).
# Change x so that it is [1, 2, 3, 4]
# YOUR CODE HERE
x.append(4)
print("problem 1: ", x)
# Using y, change x so that it is [1, 2, 3... |
9e12596b80e910828f7a829a59a2a6883229c524 | erikoang/basic-python-b4-c | /Pertemuan2/formatting.py | 278 | 3.578125 | 4 | age = 36
tinggi = 167.23698478
text = "Umur saya adalah {} dan tinggi saya adalah {:.2f}".format(age,tinggi)
print(text)
#Atau
print("Umur saya adalah {} dan tinggi saya adalah {:.2f}".format(age,tinggi))
#p = 5
#l = 3
#print("Luasnya adalah {}".format(p*l))
#print(type(p)) |
2a8fab4974928abf54f942cc9ab6e2376edf13f4 | Mityai/contests | /camps/lksh-2015/AS.small/days-plans/01.bash/lection/python/operator.py | 502 | 3.8125 | 4 | # -*- coding: utf8 -*-
class Student:
def __init__(self, name, age) :
self.name = name
self.age = age
def __eq__(self, other):
return self.name == other.name
def __add__(self, other):
return self.name + other.name
def __str__(self):
return "Я оператор вывода! Меня зовут " + self.... |
3e723115a0087a4d5a175cdb4ee3bc227e411985 | Aiman-Jabaren/G13_ECE143_Project | /plot_us_maps.py | 3,345 | 3.625 | 4 | import plotly.plotly as py
import plotly.figure_factory as ff
import plotly.graph_objs as go
from plotly.offline import plot, iplot
import numpy as np
import pandas as pd
def plot_map(df,low,high,title='Diabetes'):
'''
Function to plot US map given a dataframe. Low and high values need to be specified for the ... |
1af27b0304b3f8e47c8710d82f320872597953a8 | HighEnergyDataScientests/bnpcompetition | /feature_analysis/correlation.py | 1,843 | 3.5625 | 4 | # -----------------------------------------------------------------------------
# Name: correlation
# Purpose: Calculate correlations and covariance
#
#
# -----------------------------------------------------------------------------
"""
Calculate correlations and covariance
"""
import pandas as pd
import numpy as n... |
9bba95356505288ab388a7d140e6379000dde932 | christina57/lc-python | /lc-python/src/lock/159. Longest Substring with At Most Two Distinct Characters.py | 928 | 3.71875 | 4 | """
159. Longest Substring with At Most Two Distinct Characters
Given a string, find the length of the longest substring T that contains at most 2 distinct characters.
For example, Given s = “eceba”,
T is "ece" which its length is 3.
"""
class Solution(object):
def lengthOfLongestSubstringTwoDistinct(self, s):
... |
2e2ec0ed26652d21ee1cf0cb0f92f5021c7daaf3 | Lmackenzie6/Year9DesignPythonLM | /practiceapr20.py | 1,180 | 3.640625 | 4 | import tkinter as tk
import tkinter.font as tkFont
def motion(event):
print("Mouse position: (%s %s)" % (event.x, event.y))
return
root = tk.Tk()
canvas = tk.Canvas(root, width=300, height=400)
canvas.pack()
canvas.create_rectangle(100,50,200,250, fill = "grey") #building frame
#row 1 squares
canvas.creat... |
adadd963dd7bf7570fdb2dbbe31cf757ec2f74b9 | unsalfurkanali/codeChallenge | /q3.py | 441 | 3.5 | 4 | def prime(x):
for i in range(2, x, 1):
if not x%i:
return False
return True
def palandoken(x):
strX = str(x)
for i in range(0, len(strX), 1):
if not prime(int(strX[0 : i : ] + strX[i + 1 : :])):
return False
return True
sum = 0
for i in range(10, 50000, 1):
... |
61b075ac3c8d941727b242b45a1deb6e7b4c6c19 | codengers/python | /findallposofsubstring.py | 398 | 4.09375 | 4 | #display all positions of sub string in string.
#Enter string and sub string below
str=input("Please enter string: ")
sub=input("Please enter sub string: ")
i=0
n=len(str)
flag=False
while i<n:
pos=str.find(sub, i, n)
if pos!=-1:
print("Here is sub string: ", pos+1)
i=pos+1
flag=True
... |
a3c02580ef17e8fe04ffee44fbecc29232cf3af5 | libertad78/START-UP-PYTHON | /practice2.py | 508 | 3.859375 | 4 | sentence = input("이름을 입력하세요 : ")
print(sentence)
print(sentence[0])
print(sentence[-1])
print(sentence[2:6])
print(sentence + sentence)
print(sentence * 3)
print(sentence, sentence)
word = sentence + sentence
word2 = sentence * 4
print(word)
print(word2)
print(sentence.count('u'))
print(sentence.... |
75a52e32f0a4a6d874747db04073d47d98ccd51f | starligtht/leson-12345-hw | /untitled0.py | 360 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jul 21 21:01:14 2021
@author: 88697
"""
score = int(input('enter grade 0-100 '))
if score >= 90:
print('A')
elif score >= 80:
print('B')
elif score >= 70:
print ('C')
elif score >= 60:
print('D')
elif score == 0:
print('what are you d... |
3a51f273bc062d37f0bd3c1d92845da67b2a752a | sakshi13-cmd/tathastu_week_of_code | /tathastu_week_of_cod/p5.py | 765 | 3.921875 | 4 | run_p1=int(input("enter the runs of p1 scored in 60 balls:"))
run_p2=int(input("enter the runs of p2 scored in 60 balls:"))
run_p3=int(input("enter the runs of p3 scored in 60 balls:"))
str_1 = run_p1 * 100 / 60
str_2 = run_p2 * 100 / 60
str_3 = run_p3 * 100 / 60
print("strike rate of player_1 is:",str_1)
print(... |
b1af9ed773b4ef987e2697582d7271ea6ce2fedf | Jhynn/programming-concepts-and-logic | /solutions/1st-operators/l1_a1.py | 127 | 3.953125 | 4 | a = float(input('Type a number, please: '))
b = float(input('Type another one: '))
print(f'The sum of {a} + {b} is {a + b}.')
|
dc843a37170e119aa17343390ecee461328424c8 | printfoo/leetcode-python | /problems/0026/remove_duplicates_from_sorted_array.py | 544 | 3.890625 | 4 | """
Solution for Remove Duplicates from Sorted Array, time O(n) space O(1).
Idea:
"""
# Solution.
class Solution:
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums: return 0
j = 0
for i in range(len(nums)):
... |
3169d504fde613f8da2e842c52441534554d708d | sheldonbarry/houseprice_ANN | /property-ann.py | 2,643 | 3.578125 | 4 | import pandas as pd
import matplotlib.pyplot as plt
from math import sqrt
from keras.layers import Dense
from keras.models import Sequential
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
# King County, Washin... |
59e790766d2345154b1afe9c09f2967e6f3157a7 | Velu2498/codekata-array-python | /14.py | 463 | 3.875 | 4 | """
Given a number N, print the odd digits in the number(space seperated) or print -1 if there is no odd digit in the given number.
Input Size : N <= 100000
Sample Testcase :
INPUT
2143
OUTPUT
1 3
"""
s=int(input())
v=[]
new=[]
sum=0
while(s > 0):
n=s%10
v.append(n)
s=s//10
v=v[::-1]
for i in range(len(v)):... |
0f14fc742270beea34abe3b5b53b9c72043f8cde | AswinBarath/python-dev-scripts | /II OOP/Exercise_Extending_List.py | 355 | 3.9375 | 4 | class SuperList(list):
def __len__(self):
return 1000
super_list1 = SuperList()
super_list1.append(5)
print(super_list1)
print(len(super_list1))
print(super_list1[0])
print(issubclass(SuperList, list))
print(issubclass(list, object))
# Note: Everything in Python is an object
# that inhe... |
d157f804c04b756961316969b77774496803acab | tlops/Python-4-web | /wk6-jsonAssg.py | 1,067 | 4.0625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# programming for web by Dr chuck
# University of Michigan
# Written as an assignment by Tlops
# Nov. 2015
# what this code does:
# The program will prompt for a URL, read the JSON data from that URL
# using urllib and then parse and extract the comment counts ... |
408e076994da64a308a6dcfdbbfc4b8905c0d354 | dw2008/coding365 | /201904/0416.py | 420 | 4.09375 | 4 | #Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.
#Example 1:
#Input: [-4,-1,0,3,10]
#Output: [0,1,9,16,100]
#Example 2:
#Input: [-7,-3,2,3,11]
#Output: [4,9,9,49,121]
numbers = [1, 2, 3, 4]
def returnIntegers(alist) :
re... |
4ff27ec4413426a99af324eb0c332976415a3325 | touhiduzzaman-tuhin/python-code-university-life | /Practice_StartBit/60.py | 174 | 3.53125 | 4 | li = [1,2, 3, 4, 5.5, 9, 3.3, "tuhin", 3+8j]
print(li[2])
print(li[4])
print(li[7])
print(li[8])
print(type(li[0]))
print(type(li[4]))
print(type(li[7]))
print(type(li[8])) |
535471fc720afe2fdb719914de980b2253749e0e | sidv/Assignments | /sufail/aug19/rectangle.py | 1,000 | 4.09375 | 4 | class Rectangle:
"""implementing doc"""
def __init__(self,length,width):
self.length=length
self.width=width
def area(self):
return self.length*self.width
def __add__(self,r2):
return self.length+self.width+r2.length+r2.width
def __str__(self):
return f"The lenth is {self.length} breadth is {self.width}... |
e9721d343c364835051660250c0308c512b9e6dd | chloemcgarry/project-pands | /scatterplotpl.py | 419 | 3.921875 | 4 | #Importing pandas library
import pandas as pd
#Importing matplolib library
import matplotlib.pyplot as plt
#Read csv file and call it data
data = pd.read_csv('iris_data_set.csv')
#labelling x axis and y axis
x = data.species
y = data.petal_length
plt.scatter(x,y)
#Naming the scatter plot of the petal length data
... |
d7f5ae2690b1d87e93b9a8c625353998f036750f | Svalorzen/morl_guts | /gp_preference/pymodem/Value.py | 7,354 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 22 15:51:03 2016
@author: Diederik M. Roijers (University of Oxford)
"""
import numpy
def maxDifferenceAcrossObjectives(vector1, vector2):
"""
Returns the maximal difference across objectives between a vector v
another vector ... |
d27d8063a24b81763cb353565f47243b6236c5b4 | Stranger65536/AlgoExpert | /hard/maxPathSum/program.py | 2,412 | 4.15625 | 4 | #
# Max Path Sum In Binary Tree
# Write a function that takes in a Binary Tree and returns its max
# path sum.
#
# A path is a collection of connected nodes in a tree where no node
# is connected to more than two other nodes; a path sum is the sum of
# the values of the nodes in a particular path.
#
# Each BinaryTree n... |
5276a5e03f4c39a6f4e3451ed21da74c47ccddfc | joostgrunwald/data-visualization | /data_vis.py | 12,299 | 3.546875 | 4 |
from matplotlib import pyplot as plt
from prettytable import PrettyTable
# * Seaborn dependencies
import pandas as pd
import numpy as np
import seaborn as sns
# * Settings
show_matplotlib = False
show_seaborn = True
if (show_matplotlib == True):
#?############
#* HISTOGRAM #
#?############
# value... |
d2f0a5e3dcf6ec822a4f97f6b0cc04eecbf7103e | ahmadner/python_apps | /login.py | 867 | 4.03125 | 4 | #username = admin
#password = 123
#|===================|
#| coder : ahmadNer |
#|===================|
print ("\n")
username = input("Enter The Username: ")
password = str (input("Enter The Password: "))
count = 3 #num of trys
while username != "admin" or password != "123":
count -=1
if count == 0:
p... |
6aa428adbaee825aca2d1c9b426743bcb980e028 | Mohit130422/python-code | /pm.py | 269 | 3.640625 | 4 | def main():
a=1
b=101
for i in range(a,b):
f=0
for j in range(2,(i//2)+1):
if(i%j==0):
f=1
break
if(f==0):
print(i,' is prime')
if __name__=="__main__":
main() |
82b60e82f253894c40f29b28cc744abcf6ad1b84 | g1isgone/stanford_algorithms_specialization | /course1/karatsuba_algorithm.py | 2,747 | 3.734375 | 4 | '''
==================================================================================
Date: 05/02/2020
==================================================================================
Implementation of the Karatsuba algorithm
Practice of a divide and conquer approach
===============================================... |
a09c639cfdb0ee063669d40b6902884e832f5c51 | JohnWFraser/PBD_JF | /CA3_final/Rental2_JFraser.py | 5,931 | 3.75 | 4 |
from carR1_JFraser import Car, ElectricCar, PetrolCar, DieselCar, HybridCar
class Dealership(object):
def __init__(self):
self.electric_cars = []
self.petrol_cars = []
self.diesel_cars = []
self.hybrid_cars = []
self.electric_rentlist = []
self.electric_customerlis... |
1793db68820fc49c61234694ec2d5468228c142e | DanielPra/-t-Andre | /18if.py | 1,436 | 3.515625 | 4 | # Bulls räknas inte korrekt
# The number generated by the computer is 4162
# Guess four digits: 4444
# We got 1 cows
# We got 3 bulls
import random
import string
cows = 0 # Correct digit AND correct place
bulls = 0 # Correct digit NOT in correct place
def randomString(stringLength=4): # Generera lottonummer
numb... |
91d28e54cb60845d345984066077f4e033c706f0 | PanMaster13/Python-Programming | /Week 2/Tutorial Files/Week 2, Exercise 5.py | 259 | 3.96875 | 4 | import datetime
now = datetime.datetime.now()
app_name = input("Enter the applicant's name:")
int_name = input("Enter the interviewer's name:")
print(int_name, "will interview", app_name, "at 9.30 am on", now.year,
"-", now.month + 1, "-", now.day)
|
fb5fe3a6388547106a27748095fa19915562a416 | CodeCure-SMU/DS-and-Algorithm-2021 | /choiyoungho/Baekjoon_5885_youngho.py | 306 | 3.515625 | 4 | import sys
N = int(sys.stdin.readline()) # 1 <= N <= 100
for i in range(N):
for j in range(N - i - 1): # 왼쪽 별
print(" ", end='')
print("*", end='')
for j in range(i * 2 -1): # 오른쪽 별
print(" ", end='')
if i == 0: # 0일경우 별이 곂침.
print() # 엔터
continue
print("*")
|
72823db699fa2777ac27483d2a55c886ee8608f4 | repinnick/teachmeskills | /day4/ex4_matrix.py | 759 | 3.875 | 4 | import random
def generate_two_matrix():
data = [] # первая матрица
data2 = [] # вторая матрица
for i in range(3):
pstr = []
for j in range(3):
number = random.randrange(1, 10)
pstr.append(number)
data.append(pstr)
for i in range(3):
pstr2 = []
... |
2fd6460887a75c7aa039cb8ff53fa9e8861829d3 | Nazdorovye/VeAPython | /2020_lecture_13_tasks/py_turtle/task04.py | 493 | 3.578125 | 4 | from circle import Circle
from point import Point
from random import randint
RC = 200
HW = 250
HH = HW
POINTS = 20
crcl = Circle((0, 0), RC)
points = [Point((randint(-HW, HW), randint(-HH, HH))) for _ in range(POINTS)]
print("Canvas bounds <(x0=%d, x1=%d)(y0=%d, y1=%d)>" % (-HW, HW, -HH, HH))
print("Bounding circle ... |
55bb929827ec125535244bc27c7dcef41011763d | Dwxasd/MWMTrackingSoftware | /cnn.py | 963 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Code used for object tracking. Primary purpose is for tracking a mouse in
the Morris Water Maze experiment.
cnn.py: this file contains the code for implementing a convolutional neural
network to detect a mouse location during swimming during the tracking.
"""
class... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.