blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
97c8cb73ed833951c902a5487524ce4b9e1a2e82
Luiz719/DBPerfumes-LuizGonzaga
/BDPerfumes/data.py
1,469
3.734375
4
import sqlite3 def titulo(n, s, p, tabela): print('=' * n) print(f'{s}'.center(n)) print('=' * n) e = '' while e not in ("S", "N"): e = input(f"Cadastrar nova(o) {p}? [S/N]").upper().strip() if e == "S": i = 1 while True: nome = input(f"Digite o nome da(o) {...
28c79d41627fa49afae77aec687575769a8c7df3
gjwei/leetcode-python
/easy/Reverse String.py
296
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ created by gjwei on 3/29/17 """ class Solution(object): def reverseString(self, s): """ :type s: str :rtype: str """ return ''.join(s[::-1]) s = "hello" so = Solution() print so.reverseString(s)
7af813b3cba7c6311cea0578e130f5b05484fa28
parkyujin/Python
/test14.py
274
3.5
4
# 랜덤 로또 번호 from random import randint cnt = 0 lot = '' for x in range(100) : rand = '{:02}'.format(randint(1,45)) if rand + ' ' not in lot : lot = lot + rand + ' ' cnt = cnt + 1 if cnt == 6: print(lot) break
40f770744f5be5bf9f38675b20126cfb83a73040
noahh40/Sprint-Challenge--Algorithms
/recursive_count_th/count_th.py
741
4.1875
4
''' Your function should take in a single parameter (a string `word`) Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters. Your function must utilize recursion. It cannot contain any loops. ''' def count_th(word): #bsae if "th" not in word: return 0...
c67fbfcbb0cf264f317269417447aaadd8a3901b
jeancharlles/jc_github
/exercício datacamp.py
80
3.71875
4
a='2' print (a*int(a)) print(type('5')) n='1' m='3' print(n+m) a='b' print(a*2)
4d3f3bd6fe9affcc5b0bff6b53825fdb398090c5
Ryan-Nguyen-7/ICS3U-Unit-2-01-Python
/circle_area_perimeter.py
395
3.921875
4
#!/usr/bin/env python3 # Created by Ryan Nguyen # Created on November 2020 # This program calculates area and perimeter of a circle def main(): # this function calculates A+P import math print("If a circle has a radius of 15cm") print("") print("Area is {}cm^2".format(math.pi*15**2)) print("P...
526a9b131d8af00fadd0190f27b7119441d9c360
Beckat/Tic-Tac_toe
/GameEngine.py
6,430
4.03125
4
import GameBoard as Board import numpy as np import random as rand import gym class GameEngine(gym.Env): """ Holds logic to run the tic-tac-toe game using the GameBoard class """ def __init__(self): self.game_board = Board.TicTacToe() self.action_space = gym.spaces.Discrete(9) ...
6baa3db2f0c584bcb8c325b3a1bbf51469845efb
sramego/code_samples
/loop_ll.py
1,418
4.03125
4
# Detect loop in a linked list class Node(): def __init__(self,data): self.data = data self.next = None class LinkedList(): def __init__(self): self.head = None def push(self,data): new_node = Node(data) new_node.next = self.head self.head = new_node def detectRemoveloop(s...
a86107e5adb54ca096f02c02a31ddb3d214afbf2
lordpews/python-practice
/oops9.py
789
4.25
4
class Dad: basketball = 233 class Son(Dad): dance = 32 basketball = 32 def isd(self): print(f"i dance like a nitch {self.dance}") class Grandson(Son): dance = 2 def isd(self): print(f"i dance like a ditch balle balle romance on the bhangra floor" f"{self.dance...
973442b29a480585323e6e6733f01091797d3054
junyang10734/leetcode-python
/844.py
551
3.59375
4
# Backspace String Compare # Two Points / Stack # https://blog.csdn.net/fuxuemingzhu/article/details/80643408 # runtime: faster than 42.42% class Solution: def backspaceCompare(self, S: str, T: str) -> bool: res1, res2 = [], [] for i in S: if i != '#': res1.appe...
5030de82e7c89cb9eb8246dc8e2014e35ebafb06
LeopoldACC/Algorithm
/树/116填充每个节点的下一个右侧节点.py
568
3.5
4
class Solution: def connect(self, root: 'Node') -> 'Node': if not root: return None q = collections.deque([]) q.append(root) while q: pre = None for i in range(len(q)): t = q.popleft() if i==len(q)-1: ...
4169cad9554ee4f9467d0c5e6d35eb4f9c540cf2
durgas4/Python---DS-and-Algo-assignments-
/solution4.py
4,712
4.34375
4
#1 #Write a Python function histogram(l) that takes as input a list of integers #with repetitions and returns a list of pairs as follows:. #(1)for each number n that appears in l, #there should be exactly one pair (n,r) in the list returned by the function, where r is the number of repetitions of n in l. #(2)t...
c92046f3add8e238c9985278783269a69013ee20
ActonLeBrein/data-structures
/BinaryTreeClass.py
12,315
3.6875
4
# Script text here class BinaryTree: def __init__(self): self.tree = [] self.values = {} self.root = None def getdad(self, node): i = 0 c = None if self.nodein(node): while i < self.treelen(): if node in self.tree[i...
69e9d06437063acaa760f57d4e90d78069724d97
muhzulfik/python-dasar
/function.py
935
3.859375
4
# creating a function def my_function(): a = 20 b = 'Hello from a function {}' print(b.format(a)) # calling a function my_function() # Argument def my_hero(fname): print(fname + ' marvel') my_hero('thor') my_hero('iron man') # Arbitary Arguments def my_name(*kids): print("The youngest child is ...
670e9e814ea3711fa3d3993af2aafebdc561c105
RuijieZ/interview_prep
/byte_by_byte/validate_binary_search_trea.py
797
4.1875
4
# given a tree, write a function to validate if a given tree is a binary search tree class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def validate_tree(tree): if tree is None: return True if tree.left is not None and tree.left.value > ...
4b4c44666e81f1ebb73467806fc57d6627315cc3
larisachelba/se-python-homework
/session2/ex2.py
498
4.21875
4
""" Ex. 2: Modificati urmatoarea bucata de cod astfel incat la rulare, rezultatul afisarii sa fie cele 2 liste concatenate. HINT: Exista mai multe moduri prin care puteti face asta. """ # Ii dam variabilei l1 ca si valoare o lista cu 4 elemente (1,2,3,4) # si variabilei l2 ca valoare o lista cu 4 elemente (...
2a777a3c1b01c89ac9e3a348284f09f67b6f999f
LeonhardtWang/leetcode-train
/python/384_shuffle.py
1,401
3.640625
4
# 方法一 class Solution: def __init__(self, nums: List[int]): self.init_nums = [num for num in nums] self.nums = nums def reset(self) -> List[int]: """ Resets the array to its original configuration and return it. """ return self.init_nums def shuffle(self) ->...
387303edeaeaa9c492b46086817506fa42b25d97
vermuz/python_learning_source_code
/threading_queue.py
866
3.625
4
__author__ = 'kathiria' import threading import time import Queue job_queue = Queue.Queue() class count_stuff(threading.Thread): """ A thread class that will count a number, sleep and output that number """ def __init__(self, start_num, end, q): self.num = start_num ...
48c121749ea778d12a11f98aeb4b35e52e4672c8
Kwabena-Kobiri/FibonacciApp
/.history/Fibonacci_20210711074822.py
667
4.09375
4
from tkinter import * root = Tk() root.title('Fibonacci Number Finder') root.geometry('500x300') def button_command(): print("test") return None header_label = Label(root, text='This is a Simple Program to find the values of a \ngiven index in a Fibonacci sequence from 1 to 24', font=...
9c098ed122ce5833b718e7f697a2f9b4c8ff785e
brianmcguckin/UdemyPythonExercises
/inputValidation.py
960
4.375
4
#Test whether user input is valid #if not return error message and ask again print("Enter first side length: ") lengthOne = 0 #defining variable to get to loop while lengthOne <= 0: lengthOne = int(input()) #redefining variable to user's input if lengthOne >0: print("Enter second side length: ") #...
8a20fd378f07e1d71c99789eb85e9a84dc251a5a
Aasthaengg/IBMdataset
/Python_codes/p03379/s992841600.py
310
3.640625
4
N, *X = map(int, open(0).read().split()) sorted_X = sorted(X) median_l = sorted_X[N // 2 - 1] median_r = sorted_X[N // 2] for x in X: if x < median_l: print(median_r) elif x == median_l: print(median_r) elif x == median_r: print(median_l) else: print(median_l)
0fb8dccb2b62b1c8d17ed6176a6cf1015883af65
dingsheng824693909/gy-1908A
/demo/day01/yunsuan_py.py
476
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #__title__ = '' #__author__ = 'xuepl' #__mtime__ = '2019/9/4' a = 2 b = 4 c = 3 print(a+b-c*b/a%a) print(a/c) print(a > b) print(a < b) print(a == b) print(a != b) print(a >= b) print(a <= b) aa = [1,2,3] print(2 in aa) kk = {"名字":"牛牛","组别":"牛组"} print("名字" in kk) #...
6367c0866a61a5b337c700fbac11da932ff4e725
CyrilWendl/SIE-Master
/density_forest/build/lib/density_forest/create_data.py
6,575
3.65625
4
"""Functions to generate test data""" import numpy as np def rotate(origin, point, angle): """ Rotate a point counterclockwise by a given angle around a given origin. :param origin: Origin around which to rotate :param point: data point :param angle: angle, should be given in radians :return: ...
9809b963af619e4182bccdf154f9861c84c50fba
ggrecco/python
/scrapy/brincando/teste.py
119
3.5
4
a = ['a','b','c'] b = ['1','2','3'] d = [] i = 0 while i < len(a): c = (a[i], b[i]) d.append(c) i = i + 1
00240ffeb58c581f8decdad2c58a23976f01dab7
Prabhjot642/trantor-bootcamp
/main.py
299
3.796875
4
def sort(nums): #numbers changed for i in range(5): minpos = i for j in range(i,6): if nums[j] < nums[minpos]: minpos = j temp = nums[i] nums[i] = nums[minpos] nums[minpos] = temp nums = [2,4,1,3,6,5] sort(nums) print(nums)
4d5c1988dc70f7c2dbbeb23068f71088f7c40492
ed1rac/AulasEstruturasDados
/UNP/ref/Python/TADs e Classes/converte_base.py
656
3.890625
4
from pilha_dinamica import Stack def ler_numero(): return int(input('Digite um número inteiro: ')) def ler_base(): return int(input('Digite a base para conversão: ')) def converter(num, base): pilha = Stack() numero = num while numero != 0: x = numero resto = x % base nume...
00db63a7bc92923307645b23fb8b6f14f04a8750
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_118/2359.py
322
3.90625
4
def palindrome(num): if(num<10): # print "single digit" return 1 s = str(num) length = len(s) #print s i=0 result = 1 halflenth = length/2 # print "length and halflength ", # print length, # print halflenth while(i<halflenth): if(s[i]!=s[length-i-1]): result=0 return result i=i+1 return resul...
e88927aa08da318f958df94f68bbe1365d9a0a5d
ArbyC/Learn_khwopa
/Assignment_6/q2.py
686
3.609375
4
class Vehicle: def __init__(self, name, v_speed, manufacturer): self.name = name self.v_speed = v_speed self.manufacturer = manufacturer def speed(self): return print(f'The speed is {self.v_speed} kmh') class Car(Vehicle): def __init__(self, horsepower=1176, name='Koenigse...
b8d1e0dae9a61388ea49d824aeb61fe8329e6431
dentalmisorder/PythonUdemy
/basics (not actual projects)/regular_expressions.py
1,622
3.8125
4
import re pattern = r"\d\d\d-\d\d\d-\d\d\d\d" pattern2 = r"\d{3}-\d{3}-\d{4}" #same as before but more clear (and better cause scalable) pattern3 = re.compile(r"(\d{3})-(\d{3})-(\d{4})") #compile into Pattern Obj with 3 groups to call them separately pattern4 = r"call (me|him|her|my|them|they|your)" #basically an | or...
a8cab3b17f703c7d724be860e39c66a4b6c1ee2c
raopg/algorithm-solutions
/MyWorksheet/Trees/Tries/trie.py
1,031
4.15625
4
## Implementation of the Trie data structure. class TrieNode: def __init__(self, val): self.val = val self.children = {} self.end = True class Trie: def __init__(self): self.root = TrieNode(None) def insert(self, word): parent = self.root for i, char in...
bfa5b9d31099c335752c2185d6d683e1f6d1aa45
darkless456/Python
/search.py
742
3.515625
4
# search.py import os # 引入os模块 def Search(rootDir, suffixes, arg): for lists in os.listdir(rootDir): path = os.path.join(rootDir,lists) if os.path.isfile(path): if path.endswith(suffixes): try: with open(path, encoding='utf_8') as fh: ...
1ea392db15c609f3d8618d67e2d818883ea8c888
Zarkrosh/AoC-2018
/dia2/dia2_p1.py
794
3.890625
4
# Advent Of Code: Dia 2 - Primera parte # Devuelve tupla de dos enteros, 0 o 1 dependiendo de: # Primer valor: 1 si la cadena contiene exactamente 2 ocurrencias # de una letra cualquiera, 0 si no. # Segundo valor: 1 si la cadena contiene exactamente 3 ocurrencias # de una letra cualquiera, 0 si no. def fun(cadena)...
935973bc71b2f3b03a2e7a6e33e939b28977a268
ricardoruiz2897/Get-TABE-results
/cleaner.py
3,490
4.0625
4
#This function will return true if it finds a section, and false if it doesn't. def found_section(line): #Sections of the test. sections1 = ["Reading", "Language"] sections2 = ["Math", "Compu", "Applied", "Math"] if (sections1[0] in line) or (sections1[1] in line) or (sections2[0] in line and sections...
af5ee65de84350b4770946576b6ba26b565f124d
Neshametha/Lab-1-Python-Exercises
/Lab1Question4.py
272
3.875
4
'''Yamil Galo''' '''Ketul Polara''' '''Stuart Simmons''' '''Natalie Whitehead''' name = str(input("What is your name?")) age = int(input("What is your age?")) differnce = int(100 - age) AfterAge = int(differnce + 2019) print("Hi " + name + ", you will turn 100 years old in year " + str(AfterAge))
3df27ef16ee25682d2e40528707997dad764862b
neerajkumarTTN/oops1olution
/Q2private.py
358
3.53125
4
class Base: def fun(self): print("Public method") def __fun(self): print("Private method") class Derived(Base): def __init__(self): Base.__init__(self) def call_public(self): print("\nInside derived class") self.fun() def call_private(self): self.__fun() obj1 = Base() obj1.fun() obj2 = Derived() ob...
4a661d78f3a269b45869316c7fb8c70e649eaf3c
martinsyx/pythonStudy
/gil/tread_condition.py
1,051
3.640625
4
import threading from threading import Condition # 条件变量 用于复杂的线程间同步 class XiaoAi(threading.Thread): def __init__(self,cond): super().__init__(name="xiaoAi") self.cond= cond def run(self): with self.cond: self.cond.wait() print("{}:zai".format(self.name)) ...
4b69dff9b8537a50bf6fb1ff00710db94876790c
Prabithapallat01/pythondjangoluminar
/pythoncollections/sets/work1.py
272
3.84375
4
students_names={"alan","aleena","ram","leena","jins","jimmy","jhon","Neena","Mega"} failed_stud={"Mega","leena","ram"} diff=students_names.difference(failed_stud) print("passed students:",diff) inter=students_names.intersection(failed_stud) print("failed students:",inter)
d40932c8f4c6ab238645fe51f6df7bf10648596a
osmarsalesjr/SolucoesUriOnlineJudgeEmPython3
/1253.py
581
3.578125
4
def main(): testes = int(input()) for j in range(testes): texto = input() qtd = int(input()) palavra = "" contador = 0 for i in range(qtd): for n in range(contador, len(texto)): for z in range(97, 123): if texto[n].upper()...
1d076dbd7a79b45755ff27ea732d3a880546298b
dachen123/algorithm_training_homework
/week3/rob-II.py
560
3.546875
4
#打家劫舍版本II class Solution: def _rob(self,nums): first,second = 0,0 for num in nums: first,second = second,max(second,first+num) return second def rob(self, nums) -> int: if not nums: return 0 return max(self._rob(nums[1:]),self._rob(nums[:-1])) if l...
25f01f4be06fd277be72a3508505743284c7f573
neo4reo/euler
/eulerlib.py
3,021
3.84375
4
''' The purpose of this module is to collect functions that are useful for solving project euler problems. For example, many of the euler problems invole primes, hence many prime functions are collected here. Code aggregated and/or written by Justin Ethier ''' #import itertools import math from functools imp...
ebc096f8125f6e1965c4f932ce0865881af9692d
timo-bronseth/student-record-manager
/src/StudentRecordClass.py
8,201
3.90625
4
# ------------------------------------------------------------------------------------- # Timo Brønseth, January 2020. # ------------------------------------------------------------------------------------- # Function name starts with an underscore to indicate that it's for internal # module use only. It gets exclude...
74e8d1b816bf18ee8f2206198750040cba364fca
kristinnk18/NEW
/Skipanir/strings/collect_digits.py
504
4.0625
4
# Given a string of any length, extract the numbers (digits) and print them on one line without spaces. # Hint 1: start with an empty string # Hint 2: isdigit() is your friend. # For example, given this string: # some 1! likes 2 put 14 digits, in 3 strings # the output will be # 12143 s = input("Input a string: "...
fa3c2d46651f32c714ab0ea71fd4c90dee66ab2c
crystaljluo/testing-testing
/fizzbuzz.py
283
4.0625
4
i = int(input("Enter a number: ")) for n in range(1,i+1): if n%3 == 0 and n%5 == 0: print("FizzBuzz") continue elif n%3 == 0: print("Buzz") continue elif n%5 == 0: print("Fizz") continue print(n)
19fa2f4c6c6de382b05c8f8ced976bc2371c4d43
manoharaswal/TechgigSolution
/Python/StringMinimum.py
257
3.78125
4
def main(): string = input().strip() string = string.replace(" ","") cap = min(string) string = string.lower() low = min(string) if low < cap.lower(): print(low, end='') else: print(cap, end='') main()
ddd047b92e1aa5863a35d212f3a40dfc2f3b8ee7
niamhmc99/isogram
/isogram.py
451
4
4
def is_isogram(string): #creating a set of letters in the string letters = set() string = string.lower() #iterate over character in word for character in string: if not character.isalpha(): continue #if find character already remembered return false ...
a4c5e78a810fd29dae80840d8f9e9e3b8e888a40
thewinterKnight/Python
/dsa/Linked Lists/3.py
1,550
4.5
4
# How do you reverse a linked list using recursion? import copy class Node: def __init__(self, data=None, next=None): self.data = data self.next = next def get_data(self): return self.data def get_next(self): return self.next def set_next(self, new_node): self.next = new_node class LinkedList(Nod...
6ed11238ee798b8eed59679c96073041303a759a
HarshaaArunachalam/guvi
/code/20.py
67
3.640625
4
a=int(input()) for i in range(1,6): p=a*i print(p,end=" ")
7f8e74a48330c35959b09170740a383bbf9650b7
booratello/Python_Algos
/Урок 2. Практическое задание/task_8/task_8_1.py
2,767
3.8125
4
""" 8. Посчитать, сколько раз встречается определенная цифра в введенной последовательности чисел. Количество вводимых чисел и цифра, которую необходимо посчитать, задаются вводом с клавиатуры. Пример: Сколько будет чисел? - 2 Какую цифру считать? - 3 Число 1: 223 Число 2: 21 Было введено 1 цифр '3' ЗДЕСЬ ДОЛЖНА БЫ...
fcd060dfd1ae54776a22af1d5713bf320af582b9
ramyaramy/ramya
/p9.py
352
3.5625
4
def main(): start,end=input().split(" ") start=int(start) end=int(end) list=[] for num in range(start,end+1): if num > 1: for i in range(2,num): if (num%i)==0: break else: list.append(num) print(len(list)) if __n...
461cb59ef21e5edcd2d875a8c6988604987bca50
amisha-tamang/IF_ELSE_Python
/ladkiya jada hai ya kam (copy).py
202
3.953125
4
# num=int(input("enter the number")) # if num>12: # print(num-12," lrkiya 12 se jada hai") # elif num<12: # print(12-num, "larkiya 12 se kam hai") # else: # print(num,"is equal to 12")
4db759a96c882736c2e3d193a3e0d15784cd33b6
biwana/fixmatch
/libml/helper.py
1,421
3.71875
4
def color_to_num(color): if color == (200, 200, 200): num = 0 elif color == (255, 0, 0): num = 1 elif color == (255, 255, 0): num = 2 elif color == (0, 255, 0): num = 3 elif color == (0, 255, 255): num = 4 elif color == (0, 0, 255): num = 5 eli...
3c9eb863ebe17443200ad0778015a0edd9b6f5dd
atm1992/nowcoder_offer_in_Python27
/p21_backtracking/a2_movingCount.py
1,681
3.59375
4
# -*- coding: UTF-8 -*- """ 机器人的运动范围。 地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38),因为3+5+3+8 = 19。请问该机器人能够达到多少个格子? 解题思路:类似于上一题。 """ class Solution: def movingCount(self, threshold, rows, cols): if threshold < ...
b6355f14e98be9d83ea295e45cbd7c66b2bfc606
rohan-blah/ducs_source_code
/python/practical/annexure/prac6xprac7.py
400
4.125
4
def func(n): list=[] #fibbonacci number n1,n2=0,1 x=n-2 while x!=0: nth=n1+n2 n1=n2 n2=nth x=x-1 list.append(nth) #factorial of nth fact=1 while(nth>0): fact=fact*nth nth=nth-1 list.append(fact) return list num=int(input(''...
e27a5864eef91b6987e7911139cb54f2c11ecd35
AbhiniveshP/BFS-3
/RemoveInvalidParenthesis.py
2,780
3.796875
4
''' Solution: 1. Perform a BFS for this question as we require to remove least number of parenthesis. 2. We create one level extra by removing one of the parenthesis and if at any level, we find a valid parenthesis, we stop at that level and add all valid strings to the resultant array. 3. At each level, we a...
2e9aebfc3667118a25668cc737d6ea3d004783df
flyfatty/PythonTutorial
/leetcode/backtrace/46.py
851
3.65625
4
# @Time : 2020/10/15 9:19 # @Author : LiuBin # @File : 46.py # @Description : # @Software: PyCharm """全排列 关键字: 回溯 思路: 1、维护已经做出的选择列表(路径) 2、找到当前的可选择列表(剩下的可选数字) 3、没有选择的时候保存当前的选择列表(路径) 4、回溯表示已选择列表和可选择列表需要回退到当前做出选择之前的状态 """ from typing import List class Solution: def permute(self, nums: List[int]) -> List[List[int]]...
782dd0e832ae890533a207a1204651e2b5502941
sad786/Python
/LeapYear.py
359
3.890625
4
def getLeapYear(year): while True: if year%400==0: return year elif year%4==0 and year%100!=0: return year else: year +=1 if __name__=='__main__': leap_year_list = [] cur_year = int(input("Enter any year :")) leap_year = getLeapYear(cur_year) for i in range(15): leap_year_list.append(leap_year)...
dcbbb225dea50f9678ee54407d10b1d66a06b5f2
Guneesh/PythonPrograms
/product of list items.py
174
3.859375
4
l1=[2,7,6,5] l2=[2,3,4] def multiply(l): res=1 for x in l: res=res*x print("product of list items is: ",res) return l multiply(l1) multiply(l2)
c37554150bcde62e871d6598878f557706d57b9d
lovenishgarg/Strings-1
/longest substr wo rep.py
1,938
4.03125
4
""" ## Problem2 Longest Substring Without Repeating Characters(https://leetcode.com/problems/longest-substring-without-repeating-characters/) Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the lengt...
aa9c1c14927e964f197ccde8a3fb989c90dfef38
pbett/python-notes
/quick_data_maps.py
1,941
3.703125
4
''' Illustrating quick-and-easy ways of plotting gridded data, using the iris package and its quickplot module. https://scitools.org.uk/iris/docs/latest/userguide/plotting_a_cube.html https://scitools.org.uk/iris/docs/latest/iris/iris/quickplot.html ''' import iris import iris.quickplot as qplt #----------------------...
ea1c7a0c276ad479c3fd954690efc828a711cfa9
chairielazizi/Algorithm_Lab_Tutorial
/Lab1_na/L1Q10.py
324
4.125
4
def prime(num): if num>1: for i in range(2,num,1): if num%i==0: print("%d is not a prime number"%num) break else: print("%d is a prime number"%num) else: print("%d is not a prime number" % num) num=input("Enter a number:") prime(nu...
880f74a1a9fc06fc3f5914b882a04c38b75842be
onkcharkupalli1051/pyprograms
/ds_nptel/sample_class.py
395
3.859375
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 2 15:53:34 2020 @author: Onkar """ #sample class class heap(): def __init__(self,l): #create heap from list l def insert(self,x): #insert x into heap def delete_max(self,x): #return max element #create object #ca...
d52f5f4a9e20137bf174026e7e151a41faa9bdfa
Rochet2/packetassignment
/inputgenerator.py
393
3.5625
4
import random import string lostindicator = "_" length = 5000 assert isinstance(lostindicator, str), "lostindicator must be a string" assert len(lostindicator) == 1, "lostindicator length must be 1" def randomstring(): rand = random.Random() rand.seed(1) letters = string.ascii_letters.replace(lostindica...
971fdf3888a3371a55e119ce2b4af05aa25d5625
10486/labs
/lab2/lab2-1.py
839
4.40625
4
a = b = 2 # Пример множественного оператора присваивания. # Обратите внимание на значения переменных a и b после выполнения данной операции. print("a = " + str(a)) # Функция str() используется для приведения типа аргумента к строковому print("b = " + str(b)) hello = "Привет" print("hello = " + str(hello)) h...
168f0f90d7027a60116f6727a7111a4dd20eaf26
Aasthaengg/IBMdataset
/Python_codes/p02261/s072101211.py
515
3.578125
4
N = int(input()) A = [ x for x in input().split(" ")] orig_A = A[:] #bubblesort for i in range(0, N): for j in range(N-1, i, -1): if int(A[j][1]) < int(A[j-1][1]): A[j], A[j-1] = A[j-1], A[j] print(*A) print("Stable") #selectionsort for i in range(0, N): minj = i for j in range(i, N)...
104a3b737894da3c0215d9e4a1dae89599695d5f
N-biswas000/python-projects
/new_ex7.py
563
4.0625
4
import random winning_number=random.randint(1,100) guess=1 number=int(input("Enter a number between 1 to 100 :")) game_over=False while not game_over: if winning_number==number: print(f"You Won!, and you guess this no {guess} times") game_over=True else: if winning_number < number: ...
1cec743589b4d7de9f4bf5c9ea85b7c1807728cc
jiangsir/PythonBasic
/五福專區/5-4.py
263
3.515625
4
a, b, c = map(int, input().split()) a, b, c = map(bool, [a, b, c]) i = True if(a and b) == c: print("AND") i = False if(a or b) == c: print("OR") i = False if(a ^ b) == c: print("XOR") i = False if i: print("IMPOSSIBLE")
2863acfc723e05cd2fb6342e6e0582ff61d31c4f
kalgynirae/dotfiles
/bin/unscramble
620
3.53125
4
#!/usr/bin/python3 import operator import re import string import sys from collections import Counter from pathlib import Path reasonable_word_regex = re.compile("\w+") word_counts = { word: Counter(word.lower()) for word in Path("/usr/share/dict/words").read_text().splitlines() if reasonable_word_regex.f...
0953c4ebac7f3e74a79a933f9f668aa0a5990898
aki-08/custom-tools
/c3/challenge3.py
1,118
3.53125
4
from functools import reduce import logging logging.basicConfig(filename='c3.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s') def get_value(obj, keys): """ This function is used to extract the value inside the key Usage ==> challenge3(obj, "a/b/c") :param obj: any dictionary :t...
1858dae413a41aaf87e5eed14456529a9a234ad9
16danielvm/EjerciciosPython
/Ano_Bisiesto.py
705
4.03125
4
from datetime import date def Ano_Bisiesto(year= date.today().year): """ La función toma como argumento un año y muestra si dicho año es bisiesto o no. Args: year(date.year): Debe ser un año. Return: String: Si es bisiesto o no Raises: ...
42ac2f54ba00afbf0b9002e8e5a441e3db7e24c2
everqiujuan/python
/day11/code/07_深度遍历目录.py
1,716
3.703125
4
# 深度遍历(了解) # 栈:后进先出 import os # 遍历目录 def getAllDirAndFile(sourcePath): # 创建栈 stack = [] # [] stack.append(sourcePath) # [newdir] while True: if len(stack) == 0: break # 从栈的右边取文件名 dirPath = stack.pop() # [] # 获取sourcePath所有子文件夹和子...
e47f45a96489558f60f4549877c5913f6c623a4c
soli1101/python_workspace
/d20200716/test11.py
2,170
4.03125
4
print(1+1) #1+1의 연산값 출력 a = 10 #a에 정수 10을 대입해 print(a) #a를 출력해 a = float(a) #a를 실수형으로 변환후 a에 대입해 print(a) #a를 출력해 print(complex(1.3, 1.4j)) #괄호안의 복소수를 출력해 print('-------------------------') #---를 출력해 # x = input("아무거나 입력") ...
3dd87e82f9dfaf1b6a57c65e36df74c25836a82c
DeflatedPickle/quill
/quill_calculator.py
2,157
3.546875
4
from quill import Window class Calculator(Window): def startup(self): self.menu() def menu(self, *args): self.enable() self.clear() self.insert_text("Calculator", True, tag="Heading-4") self.insert_text("What calculation would you like to do?", True) self.ins...
7616a47a9e3cd872f0e325cd42266e9f61822ea0
yunkaiwang/LeetCodeSol
/algorithms/105_ConstructBinaryTreeFromPreorderAndInorderTraversal.py
1,546
3.625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: """ O(n^2) solution, inefficient, but very easy to think of """ def buildTree(self, preorder: 'List[int]', inorder: 'List[int...
bafb508dc8e3add774eeb7a82d0229a0bcfed591
IngvarRed/circle_python_2019
/20191017_list01.py
423
4.25
4
# list week_days = [10] print(week_days) week_days = ['Monday', 'Tuesday', 'Wednesdayy'] print(week_days) # first item in the list print(week_days[0]) # slice print(week_days[0:2]) another_list = list() print(another_list) # iterarate by string ll1 = list('cat') print(ll1) ll2 = ['cat'] print(ll2) ll3 = ['cat', 'd...
61982e1973f1e2ce712a7424e9134d8c853be84c
cloveridge/BattleShip
/battleship.py
807
3.828125
4
from game import * from player import * if __name__ == "__main__": players = [] for num in range(1, 3): cls() print("************************") print("*Welcome to Battleship!*") print("************************\n\n") # Establish players here, for all games. new_player = Player() players.append(new_pl...
a2fd6f4a7e2f6006fcf1f883c3a5a674aacf7155
triptigupta346/python-practice
/swapnode_linklist.py
1,246
4.0625
4
# Problem Statement: # You are given one non-empty linked lists representing some integers and one k value. you need to swap the first kth value of linked list with the last kth value in the one iteration only # Example: # Input: (1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7) with kth value 3 # Output: 1 -> 2 -> 5 -> 4 -> 3 -...
09772baebd5f7e2f98ff23fb8e10a6d51973c46b
RafaelSanzio0/FACULDADE-PYTHON.1
/PF/IAP PF/Bolinhas.py
242
3.671875
4
h = int(input("valor: ")) row = 0 while row < h: count = 0 while count < h - row: print(end=" ") count += 1 count = 0 while count <2*row + 1: print(end="I") count += 1 print() row += 1
0e5abf25b2d0be17e5f10e4ac008a38c11ac9931
dhungana/edxProject1
/driver.py
9,625
3.84375
4
#!usr/bin/env python #################################### # Sailesh Dhungana (Week 2 Project)# #################################### import sys import resource from collections import deque class PriorityQueue: def __init__(self): self.array = [None] self.position_map = {} self.size = 0 def is_empty(self): ...
89572ccc6764ba8d475b68ebfa87d34e62209012
timliakhor/geekbrains_python
/lesson1/1.py
256
3.921875
4
strExample: str = input('Please, input your Name: ') print(strExample) intExample: int = int(input('Please, input random integer number: ')) print(intExample) floatExample: float = float(input('Please, input random float number: ')) print(floatExample)
626ddfb4f5251a4a8d0fec40d68e8685f4014d04
antoni0duarte/UFRN
/sb.py
594
3.53125
4
## Valores por região ## ## P= 5kg / M= 7kg ## print("########### GRUPOS ############") print("# GRUPO 1 = PE/PB/AL/SE/BA/TO #") print("# GRUPO 2 = AC/AM/RR/RO/MT/AP #") print("# GRUPO 3 = AC/AM/RR/RO/MT/AP #") print("# GRUPO 4 = AC/AM/RR/RO/MT/AP #") print("###############################") group1_p = 23.40 group...
77e35a76507c94b0e63371c07e99b609e6846812
apple2062/algorithm
/programmers/[L2]올바른괄호.py
514
3.59375
4
#올바른 괄호 (https://programmers.co.kr/learn/courses/30/lessons/12909) def solution(s): from collections import deque answer = True lst =[] q = deque(s) while q: try: target = q.popleft() if target == ')': lst.pop() #print(lst) ...
ab81d6c201df1a21c48f70981102a121459c0005
Moustafa-Eid/Python-Programs
/Unit 1/User Input/InputEx2.py
480
4
4
# Name: Moustafa Eid # Date: February 14th 2017 # Class: ICS3U1-03 # Description: Currency converter (CAD) to (EUR) #Input Canadian dollars money = int(input("Please enter the amount of money in Canadian Dollars that you want to convert to euros ")) # Rate of change from cad to euro + converting from cad to euro RATE...
84deabdf9eb795d3cec55d34bb7c8cb2f68d9a41
OniuUI/alphazero-play-app
/flask-server/alphazero/rules.py
1,128
3.5625
4
import numpy as np from typing import List class Rules(): """ Abstract game-rules class. For any new game, inherit from this class and implement all of the below methods. """ def __init__(self): pass def step(self, board: np.ndarray, action: int, player: int) -> np.ndarray: r...
8de394d79093e3eae3fb400d2d5a72dee895e370
kev158/NguyenTrongDuc-c4t
/minihackp3.py/b2s.py
93
3.71875
4
x=int(input("Nhap vao 1 so?")) if x % 2 == 0 : print("so chan") else: print("so le")
aec4995eef6aa7b83b065d619ae1177fac2bd54b
gagandeep7/python
/basic/comprehension.py
516
3.78125
4
gag={'age':20,'name':['gag' ,'deep']} print(gag['name'][1]) print(gag.get('name'[0],'errror')) for i,j in gag.items(): print(i,':',j) nums = [0, 1, 2, 3, 4] even_num_to_square = {x: x ** 2 for x in nums if x % 2 == 0} # dict comprehension even_num_to_square2 = [ x ** 2 for x in nums if x % 2 == 0] # list compr...
e8b1dc4a8a0ff5b8ed80767ac0e98614e61a86c6
difanhao/LearningPython
/PythonWebBookStudyNotes/variableLengthArgument.py
1,563
3.609375
4
#coding:utf-8 ''' tupleArg前面“*”表示这个参数是一个元组参数,从程序的输出可以看出,默认值为(); dicrtArg前面有“**”表示这个字典参数(键值对参数)。 可以把tupleArg、dictArg看成两个默认参数。 多余的非关键字参数,函数调用时被放在元组参数tupleArg中;多余的关键字参数,函数调用时被放字典参数dictArg中 (1)如代码:fun(123, l, dict)   元组对象前面如果不带“*”、字典对象如果前面不带“**”,则作为普通的对象传递参数。   多余的普通参数,在foo(123,myList,myDict)中,123赋给参数arg1,myList赋给参数arg2,多余...
d496fa3ca50091e0f09ebb30857998c408243fd5
xXG4briel/CursoPythonGuanabara
/10 - Condições/Desafio 032.py
548
3.78125
4
"""DESAFIO 032 ANO BISSEXTO""" x=0 while x==0: print('{:_^80}\n\n{: ^70}\n{:_^80}'.format('','É bissexto ou não?','')) A=int(input('Digite um ano: ')) div=A%4 if div==0: print('{} é ano Bissexto'.format(A)) else: print('{} é ano normal'.format(A)...
6d0af866969403780606c557a187a0ecc71d6b93
StRobertCHSCS/fabroa-emaddehghani
/Working/LiveHacks/liveHack2_problem.py
512
3.96875
4
------------------------------------------------------------------------------- Name: livehack2_pronlem1 Purpose: find BMI Author: dehghani.E Created: 18/11/2019 ----------------------------------------------------------------------------- weigh = int(input("Enter a number: ")) height = int(input("Enter a number:...
8d3d385aada4b78634b650fb12dbbc2a9d67ef67
MarsWilliams/DataStructureExercises
/binary_search.py
433
3.828125
4
def binarySearch(upper_bound, num): tries = 0 lower_bound = 1 upper_bound = upper_bound while True: tries += 1 guess = (lower_bound + upper_bound) / 2 if guess == num: print 'You guessed my number in', tries, 'tries!' break elif guess > num: print guess, 'is too high.' upper_bound = guess - 1 ...
eaeae05aa34f2997df44f754e882bdbf059bd267
Samrat0009/Python_REPO1
/#13 OOPS-1/Fraction_class_3_arithmetic.py
1,409
3.875
4
class fraction: def __init__(self,num = 0,den = 1): # init can be given default values like this !! if den ==0: den = 1 self.num = num self.den = den def print(self): if self.num == 0: print(0) elif self.num == 1: pr...
ec40e8ea181d678ac8865cd60422a8536e9ae7a8
SimonrLofgren/breakout
/sprites/pwups/Pandaprogramming-master/adventure_door_choice.py
751
3.609375
4
import time from starting_room_normal import starting_room_normal def door_choice(): while True: user_adventure_choice = input().lower() if user_adventure_choice == "yes": print("questroom method insert here") elif user_adventure_choice == "no": print("You back aw...
7de91d690d57da13790f4851ca25e20ce6e74622
okmechak/SandBox
/some_course/week6/cash.py
360
3.78125
4
from cs50 import get_float dollars = -1 while dollars < 0: dollars = get_float("Change owed: ") coins = round(dollars * 100) coins_and_money = [25, 10, 5, 1] counter = 0 while coins > 0: for coin_and_money in coins_and_money: if coin_and_money <= coins: coins -= coin_and_money ...
f13e30326ed5d5b3f787462f0334d3215843eded
xlr10/pyton
/190729/190729_01.py
665
3.6875
4
# funtion print("funtion") print() def add(a, b): return a + b a = 1 b = 2 print(add(a, b)) def add_serial(*args): result = 0 for i in args: result += i return result print(add_serial(1, 2, 3, 4, 5)) def print_dic(**kwargs): print(kwargs) print_dic(d=1) print_dic(name='a', pss=1...
5ce7f4ea663c5cd8c87c5674ac93353ef38d8a80
yokesh-git/Pattern-Programs
/Pattern Programs (1).py
2,333
3.796875
4
#Pyramid ''' N = int(input()) for i in range(N): print(' ' *(N-i-1) + (i+1)*'* ') ''' #Inverted Pyramid ''' N = int(input()) for i in range(N): print(' '*i + (N-i)*'* ') ''' #Right Angle Triangle ''' N = int(input()) for i in range(N): print((i+1)* '* ') ''' #Inverted Right A...
61e3f015cc83bb648f18fe448b90f0b610cdf2b7
martinazaki/Uni-Work
/COMP1531/20T1-cs1531-lab01/strings.py
282
4.3125
4
''' TODO Complete this file by following the instructions in the lab exercise. ''' strings = ['This', 'list', 'is', 'now', 'all', 'together'] new_string = "" for string in strings: new_string = new_string + string + " " print(new_string[:-1]) print(' '.join(strings))
12eebe65fb67ab073ef9c8d75fe760759e8bd19c
chc1129/python_jisen
/04/isList.py
1,667
4.1875
4
# 配列 - 要素を一列に並べて扱う # list型 - 可変な配列を扱う型 # リストを作成 items = ['note', 'notebook', 'sketchbook'] type(items) print( type(items) ) items print( items ) # 文字列はイテラブルなオブジェクト list('book') print( list('book') ) # 要素の追加と削除 items = ['note', 'notebook', 'sketchbook'] items.append('paperbook') # 要素を追加 print( items ) items = [...
25358e245c9fefe0c059a7f5b8e19ad946a351cf
sathish-csk/thinkpython
/exercise7.4.py
296
3.515625
4
import sys import os def eval_loop(): while True: user_string = input('>>> ') if user_string == 'done': break else: print(user_string) result = eval(user_string) print(result) if __name__ == '__main__': eval_loop()
711dfb3c3cbda6713b06d141848c0ccc5dd650ef
exs1084/School
/cs720/HW_02_Sodergren_Erikson/assign2.py
2,061
3.609375
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 5 14:45:30 2019 @author: Erikson """ import matplotlib.pyplot as pyplot import pandas from numpy import var def main(): fileName = "Speed_Data.csv" #fileName = "Mystery_Data.csv" dataFile = open(fileName, "r")#open file data = list() ...
574347275d90c91cfe001c103da58cf27142d1b8
tfchu/py_test
/mt_return3.py
895
3.5
4
# multithreading with return values ''' threading.Thread does not give return value use multiprocessing.pool.ThreadPool instead ''' import marktime # stopwatch from multiprocessing.pool import ThreadPool def foo(bar, baz): print('hello {0}'.format(bar)) return 'foo' + baz def foo2(bar, baz): print('hello...
00aa17db1af89fa8518807ee91f81b0a1a6d7bc4
orengoa0459/cti110
/P5HW2_RockPaperScissors_AnthonyOrengo.py
3,000
4.46875
4
# This program is a version of the game rock, paper, scissors. # 07/04/2019 # CTI-110 P5HW2_RockPaperScissors # Anthony Orengo # # 1.) Create funtion called main() # 2.) Import random module # create funtion called number = random.randint(1, 3) # # 3.) Declare variables # rock = "Rock" # ...