blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
66411ff8a8939a465b84c081d269090ededf9567
wusui/pentomino_redux
/tree_offspring.py
2,443
3.546875
4
""" _get_offspring and associated functions """ def get_complete_gen(tree): """ Given a tree, return a list of lists indexed by node number. Each list entry is a set of points that can be added as an offspring node to that node """ return map(_get_new_points(tree), range(len(tree))) def _get...
0d42ed8f2e6f96a6cd1cae24237a7cff15b04dd5
Susmit-A/IoT_HandsOn
/src/basics/Python/functions.py
623
4.375
4
# Here we shall see how to define a function in Python. # A function definition starts with the keyword 'def': def func(): print("No Parameters") def func(param): print(param) func(5) # Unlike OOP languages, Python doesn't support function overloading. # If multiple definitions of a function exist, ...
099fbb0631bd300d9badad07be491fba68779051
alejamorenovallejo/retos-phyton
/Ejercicio/Clases/ciclos.py
825
4.0625
4
#for loop(ciclo) suma = 0 #Esto es un Acumulador cuenta = 0 #Este es un contador numero = int(input("¿Hasta que número quieres sumar?")) for i in range(numero + 1): suma += i cuenta += 1 print("La suma de los números es ", suma) print("El ciclo se ejecuto ", cuenta, "veces") #Pero quiero que mi programa empie...
db269d36e8e791412a0fac7d7822f9a573ea3b72
kaio358/Python
/Mundo3/Funções/Desafio#101.py
395
3.875
4
def voto(anos): from datetime import date atual = date.today().year idade = atual - anos if idade < 16 : return f'A idade {idade} insuficiente, NEGADO !!' if 16 <= idade <18 or idade>69: return f'A idade {idade} é OPICIONAL' if 18 <= idade <= 69: return f'A idade {idade}...
449067634351a2e5207cfbcd61ef2f87a0a245fb
cwinslow22/Data-Structures
/linked_list/linked_list.py
1,524
3.75
4
""" Class that represents a single linked list node that holds a single value and a reference to the next node in the list """ class Node: def __init__(self, value=None, next_node=None): self.value = value self.next_node = next_node def get_value(self): return self.value def get_next(self): retu...
03fca00bf92ab7d1bf4e15e6b82c4f2f274ea3c7
bcui6611/mortimer
/mortimer/grammar.py
11,214
3.59375
4
import globals from lepl import * from bisect import bisect_left import logging """ The following class definitions are used to aid in the construction of the Abstract Syntax Tree from the expression. For example, they allow simple tests such as isinstance(exprtree, Identfier). See expr_evaluate(exprtree, c...
2f9c9b9e5aaa56ae59308c36a98861e5c79941f7
itsolutionscorp/AutoStyle-Clustering
/assignments/python/61a_hw4/src/166.py
253
3.515625
4
def num_common_letters(goal_word, guess): goal_word_list = get_list(goal_word) guess_list = get_list(guess) commonChars = 0 for char in goal_word_list: if char in guess_list: commonChars += 1 return commonChars
8b4edd1237e54d579b69c4bcf9ed25335a05c481
roclas/utils27.py
/financial/ibex35/add_weekdays.py
392
3.515625
4
#!/usr/bin/env python import datetime,sys inputfile=sys.argv[1] weekdays=["mon","tue","wen","thu","fri","sat","sun"] for l in open(inputfile).readlines(): try: arr=l.split('"') date_str=arr[1] d,m,y=date_str.split("/") dt=datetime.date(int(y),int(m),int(d)) weekday=weekdays[dt.timetuple()[6]] print "\"%...
9940c65e40f0bdd650ba3ad9bb376b3396d47267
MiraDevelYing/colloquium
/1.py
702
3.578125
4
#Введіть з клавіатури в масив п'ять цілочисельних значень. Виведіть їх в #один рядок через кому. Отримайте для масиву середнє арифметичне. #Дудук Вадим 122-Г import numpy as np while True: b=np.zeros(5,dtype=int) u=[] for i in range(5): b[i] = int(input('Введіть елементи: ')) for k in range(...
574d63d0c04756ba5a3654e6c0d16a0625a82f1d
xzeromath/euler
/myfunctions.py
1,421
4.4375
4
# https://www.geeksforgeeks.org/python-program-to-check-whether-a-number-is-prime-or-not/ # Instead of checking till n, we can check till √n because a larger factor of n must be a multiple of smaller factor that has been already checked. # The algorithm can be improved further by observing that all primes are of the fo...
ea5b916dccb9420006a9b8aefa342d1f4809584c
MariVilas/teste
/Python/aula10h.py
314
4.15625
4
a=int(input('Entre com um número:')) b=int(input('Entre com um número:')) c=int(input('Entre com um número:')) if ( b - c ) < a < b + c : print('Triângulo Encontrado!') elif ( a - c ) < b < a + c: print('Triângulo Encontrado!') else: (a - b) < c < a + b print('Triângulo Encontrado!')
7e794d4c43d8b06720f4af66b39940a3d1f5e20a
gbharatnaidu/python_programs
/duplicate_numbers.py
417
3.578125
4
arr1=[1,10,12,12,1,1,5,10,23,1] arr2=[] for i in range(0,len(arr1)): arr2.append(-1) print(arr2) for i in range(0,len(arr1)): count=1 for j in range(i+1,len(arr1)): if(arr1[i]==arr1[j]): count+=1 arr2[j]=0 if(arr2[i]!=0): arr2[i]=count for i in range(0,len(...
987bd929b9641ecf9f5022773df5ab7a45caf750
SSK0001/SDE-Skills
/Week 3/CloneStack.py
471
3.515625
4
# Clone Stack def cloneStack(original): ''' type original: original stack type clone: clone stack with this rtype: clone ''' if len(original) == 0: return original tempStack = queue.LifoQueue() clone = [] while(len(original) > 0): tempStack.put(original.pop()) ...
9eedb2b11a01c71bcadd0b4feeb421bad22d2b1d
zxycode-2020/python_base
/day16/6、文档测试/文档测试.py
416
3.8125
4
import doctest #doctest模块可以提取注释中的的代码执行 #doctest严格按照Python交互模式的输入提取 def mySum(x, y): ''' get The Sum from x and Y :param x: firstNum :param y: SecondNum :return: sum 注意有空格 example: >>> print(mySum(1,2)) 3 ''' return x + y print(mySum(1, 2)) #进行文档测试 ...
72bce4850e9ee2be49baa0bf0da265fd36d0ba52
Meenaashutosh/FileHandlingAssignment
/program9.py
428
4.3125
4
# 9.Write a Python program to count the frequency of words in a file file=open("file.txt","r+") word_count={} for word in file.read().split(): if word not in word_count: word_count[word] = 1 else: word_count[word] += 1 for l in word_count.items(): print l #output ''' python program...
f40a75f21b2c7ea6823e6c79b144dd21ceade09b
iamfakeBOII/pythonP
/reference/nested_loops.py
2,201
4.125
4
#NUMBER 1 - ASCENDING ''' num = int(input('ENTER HOW MANY ROWS ARE REQUIRED: ')) count = 1 for b in range(num): for i in range(count): print('1', end=" ") print('') count +=1 continue ''' #NUMBER 1 - DESCENDING ''' num = int(input('ENTER HOW MANY ROWS ARE REQUIRED: ')) count = nu...
a551c226e1667ee3639cc09be8dc3e1535aaace0
masif245/TicTacToe
/TicTacToeGame.py
3,137
3.828125
4
def welcomeMessage(): print ('Hello !!! Welcome to the tic tac toe game.') #clear = lambda: os.system('clear') def clear(): clr = "\n" * 100 print (clr) def getPlayedChoice(): Player1 = input('Hey Player 1 ! Enter your choice of character X/O: ') while (Player1 != 'X' and Player1 !=...
7ca2ecacbbd6a42b7937fd334251bc67baf9471d
haydenso/school-projects
/Pre-release/invalid_final.py
3,551
3.859375
4
# TASK 1 - Start of Day up_times = ["9:00", "11:00", "13:00", "15:00"] #Array of strings - variable up_seats = [480, 480, 480, 480] #Array of integers - variable up_tally = [0, 0, 0, 0] #Array of integers - variable up_revenue = [0.0, 0.0, 0.0, 0.0] #Array of real - variable down_times = ["10:00", "12:00", "...
b9fd49ea64220ba74cdcd34b59a26697bab2fd8f
nasama/procon
/atcoder.jp/abc072/abc072_b/Main.py
67
3.53125
4
s = input() a = '' for i in range(0,len(s),2): a += s[i] print(a)
2fbe3b9b78105b8ea0b4f7db3d808bcecfd838c9
LichAmnesia/LeetCode
/python/230.py
914
3.84375
4
# -*- coding: utf-8 -*- # @Author: Lich_Amnesia # @Email: alwaysxiaop@gmail.com # @Date: 2016-10-01 00:47:36 # @Last Modified time: 2016-10-01 13:06:36 # @FileName: 230.py # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # ...
df6918320355f8e4ed958563e713300acefdc7cd
joaovictorfg/Peso2
/PesoIMC2.py
921
3.5625
4
#! /usr/bin/env python #-*- coding: UTF-8 -*- import math import os, sys print( 'IMC') peso = raw_input (' Digite seu peso e aperte enter: ') altura = raw_input ('Digite a sua altura e aperte enter: ') imc = float(peso)/(float(altura)*float(altura)) #print 'Seu IMC é : ', imc if imc <= 17.0: print ("Atenção! V...
c45763ef758ad83b852f5427b9074fe9fc490e83
paulinho-16/MIEIC-FPRO
/FPRO PLAY/TheCollatzSequence.py
253
3.8125
4
def collatz (n): result = str(n) + ',' while n != 1: if n%2==0: n = round(n/2) result += str(n) + ',' else: n = round(n*3+1) result += str(n) + ',' return result[:len(result)-1]
341ffd50afd5cbc49317fa987842099a1761026a
noorulameenkm/DataStructuresAlgorithms
/SDE_CHEAT_SHEET/Day 3/MajorityElementNBy2.py
1,167
3.890625
4
def majorityElementNByTwo(array): n_by_two = len(array) // 2 for i in range(len(array)): count = 0 for j in range(i, len(array)): if array[j] == array[i]: count += 1 if count > n_by_two: return array[i] def majorityElementNByTwo2(a...
c3c0544c51eb3fd6c385b27ac1d29e59ac22897e
Godul/advent-of-code-2020
/day06/solution.py
672
3.578125
4
QUESTIONS = list(map(chr, range(ord('a'), ord('z') + 1))) def both_parts(): anyone_set = set() everyone_set = set(QUESTIONS) anyone_count = 0 everyone_count = 0 with open('input.txt') as file: for line in file: if line == '\n': anyone_count += len(anyone_set) ...
c0e9579ae7b7a6875f4ffb44341f5909c4ae7ace
etzellux/Python-Demos
/NumPy/numpy_basics_7_shape_manipulation.py
515
3.625
4
#SHAPE MANIPULATION import numpy as np #%% array1 = np.array(10* np.random.random((2,3,3)),dtype=int) print(array1,"\n",) print(array1.ravel(),"\n") #arrayin düzleştirilmiş halini döndürür #%% array2 = np.array([[1,2],[3,4]]) print(array2,"\n") print(array2.T,"\n") #%% array3 = np.array([[1,2,3],[4,5,6]]) print(array...
49329efa2d83d6c11b520cc7ea1304013acdeaf4
DStazic/Fraud_Analysis_Machine_Learning
/imputation.py
1,580
3.703125
4
#!/usr/bin/python import numpy as np import pandas as pd from fancyimpute import MICE def MultipleImputation(dataset, features): ''' Takes a dataset and a set of feature names that refer to features to be imputed in the dataset. Facilitates multiple imputation technique on missing data and returns the im...
1ce16fd50c287cdd9024f1f5fe64e6201e9ba749
ZukGit/Source_Code
/python/plane/plane.py
9,401
3.625
4
#!C:/Users/Administrator/Desktop/demo/python #coding=utf-8 #导入pygame库 import pygame,random,sys,time #sys模块中的exit用于退出 from pygame.locals import * #定义导弹类 class Bullet(object): """Bullet""" def __init__(self, planeName,x,y): if planeName == 'enemy': #敌机导弹向下打 self.imageName = 'Resources/bullet-3.png' s...
db8ed6fb0f0d48b7f2748800292eead7764ac1d3
MGloder/python-alg-exe
/array/move_zeros.py
1,109
3.890625
4
def is_validate(value): return value != 0 class MoveZeros: def __init__(self): """ * Move Zeroes * * - Given an array, move all 0's to the end of the array while maintaining the relative order of others. """ self.array = [0, 1, 0, 2, 5, 0, 3, 2, 0, 0] ""...
816bb95f2a1589c2733791e18900758863604f5b
jozsar/beadando
/43_feladat.py
444
3.5
4
def s_lista(s): ls=[] for i in range(len(s)+1): for j in range(i+1,len(s)+1): ls+=[s[i:j]] ls.sort(key=len) return ls def benne(ls,t): tartalmaz=True for i in ls: for k in t: if k not in i: tartalmaz=False if tartalmaz==True: ...
20c2be6108211ecd616c0e89f05c9c4ab2410739
alankrit03/LeetCode_Solutions
/129. Sum Root to Leaf Numbers.py
687
3.5
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def sumNumbers(self, root: TreeNode) -> int: self.ans = 0 def recur(node, curr): ...
b2fd53bdc88b14b023f613aa3b820a94d67aa23f
Code-Abhi/Basic-games
/Tic tac toe/Tic_tac_toe.py
5,687
3.921875
4
def check_win(): #horizontally if board[0]==ch and board[1]==ch and board[2]==ch: print("TIC TAC TOE PLAYER 1 HAS WON") exit() elif board[0]==cy and board[1]==cy and board[2]==cy: print("TIC TAC TOE PLAYER 2 HAS WON") exit() elif board[3]==ch and board[4]==ch an...
8ac8f081c5bf2e1529849fd359407e424631093f
catoteig/julekalender2020
/knowitjulekalender/door_04/door_04.py
1,108
3.6875
4
def count_groceries(deliverylist): groceries2 = [] aggregated = [0, 0, 0, 0] # sukker, mel, melk, egg with open(deliverylist) as f: groceries = f.read().splitlines() for element in groceries: groceries2.extend(element.split(',')) groceries2 = [x.strip() for x in groceries2] ...
39865048937d430e610288e1b82a754f23105188
frclasso/DataScience
/Data_Camp_tutorials/Python_for_Spread_Sheet_users/same/script4.py
514
3.5625
4
#!/usr/bin/env python3 import pandas as pd #1 fruit_sales = pd.read_excel("fruit_stores.xlsx") #print(fruit_sales.head()) #2 - summary - by fruit by store totals = fruit_sales.groupby(['store', 'product_name'], as_index=False).sum() print(totals) #3 - sort the summary print() totals = (totals.sort_values('revenue'...
8e780bdb0743cf302e2dc7d569647a1df3b5c117
luisarcila00/Reto1
/Clase 6/ejercicio_7.py
425
3.71875
4
def imprimir_caracter(caracter): if caracter == 'a' or caracter == 'A': return 'Android' elif caracter == 'i' or caracter == 'I': return 'IOS' else: return 'Opción inválida' print(imprimir_caracter('a')) print(imprimir_caracter('A')) print(imprimir_caracter('i')) print(imprimir_c...
9c2a83ec4fd3895efe234ca83f26235889c2e147
Shashanksingh17/python-functional-program
/Distance.py
189
4.15625
4
from math import sqrt x_axis = int(input("Enter the distance in X-Axis")) y_axis = int(input("Enter the distance in Y-Axis")) distance = sqrt(pow(x_axis,2) + pow(y_axis, 2)) print(distance)
f77b9de79e3cefe46c5f517ff00093a11d29ec5d
EdwardBrodskiy/algorithms
/sorts/merge.py
580
3.78125
4
def merge_sort(arr): if len(arr) <= 1: return arr half = len(arr) // 2 lhalf = merge_sort(arr[:half]) rhalf = merge_sort(arr[half:]) return merge(lhalf, rhalf) def merge(a, b): ai, bi = 0, 0 output = [] while ai < len(a) and bi < len(b): if a[ai] < b[bi]: ou...
d246526434485b833e1c78bf11af114c1bf7f1de
Gibbo81/LearningPython
/LearningPython/27ClassCodingBasics.py
4,079
4
4
class FirstClass: MutableField=[1,2,3] #this is an attribute present in all the istance # change in place will affect all the istance but immutable change or new assignment will create a new local variable for istance, the global one is unaffected #Placeorder AAAAAA def SetData(self, v...
7f2a98a34682d7d225649a2f2e996b35b66aa643
doom2020/doom
/sort-insert.py
825
3.90625
4
def insertion_sort(arr): """插入排序""" # 第一层for表示循环插入的遍数 for i in range(1, len(arr)): # 设置当前需要插入的元素 current = arr[i] # 与当前元素比较的比较元素 pre_index = i - 1 while pre_index >= 0 and arr[pre_index] > current: # 当比较元素大于当前元素则把比较元素后移 arr[pre_index ...
6fe720349f891b99c20cc803503716c3a8a193ed
robotBaby/linearAlgebrapython
/HW1.py
748
3.859375
4
from sympy import * init_printing(use_unicode=True) #Problem8 a = Matrix([[1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5]]) A3 = a*a*a print "Answer to question 8: A^3= " pprint(A3) print "\n" #Problem9 A = Matrix([[2,4,5], [2,6,1], [-2, 9, 15], [12, 0, 15], [3, 34, -52]]) B = Matrix([[2,4,5,4], [2,6,...
ff775119df7eb28b922b290967ad35a0239d5bc3
RaghavTheGreat1/code_chef
/Data Strucures & Algorithm/Complexity Analysis + Basics Warm Up/LRNDSA01.py
457
4.25
4
# Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits. # Example # Input: # 1 # 2 # ...
e4529b76a695c341fe847c38735e9fee18b4b67f
amiraliakbari/sharif-mabani-python
/by-session/ta-922/j8/a3.py
151
3.6875
4
def f(n): if n < 2: print 'A' return 1 a = f(n-1) print 'B' b = f(n-2) print 'C' return a + b f(6)
daaf672775550230e18397d382e5d3dbbd18e1a6
xxxxgrace/COMP1531-19T3
/Labs/lab01/19T3-cs1531-lab01/integers.py
239
4.03125
4
# Author: @abara15 (GitHub) ''' TODO Complete this file by following the instructions in the lab exercise. ''' integers = [1, 2, 3, 4, 5] integers.append(6) x = 0 for integer in integers: x += integer print(x) print(sum(integers))
434d57d7265a3932b4cb6cdca1606f65894cd547
Shruthi21/Algorithms-DataStructures
/14_BoatTrips.py
407
3.515625
4
#!/bin/python import sys def BoatTrip(n,c,m,p): capacity = c * m flag = 0 if len(p) == n: if max(p) > capacity: return 'No' else: return 'Yes' if __name__ == '__main__': n,c,m = raw_input().strip().split(' ') n,c,m = [int(n),int(c),int(m)...
d4bc41404a89437c5ee8ee4c62b33b90fc05efd0
apethani21/project-euler
/solutions/p16.py
253
3.953125
4
import time start_time = time.time() def digit_sum(n): s = 0 while n: s += n%10 n //= 10 return s print(digit_sum(2**1000)) end_time = time.time() print("Time taken: {} ms".format(round((end_time - start_time)*1000, 3)))
a0bf957342bf38edf181ae8d9d9b22c36adc89ca
NetJagaimo/Algorithm-and-Data-Structure-With-Python
/3_basic_data_structure/balanced_symbol.py
797
3.5625
4
''' 使用stack作為核對大中小括號的實作方式 ''' from stack import Stack def symChecker(symbolString): s = Stack() balenced = True index = 0 while index < len(symbolString) and balenced: symbol = symbolString[index] if symbol in "([{": s.push(symbol) else: if s.isEmpty(): ...
068fb7fba7401a53ec6f09f1da6f8040d725b930
Adomkay/python-attributes-functions-school-domain-nyc-career-ds-062518
/school.py
542
3.671875
4
class School: def __init__(self, name): self._roster = {} self._name = name def roster(self): return self._roster def add_student(self, name, grade): if grade in self._roster: self._roster[grade].append(name) else: self._roster[grade] = [na...
5ca765533611abf1250ea2897f71d78fd8b7131f
Angel07/Restaurante_Biggby_coffee
/EmployeeDB.py
538
3.640625
4
import sqlite3 con = sqlite3.connect("employee.db") print("BASE DE DATOS CREADA CON EXITO") con.execute("create table Employees (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, contraseña TEXT NOT NULL, address TEXT NOT NULL, tipo_usuario TEXT NOT NULL)") print("TABLA EMPLEADO CREADA SATISFACTO...
10313e1029c082effde78494e6afc3da69a268a9
live2skull/TheLordOfAlgorithm
/problems_boj/스택/4949.py
928
3.625
4
## 균형잡힌 세상 - 4949(스택) import sys def int_input(): return int(input()) def ints_input(): r = input().split(' ') for _r in r: yield int(_r) from collections import deque char_open = ('(', '[') char_close = (')', ']') def main(): stack = deque() for line in sys.stdin: stack.clea...
71d86a6ba63f2a7e3da3ca985cb6f94b52281dc0
Jaseamsmith/U4L4
/problem4.py
320
4.15625
4
from turtle import * charlie = Turtle() nana = Turtle() charlie.color("blue") charlie.pensize(5) charlie.speed(5) charlie.shape("turtle") nana.color("green") nana.pensize(5) nana.speed(5) nana.shape("turtle") for x in range(1): charlie.circle(100) for y in range(3): nana.forward(100) nana.left(120) mainloop()
45c67000244cfa3d98ccee6c8f672cfa15ea4ba1
intellivoid/CoffeeHousePy
/deps/scikit-image/doc/examples/filters/plot_entropy.py
2,401
3.640625
4
""" ======= Entropy ======= In information theory, information entropy is the log-base-2 of the number of possible outcomes for a message. For an image, local entropy is related to the complexity contained in a given neighborhood, typically defined by a structuring element. The entropy filter can detect sub...
4b71c11166bfdc1b71d200e07f12b27cbb254bfd
ThenuVijay/Practice-Programs
/homework.py
1,369
3.8125
4
row =1 while row<=5: col = 1 while col<=row: print(row,end=' ') col+=1 print() row+=1 # output # 1 # 2 2 # 3 3 3 # 4 4 4 4 # 5 5 5 5 5 row =1 while row<=5: col = 1 while col<=row: print((col+row),end=' ') col+=1 print() row+=1 # output # 2 # 3 4 # 4 5 6 # 5 6 7 8 # 6 7 8 9 10 ...
23c85c36d25af35a22ffccdac1ea7c39c9d632e1
debazi/python-projets
/modules/sqlite3-with-prettytable/crudSqlite3.py
1,260
3.765625
4
import sqlite3 from prettytable import * # creation et connection à la base de donnée conn = sqlite3.Connection('./db/crudDB.db') cursor = conn.cursor() #cursor.execute("""DROP TABLE IF EXISTS users""") # creation de la table utilisateur cursor.execute( """CREATE TABLE IF NOT EXISTS users( id...
2dfd2927fb560238d4f708fa13d66b290de870bc
kailinshi1989/leetcode_lintcode
/170. Two Sum III - Data structure design.py
1,570
3.890625
4
class TwoSum(object): def __init__(self): self.map = {} def add(self, number): if number in self.map: self.map[number] += 1 else: self.map[number] = 1 def find(self, value): for number in self.map: if value - number in self.map and (value...
a0662d628774efbdb67ee1bc180377f05ac76afb
andrewharukihill/ProjectEuler
/55.py
572
3.640625
4
import time def reverse(num): num = str(num)[::-1] return int(num) def lychrel(num, iteration): if (iteration==50): return 1 else: rev = reverse(num) if (num == rev and iteration != 0): return 0 else: return lychrel(num+rev, iteration + 1) def main(): start_time = time.time() range_lim = 100000 ...
1deecaca1ca8410c596d762e6589e70e4934cc40
adriano662237/fatec_ferraz_20211_ids_introducao_git
/calculadora.py
412
4.21875
4
a = int(input("Digite o primeiro valor")) b = int(input("Digite o segundo valor")) operacao = input("+: Soma\n-: Subtração\n: Multiplicação\n/:Divisão\n**: Exponenciação") if operação == '+': resultado = a + b elif operação == '-': resultado = a - b elif operação == '*': resultado = a * b elif operação...
3c494a8d7c5f824892cf3040d65ab94cd28ce1d2
jsmlee/123-Python
/helper_functions/character_model.py
729
3.546875
4
import pygame wLeft = [] wRight = [] still =[] num_sprite = 10 #sprite correlating to action,add to if more actions are added class player(): def __init__(self,xPos,yPos,pWidth,pHeight): self.xPos = xPos self.yPos = yPos self.pWidth = pWidth self.pHeight = pHeight self.wLe...
7b2fbe7171910720724e933e0d5a0a3cd3bd0c45
stephenrobic/PythonTargetPractice
/Target Practice.py
15,634
3.671875
4
import tkinter as tk import turtle import random class Darts: def __init__(self): self.scores = [500, 700] self.main_window = tk.Tk() # self.newgame_window = tk.Tk() #create frames for start screen self.title_frame = tk.Frame(self.main_window) self.buttons_frame = tk...
5576e132990431909b2fac3ac24e0375b4097097
AdamZhouSE/pythonHomework
/Code/CodeRecords/2133/60837/238728.py
497
3.53125
4
def findMax(list): max=0 for i in range(len(list)): if list[i]>max: max=list[i] return max def isNotEqual(list): for i in range(len(list)-1): if list[i]!=list[i+1]: return True return False list=list(map(int,input().split(','))) max=findMax(list) result=0 wh...
93bc310d76b1478b59a78a24bc93dd2a08bdd730
ilya-lebedev/hhhomework2021
/core/classes.py
1,488
4.1875
4
class Car: # Реализовать класс машины Car, у которого есть поля: марка и модель автомобиля # Поля должны задаваться через конструктор def __init__(self, model, brand): self.model = model self.brand = brand def __str__(self): return self.model + ' ' + self.brand class Garage: ...
c36fd102bd30b22fc91b2e447a1b403c5636ffa9
elijahsk/cpy5python
/practical03/q07_display_matrix.py
854
4.28125
4
# Name: q07_display_matrix.py # Author: Song Kai # Description: Display a n*n matrix with 1 and 0 generated randomly # Created: 20130215 # Last Modified: 20130215 import random # check whether the string can be converted into a number def check(str): if str.isdigit(): return True else: print("Please e...
e9aa7bc8802dc5bbe3fefe2c1c6246bb90186ecb
GlenboLake/DailyProgrammer
/C214E_standard_deviation.py
379
3.84375
4
from math import sqrt def stddev(items): items = [float(x) for x in items] avg = sum(items)/len(items) var = sum([(x-avg)**2 for x in items])/len(items) return sqrt(var) def numlist(s): return [int(x) for x in s.split(' ')] print(stddev('5 6 11 13 19 20 25 26 28 37'.split())) print(stddev('37 81 ...
c50a8bcb2d2edec2bcff8109128d892458264aa5
birdhermes/CourseraPython
/5_week/Флаги.py
1,010
4.1875
4
# Напишите программу, которая по данному числу n от 1 до 9 выводит на экран n флагов. Изображение одного флага имеет # размер 4×4 символов, между двумя соседними флагами также имеется пустой (из пробелов) столбец. Разрешается вывести # пустой столбец после последнего флага. Внутри каждого флага должен быть записан его ...
b9ea50eae4b8e47b186eaba6d2c45e6d385eb8c4
semmons1/Unix_File_Sytem
/project/bhelper.py
1,008
3.625
4
import os, sys def main(): ## validate command line args if len(sys.argv) == 1 or len(sys.argv) > 3: print("Usage: python bhelper.py <driver number> [<type of output>]") if not sys.argv[1] in range(1, 7): print("Please input a driver number between 1 and 6") if len(sys.argv) == 3 and ...
f5d1b04554ae41f5320e38e39ab3cbfff6826145
SensumVitae13/PythonGB
/LS1_3.py
395
3.75
4
# Узнайте у пользователя число n. Найдите сумму чисел n + nn + nnn. # Например, пользователь ввёл число 3. Считаем 3 + 33 + 333 = 369. n = int(input("Введите число n от 1 до 9: ")) amount = (n + int(str(n) + str(n)) + int(str(n) + str(n) + str(n))) print(f"Сумма чисел n+n+nnn = {amount}")
15af59e32baf53c3e99bfbcf5ee624468bc2169a
hoklavat/beginner-data-science
/05-MultipleLinearRegression(Sklearn)/05-Standardization.py
1,517
3.859375
4
#05-Standardization #standardization: process of transforming data into a standard scale for predict method. (original variable - mean)/(standard deviation) import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns sns.set() from sklearn.linear_model import LinearRegression data = p...
ccc3b34c86e74ebacf313bacfab62fe45ab0b751
AbdulAhadSiddiqui11/PyHub
/Basics/Strings.py
1,039
4.21875
4
# Both single and double quotes work. a = "hello" b = 'world!' print(a + " " + b) print() x = "aWeS0Me" print("String is " + x) print("Capitalizing the first letter : " + x.capitalize()) print("Converting stirng to lower case : " + x.casefold()) print("Converting all the letters to upper case : " , x.upper()) print("...
88159e01f91b68ac2c4a2c1d9d1cd2a86cb15d05
chintanvadgama/Algorithms
/findNextGreaterElement.py
1,414
3.609375
4
# Find a next greater element in arrary and if not exists then return -1 # 2 ways # 1. using 2 for loops # 2. using stack # [15,2,9,10] # 15 --> -1 # 2 --> 9 # 9 --> 10 # 10 --> -1 # 1. using 2 for loops class Stack: def __init__(self): self.stack = [] def push(self,item): self.stack.append(item) def isEmpty(...
307bcd423f522f6b799843bace5306ece9d95a1b
zimindkp/pythoneclipse
/PythonCode/src/Exercises/palindrome.py
853
4.4375
4
# K Parekh Feb 2021 # Check if a string or number is a palindrome #function to check if number is prime def isPalindrome(n): # Reverse the string # We create a slice of the string that starts at the end and moves backwards # ::-1 means start at end of string, and end at position 0 (the start), move w...
ca6c82d5cf36cd9018e49c296835a446143c4377
SetaSouto/torchsight
/torchsight/models/anchors.py
22,451
3.609375
4
"""Anchors module""" import torch from torch import nn from ..metrics import iou as compute_iou class Anchors(nn.Module): """Module to generate anchors for a given image. Anchors could be generated for different sizes, scales and ratios. Anchors are useful for object detectors, so, for each location (o...
c6468f1e40c442c13b97f54a677a7a23c336b057
Seetha4/GraduateTrainingProgram2018
/python/day8.py
1,317
3.59375
4
import pandas as pd raw_data1 = { 'subject_id': ['1', '2', '3', '4', '5'], 'first_name': ['Alex', 'Amy', 'Allen', 'Alice', 'Ayoung'], 'last_name': ['Anderson', 'Ackerman', 'Ali', 'Aoni', 'Atiches']} data1=pd.DataFrame(raw_data1) raw_data2 = { 'subject_id': ['4', '5', '6', '7', '8'], ...
69be4d17197541b83dd01bdfe2aa5e7049dd9202
r-ellahi/python_tasks
/task_sheet5b.py
2,129
4.15625
4
#CSV # Q1 read the ford_escort.csv example file using python csv library and print each row import csv with open('ford_escort.csv', 'r') as file: reader = csv.reader(file, delimiter = ',') for row in reader: print(row) # Q2 Extend the above so that the data is read into a dictionary import csv wi...
eb3fc28a057076563a37993b65bee8bd0bc56048
DamonTan/Python-Crash-Course
/chapter1-6/ex5-3.py
330
4.1875
4
alien_color = input("Please enter your alien's clolor: ") if alien_color == 'green': print("The alien is green, so you can get 5 points!\n") elif alien_color == 'yellow': print("The alien is yellow, so you can get 10 points!\n") elif alien_color == 'red': print("The alien is red, so you can get 15 poi...
86727a07d4b7fe7a6abd40bc643b4812a8dc5fc0
melodyzheng-zz/SIP-2017-starter
/Unit1_Foundations/shapes2/pythonshapes_starter.py
399
4.21875
4
from turtle import * import math # Name your Turtle. t = Turtle() # Set Up your screen and starting position. color = input("What color?") pencolor(color) setup(500,300) x_pos = 0 y_pos = 0 t.setposition(x_pos, y_pos) x= 0 begin_fill() s = input("How many sides?") for x in range (s): forward(50) right(360/...
d830714198548e66a329a05ed4fcbb4d30e0e52d
alexwalling/ai3202
/Assignment_5/Graph.py
4,381
3.640625
4
class Node: def __init__(self, x, y, wall, reward): self.parent = None self.utility = 0 self.x = x self.y = y self.wall = wall self.reward = reward def printNode(self): print self.x, self.y, self.reward, self.utility, self.wall, self.parent class Graph: def __init__(self, height, width, gamma = 0.9):...
e6f3c3a0e327762910a2d3f54f26503d360c11c7
Sapna20dec/Dictionary
/questions9.py
412
3.625
4
# word="mississippi" # count=0 # for i in word: # if i=="m": # count["m"]=count["m"]+1 # elif i=="i": # count["i"]=count["i"]+1 # elif i=="s": # count["s"]=count["s"]+1 # elif i=="p": # count["p"]=count["p"]+1 # print(count) # dic="mississippi" # n={} # c=0 # for ...
8ad1393e905658f787eb36b313e4566622262dd6
staryjie/14day3
/day1/s1.py
1,727
3.5625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' #10进制转二进制 num = int(input("Pls enter a number: ")) print(bin(num)) ''' ''' 8bit = 1bytes 字节,最小的存储单位,1bytes缩写为1B 1KB = 1024B 1MB = 1024KB 1GB = 1024MB ITB = 1024GB 1PB = 1024TB 1EB = 1024PB 1ZB = 1024EB 1YB = 1024ZB 1BB = 1024YB ''' ''' ASCII编码不支持中文 1981年5月1日,GB2312编码...
44fdd66802449cac5f9435e1046341de8df63c6c
palakbaphna/pyprac
/Lists/15JoinMethodList.py
613
4.5625
5
#the method join is used; this method has one parameter: a list of strings. # It returns the string obtained by concatenation of the elements given, # and the separator is inserted between the elements of the list; # this separator is equal to the string on which is the method applied a = ['red', 'green', 'blue'] pri...
a7a0dbfbf9780c50b91b81fd9147da1fb46458d2
love68/studypython
/basic/day01/demo/func4.py
207
3.90625
4
# 可变参数 def calc(*numbers): sum = 0 for n in numbers: sum = sum + n * n return sum print(calc(1,2,3,4,2.1)) num = [1,2,3] # list 作为可变参数 print(calc(*num))
f4728bf5ecf8c1b9fd66cbad669e239c676674e7
Pythoner-Waqas/Backup
/C vs Python/py prog/1.py
342
3.859375
4
#if user enter 7531, #it displays 7,5,3,1 separately. number = int(input("Please enter 4 digit integer ")) fourth_int = number%10 number = int(number/10) third_int = number%10 number = int(number/10) second_int = number%10 number = int(number/10) first_int = number print (first_int, "," , second_int, "," , third_i...
ba5669f783d742c2469a4e27f4e634cff2416208
Mumulhy/LeetCode
/1185-一周中的第几天/DayOfTheWeek.py
838
3.84375
4
# -*- coding: utf-8 -*- # LeetCode 1185-一周中的第几天 """ Created on Mon Jan 3 10:23 2022 @author: _Mumu Environment: py38 """ class Solution: def dayOfTheWeek(self, day: int, month: int, year: int) -> str: week = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"] idx = 0 ...
6ed137e9b82850b61ab16a1976b26aa6b964462d
shahryarabaki/ICE
/src/collocations_method_1.py
5,114
3.59375
4
from nltk.corpus import wordnet import re from .pos_tagger import POS_tag_cleaner # Method to determine if a phrase is a collocation based on dictionary based technique # Uses WordNet from NLTK corpus to obtain definitions of the words when both # the word and it's sense are passed as inputs def Collocations_Method_1...
edc60d1e12c1c5ae3dc0b38323ab67b5bfdcaf50
SohyunNam/sso
/test.py
140
3.5625
4
from collections import OrderedDict my_dict = OrderedDict() my_dict[1] = 1 my_dict[2] = 2 my_dict[3] = 3 print(my_dict.popitem(last=False))
4995a90907a61667a9a33aeb6fb0b33f5c9c3d69
diachkina/PythonIntroDiachkina
/Lesson6-7/home_work13.py
255
3.53125
4
from random import randint lst = [randint(1, 100) for _ in range(10)] print(lst) lst.append(0) k = int(input("Enter the index: ")) c = int(input("Enter the value: ")) for ind in range(len(lst) - 1, k, -1): lst[ind] = lst[ind - 1] lst[k] = c print(lst)
b6806536eab5f36c67cc590d27ba13000eabd294
Dismissall/info_msk_task
/io_and_operation/symmetrical_num.py
173
3.703125
4
number = int(input()) first_part = number // 100 second_part = number % 100 second_part = second_part % 10 * 10 + second_part // 10 print(second_part - first_part + 1)
712df6e153667b6165f0820c96c52ef633e8ff7e
xDannyCRx/Daniel
/ClassExample1.py
540
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: class itspower: def __init__(self,x): self.x=x def __pow__(self,other): return self.x**other.x a=itspower(2) b=itspower(10) a**b # In[11]: def factorial(n): f=1 while n>0: f*=n n-=1 print(f) factorial(4) # In[12]:...
6ca7afa79193b60dca8eef6df9348a59a04411f0
v1ktos/Python_RTU_08_20
/Diena_1_4_thonny/if_else_elif.py
692
4.125
4
# if a = 0 b = 5 c = 10 if a > b: print("a > b") print("Also do this") print(a*b) # a <= b: else: # if a <= b: print(a,b) print("a is less or equal than b") if a != 0: print("Cool a nonzero a") print(b / a) b += 6 b -= 1 if b > c: print("b is larger than c", b, c) elif b < c: ...
b1e8d42910fe31737b66a3f4c427122d37d1a76c
Artemis21/game-jam-2020
/artemis/utils.py
819
3.5
4
"""General utilities.""" import json import typing # --- Data storage files def open_file(file: str) -> dict: """Open the file, if present, if not, return an empty dict.""" try: with open(file) as f: return json.load(f) except FileNotFoundError: return {} def save_file(file...
00a0d495c0e449a70003d685b40c7001501f6e40
lukereed/PythonTraining
/Class/Class_01/Class_01.py
2,814
4.5625
5
#!/usr/bin/python # Luke Reed # RES Python Class 01 # 01/07/2016 # Classic "hello world" welcome to programming print "Hello World!" print "Hello Again!" # We can now learn about different types type(55) # this will return 'int' for integers type(55.34) # this will return 'float' for floating points type...
06945db5be1d64102ab05fdd3ebb04e474710788
vmasten/madlib-cli
/madlib.py
2,886
4.1875
4
"""Recreates the game of Mad Libs. First, the user is prompted for parts of speech. Then, the prompts are recombined into a silly story Finally, the completed story is displayed. """ import re def greeting(): """Greet the user and provide instructions.""" print("Let's write a silly story. I'm going to promp...
17b7410330ee2eda58e88f7800a127af79ee8a44
seggiepants/rosetta
/python/mugwump/mugwump.py
3,868
3.984375
4
from random import randint from math import sqrt CONSOLE_W = 80 GRID_W = 10 GRID_H = GRID_W MAX_TURNS = 10 NUM_MUGWUMPS = 4 def center_print(message): x = (CONSOLE_W - len(message)) // 2 # // does integer division print(' ' * x + message) def init_mugwumps(mugwumps): for mugwump in mugwumps: mugw...
7b3f5897e6e1c0a5a4c8e7590dacf428fab0fb6d
HiThereItsMeTejas/Python
/count.py
577
3.703125
4
import xlrd from collections import Counter def FindDuplicates(in_list): counts = Counter(in_list) two_or_more = [item for item, count in counts.items() if count >= 2] print (two_or_more) # print Counter(two_or_more) return len(two_or_more) > 0 workbook = xlrd.open_workbook(r"C:\Users\Vi...
798533fc7479757df608a9b228323eea36a0e122
spradeepv/dive-into-python
/hackerrank/domain/data_structures/linked_lists/merge_point.py
766
3.953125
4
""" Find the node at which both lists merge and return the data of that node. head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node """ def FindMergeNode(headA, headB): data = N...
ea6f82c5c805e270785b1e05267f9cdfa08c03b3
krijnen/vuurschepen_northsea
/location.py
503
3.703125
4
from math import * class location(object): def __init__(self, x, y): self.x = x self.y = y def update(self, v, theta): self.x += v * cos(theta / 180 * pi) self.y += v * sin(theta / 180 * pi) def distance(self, location): dx = location.x - self.x dy = locat...
0b4f14963b6d694152b44da08b02acb2402e01a3
chavan-tushar/python-CA1
/createPayslipUsingClass.py
5,172
3.5625
4
class PrintPaySlip: # def __init__(self): # self.forStaffID = staffID; def printSalarySlip(self): with open("./Accounts/Hours.txt") as hrs: for data in hrs: dataInList = data.split() forWeek = dataInList[0] forStaffID = dataInList[1] ...
a5cb61581e3e31485d2f69579ec38830b5fd8d00
Avinash110/LeetCode
/Backtracking/78 Subsets/Solution.py
917
3.546875
4
class Solution: # Using binary counter def subsetsUsingBinary(self, nums): output = [] length = len(nums) for i in range(2**length, 2**(length + 1)): binNum = bin(i) currSS = [] for j in range(3, len(binNum)): if binNum[...
236ad98f976d13d21b5ef555d2d8fbf5e1185894
pavanmadiwa/Python--Let-s-upgrade
/Python- Let's upgrade- Day 2 Assignment.py
1,899
4.28125
4
#!/usr/bin/env python # coding: utf-8 # # Assignment 2: # a. Basic python syntax: # In[2]: #Ritual: print("Hello beautiful world") # In[4]: print("This is a back slash \ character ") # In[5]: print("Welcome python") # In[7]: print("This is my the use of \"backslash\" character") # In[10]: print("""...
5ff58f339b14906e013cd6b6291605d95e0beec1
tawhid37/Python-for-Everybody-Coding
/DataStructure Python/list2.py
581
3.953125
4
fname = input("Enter file name: ") file=open(fname,'r') count=0 lst=list() for x in file: line=x.rstrip() if line.startswith('From '): words=line.split() count=count+1 print(words[1]) print("There were", count, "lines in the file with From as the first word") """count = 0 for line in fh: line = line.rst...
013b7f6c9c9bdd75290bbf0a9ccc966352e4efd4
ganesh909909/html-bootstrap
/Acessing instance variables.py
356
3.84375
4
#within the class by using self from outside of the class by using object reference class student: def __init__(self,x,y): self.name=x self.age=y def info(self): print('hello my name is :',self.name)#(self) print('my age is :',self.age) s1=student('ganesh',24) s1.info() print(s1...
566c1185799ef4a59650bd5f4b804f76cc4c00c7
Arturou/Python-Exercises
/python_demos/function_exercises/level_one_two.py
288
3.90625
4
""" MASTER YODA: Given a sentence, return a sentence with the words reversed """ def master_yoda(text): arr = text.split(' ') arr = arr[::-1] return ' '.join(arr) print("Test #1: {}".format(master_yoda('I am home'))) print("Test #2 {}".format(master_yoda('We are ready')))
0fda2a640c3f4c394e003d1e7eaee69186c9885a
StephanieCherubin/Tweet-Generator
/robot_random_name.py
1,402
3.890625
4
# import random # import string # class Robot(object): # used_names = set() # def __init__(self): # self.reset() # def generate_new_random_name(self): # while True: # new_random_name = self.random_name() # if new_random_name not in self.used_names: # return new_random_name...