blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
5165e3c3d37e074668993abfd8245d1f05fca6fd | sheetaljantikar/python-codes | /hashtable_linkedlist.py | 971 | 3.796875 | 4 | class Node():
def __init__(self,value):
self.value=value
self.next=None
class Linkedlist():
def __init__(self):
self.head=None
class Hashtable():
def __init__(self,size):
self.size=size
self.table=[0]*size
def create_ll(self):
self.ll=[0]*self.... |
083b74c89503b69560fa875869144f20c522de85 | pkoluguri/learning-python | /problem/morse_code.py | 1,350 | 3.640625 | 4 |
text_to_morse = {"a":"._",
"b":"_...",
"c":"_._.",
"d":"_..",
"e":".",
"f":".._.",
"g":"__.",
"h":"....",
"i":"..",
"j":"._ _ _",
"k":"_._",
... |
a99ce988010eae6e096f468eef6929550f179cc1 | filipepgoes/tf | /csp.py | 2,407 | 3.609375 | 4 | # Estimates the closing stock prices of Apple Inc. using an artificial recurrent neural network called
# Long Short Term Memory (LSTM) using the past 60 days stock price.
import math
import pandas_datareader as web
import numpy as np
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import S... |
62ca21a93ce518a96587a022508a2bfec377da23 | zzz136454872/leetcode | /twoOutOfThree.py | 430 | 3.84375 | 4 | from typing import List
class Solution:
def twoOutOfThree(self, nums1: List[int], nums2: List[int],
nums3: List[int]) -> List[int]:
c1 = set(nums1)
c2 = set(nums2)
c3 = set(nums3)
return list(c1 & c2 | c1 & c3 | c2 & c3)
nums1 = [1, 1, 3, 2]
nums2 = [2, 3]
... |
d104c6f85d126ccc0bcea066cfd16b7df8c74d8c | ltk/PyCry | /pycry | 6,601 | 3.84375 | 4 | #! /usr/bin/env python
import binascii
import inquirer
import os
import re
import secrets
import sys
from zipfile import ZipFile
from pycry_aes import decrypt, encrypt
def main():
# Don't let anyone try to run this without Python 3
if sys.version_info[0] < 3:
raise Exception("Please use Python 3.")
... |
169fe5d3674da81008e79af21bad31e425f344f8 | r1shabh/LeetCode-Problems | /MergeSortedLists.py | 1,148 | 3.828125 | 4 | __author__ = 'rishabh anand'
class Solution(object):
def merge(self, nums1, m, nums2, n):
while len(nums1) > m:
nums1.pop()
i1 = 0
i2 = 0
while i1 < m and i2 < n:
if nums2[i2] >= nums1[i1]:
if i1 == m - 1 or nums1[i1 + 1] >= nums2[... |
ee6ffabc714333138d0a5c5dc0ac98b5909f94f8 | nralex/Python | /1-EstruturaSequencial/exercício07.py | 297 | 4.125 | 4 | # Faça um Programa que calcule a área de um quadrado, em seguida mostre o dobro desta área para o usuário.
comprimento = largura = float(input('Informe a largura: (cm) '))
print(f'A area do quadrado é {comprimento * largura}cm²\nE o dobro desta área é {(comprimento * largura) * 2}cm²')
|
04a329fecbb510a54e7aab3cb7bf31de77d2f458 | JajoScript/Python_POO_Notes | /four.py | 1,518 | 3.8125 | 4 | class Coche():
# Estado inicial.
def __init__(self):
# Propiedades.
self.__Largo = 250
self.__Ancho = 120
self.__Ruedas = 4
self.__Encendido = False
# Metodos.
def Arrancar(self, Arrancamos):
self.__Encendido = Arrancamos
if self.__Encendido == True:
... |
e61eca3fcf245c18a438d0b8cce8d3302ac0c96d | DorogAD/some_tests | /task2_sum_function.py | 735 | 4.25 | 4 | """
ЗАДАНИЕ
--------------------------------------------------------------------------------
Написать функцию, которая вернет результат сложения цифр целого числа
"""
def num_sum(numb: int) -> int:
"""
Calculating sum of number's digits
"""
result = 0
for element in str(numb):
result +... |
6766d990b7c98cfe2dcadf44d19d5f495b59c5a5 | Beryl2208/CI-2 | /Coding Club India/Asked Goldman Sach Interview Questions/2SuminBST.py | 555 | 3.578125 | 4 | def inorder(head, arr):
if head:
inorder(head.left, arr)
arr.append(head, arr)
inorder(head.right, arr)
return arr
def 2SumBST(head1, head2, summ):
arr1 = []
arr2 = []
arr1 = inorder(head1, arr1)
arr2 = inorder(head2, arr2)
i, j = 0, len(arr2)-1
while i < len(arr1) and j >= 0:
add = arr1[i] + arr2[... |
195b4955345859075d9a736281f5399680a37557 | mikolajf/sailing-tdd | /sailboat.py | 655 | 3.609375 | 4 | from utils import sides
class Sailboat(object):
def __init__(self, initial_heading):
self._heading = initial_heading
def get_heading(self):
return self._heading
def change_course(self, course_diff):
self._heading = (self._heading + course_diff) % 360.0
... |
e91eeac36aa1f9d7a662aa2ec340cc55efb63483 | OmarWAboZeid/Risk | /game_componenets/game.py | 6,384 | 3.625 | 4 | import math
import random
from game_componenets.city import City
from game_componenets.map import Map
class Game:
"""
Attributes:
map: id of each city maps to ids of adjacent cities
cityList: id of each city maps to information about this city
soldiersCount:
... |
d8f115fdb09ef0fb50dab3971f0e39499b2ec112 | GTPB/PPB17 | /day2/1-PythonPrograms/d2_programing_data_scripts/read_seq_print.py | 185 | 4.09375 | 4 | '''
Python Programs - Exercise 3
The script reads the insulin sequence from a file
and prints it to the screen.
'''
insulin = open("insulin.txt")
seq = insulin.read()
print seq
|
6eaa56094bdadaf20ecf07061fa64d4b2cd7b122 | cglima/python-brasil-exercicios | /estrutura_sequencial/exercicio_04.py | 434 | 4 | 4 | """
4. Faça um Programa que peça as 4 notas bimestrais e mostre a média.
"""
nota1 = int(input("Digite a primeira nota do bimestre: "))
nota2 = int(input("Digite a segunda nota do bimestre: "))
nota3 = int(input("Digite a terceira nota do bimestre: "))
nota4 = int(input("Digite a quarta nota do bimestre: "))
media = ... |
4f78b091ac950eacb74bf0c41f2f20f2f34675cd | http-www-testyantra-com/Surbhi_Sony | /training_day2/decorator/d1.py | 327 | 3.90625 | 4 | import time
def sqaure(n):
start = time.time()
for i in range(n):
res = i **2
end = time.time()
print("total time taekn as ", end)
sqaure(100000)
def cube(n):
start = time.time()
for i in range(n):
res = i ** 3
end = time.time()
print("total time taekn as ", end)
cube(1... |
bfcac608793d16b9633870e56987268d54b2f0e0 | MicheSi/algorithms-project | /moving_zeroes/moving_zeroes.py | 751 | 4.25 | 4 | '''
Input: a List of integers
Returns: a List of integers
'''
def moving_zeroes(arr):
# Your code here
# number of non zero integers
num = 0
# loop through array
for i in range(len(arr)):
# if i is not zero, replace with num at arr[num]
# increment num to change index of pointer
... |
dd4415625e15c4fbddffe8c140f42730eb4915cf | JamesElgey/git_review | /word_count.py | 598 | 3.875 | 4 | WORD_COLLECTION = {}
def main():
word_list = {}
str_count = 0
text = str(input("Give a sentence:"))
for word in text.split():
word_str = 0
for char in word:
word_str = word_str + 1
if word_str > str_count:
str_count = word_str
if word in WO... |
68ebd8cd921bbbba241c1368a01202b2412068c2 | anshu-gautam/python_learning | /list.py | 517 | 3.875 | 4 | def maxElement(arr):
max = arr[0]
for x in arr:
if x > max:
max = x
return max
def minElement(arr): # [23, 45, 1, 89, 77]
min = arr[0]
for x in arr:
if x < min:
min = x
return min
listx = []
num = int(input("no of numbers in list"))
for n in range(n... |
eb908fc55693673c3cc93ab012c9a47c7c021b17 | calgagi/leetcode | /0876/answer.py | 433 | 3.78125 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def middleNode(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
it = head
count = []
... |
0681304dd055106d42227843f2839c5368e462dd | BrockMHarris/Poker | /make_rank.py | 2,337 | 3.9375 | 4 | # I affirm that I have carried out my academic endeavors with full academic honesty -Brock Harris
import Deck as deck
import FiveCardHand as check
HIGH_CARD = 0
PAIR = 1
TWO_PAIR = 2
FLUSH = 3
def get_ranks_in_hand(hand):
"""
puts the ranks for each card in a hand and puts them into a new list
:param han... |
c74d83b215d2fc46777c83570908d24a3d2c17d0 | Gokulyeswi/recursive | /README.py | 237 | 3.5625 | 4 | # recursive
def main():
a=[1,2,3,4,5]
b=[0,0,0,0,0]
n=len(l)
def rev():
i=0
j= n-1
while(i<n):
if(i==n):
return 0;
else :
b[i]=a[j]
i=i+1
j=j-1
rev()
print (b)
if __name__ == '__main__':
main()
|
6d7c5035cb28bb47363f018d523716c7e6e9ab46 | mauro3/VarGlaS | /src/model.py | 10,934 | 3.515625 | 4 | from dolfin import *
class Model(object):
"""
Instance of a 2D flowline ice model that contains geometric and scalar
parameters and supporting functions. This class does not contain actual
physics but rather the interface to use physics in different simulation
types.
"""
def __init__(self):
sel... |
24090bbe9b6eedf75e9d4e48e0a644ebd01d8039 | j-c-cook/pygfunction | /examples/custom_bore_field.py | 1,912 | 3.546875 | 4 | # -*- coding: utf-8 -*-
""" Example of definition of a bore field using custom borehole positions.
"""
import pygfunction as gt
def main():
# -------------------------------------------------------------------------
# Parameters
# -------------------------------------------------------------------------
... |
f3877c0ff38840bf326ae7973499bbbed8de9d32 | esmiroco/heuristicas-de-cobertura-de-conjuntos | /con guardado de subjonjuntos no inmediatamente optimos.py | 996 | 3.5 | 4 | L = [[4,5],[1],[1,3,5],[2,4,5],[1,2],[3],[1,6,5]]
L.sort(key=lambda x:len(x), reverse=True)
L = [[1, 3, 5], [1, 6, 5], [2, 4, 5], [4, 5], [1, 2], [1], [3]]
print(L)
S = [1,2,3,4,5,6]
M = []
T = L[0]
nT = list(set(S)-set(T))
i = 1
contador = 1
while (len(T)<len(S)) & (i < (len(L)- 1)):
if len(list(set(L[i])... |
36668911360c190ceb7af531f847798be5278019 | Makhanya/PythonMasterClass | /lists/ListMethodsExercise.py | 1,093 | 4.21875 | 4 | # Lists Methods Exercise
# Now that we've learned about list methods, let's get some practice.
# See the problem statements in the comments below:
# # Create a list called instructors
# instructors = []
# # Add the following strings to the instructors list
# # "Colt"
# # "Blue"
# # "Lisa"
# instructors.extend(["Co... |
127cb79b3a9ba68f413da5bcccf3b24798ad9343 | nyuxz/CodePractice | /101_Symmetric_Tree.py | 2,924 | 4.1875 | 4 | # 101. Symmetric Tree
# https://leetcode.com/problems/symmetric-tree/description/
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def isSymmetric(self, root):
"... |
f4f85800e31ce84b1d173e412fca5e9776664a64 | graefft/higher_level_programming | /0x0B-python-input_output/12-student.py | 718 | 3.734375 | 4 | #!/usr/bin/python3
"""Module for Student class"""
class Student:
"""Student class"""
def __init__(self, first_name, last_name, age):
"""Initializes class"""
self.first_name = first_name
self.last_name = last_name
self.age = age
def to_json(self, attrs=None):
"""Ret... |
8fe3dd0d72e8c3f7bd3ff82fbe27d7dbda2afc88 | ichsankurnia/Python-Basic | /NetAcad/modul_3/lab_2.py | 1,859 | 3.96875 | 4 | """
In 1937, a German mathematician named Lothar Collatz formulated an intriguing hypothesis (it still remains unproven) which can be described in the following way:
take any non-negative and non-zero integer number and name it c0;
if it's even, evaluate a new c0 as c0 ÷ 2;
otherwise, if it's odd, evaluate a new c0 as... |
6efe79dd2058f112a08faa463a02c8c492acdb4f | pinky0916/python_Basics | /Geeksforgeeks/Matrix_addition.py | 471 | 3.75 | 4 |
print("Method#1")
A = [[1,2],
[3,4]]
B = [[9,8],
[1,2]]
result=[list(map(sum,zip(*t))) for t in zip(A,B)]
print(list(result))
print('**************************************************')
print("Method#2")
x=[[1,2,3,4],
[4,5,6,5],
[7,8,9,10]]
y=[[9,8,7,1],
[6,5,4,1],
[3,2,1,1]]
z=[[0,0,0,0],
... |
a98bc5ea5285bc848f430c29e60488bb2df32629 | nicolageorge/play | /amazon/deleteNthNode.py | 1,058 | 3.640625 | 4 | class Node:
def __init__(self, val):
self.val = val
self.next = None
class LL:
def __init__(self, root=None):
self.root = root
self.last_node_added = root
def add(self, node):
if(self.root):
self.last_node_added.next = node
self.last_node_add... |
ec75c34b5e49a95bb4503cf15eaab0e0d6aa28cf | Mayank-141-Shaw/Python-Repo | /Upload/prob1.py | 688 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 20 22:40:00 2020
@author: MAYANK SHAW
"""
import random as rd
import time
def return_heads():
heads = 0
for i in range(100):
if rd.random() <= 0.5:
heads += 1
return heads
def generate(n):
trials = []
for i in ra... |
f46326a41395c214ae94065c89f6913f4d15c138 | younheeJang/pythonPractice | /for_loop/palindrome.py | 634 | 4.03125 | 4 | def is_palindrome(word):
reserved = ''
i = 0
word_list = list(word)
print(word_list)
while i < len(word_list):
i += 1
reserved += word_list[len(word_list)-i]
if(reserved == word):
return True
else:
return False
print(is_palindrome("racecar"))
print(is_palindr... |
2d60b8f286b61c04af94ef4f211b0a28bf856af0 | toljio/hyperskill_python | /Smart Calculator/Problems/Dating App/task.py | 160 | 3.625 | 4 | def select_dates(potential_dates):
return ", ".join(x["name"] for x in potential_dates if x["age"] > 30 and "art" in x["hobbies"] and x["city"] == "Berlin") |
ee5559a0a33d0ce67cd790f8816291d47ddb3802 | dosmilego/my_learning_record | /week1/palindrome.py | 887 | 3.515625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: palindrome.py.py
Description : 实现判断一个数是不是回文数的函数
Author : changyy
date: 2020/4/11 0011 18:24
-------------------------------------------------
Change Activity:
... |
347adff551d4b43b075e36f3ef24b4c2b9a6a3b1 | DanilloMLS/lista_de_exercicios | /2014-1-bcc-ip-L2.2-DanilloMoraesLimaDosSantos/Q17.py | 634 | 3.625 | 4 | mquad=input("Digite o tamanho da rea a ser pintada: ")
qtinta=round((mquad/6.)*1.1,0)
latas=round((qtinta/18),0)
galoes=round((qtinta/3.6),0)
mistlata=round((qtinta/18),0)
mistgaloes=round(((qtinta % 18)/3.6),0)
precolata=latas*80
precogaloes=galoes*25
precomist=(mistlata*80)+(mistgaloes*25)
print ("Voc va... |
72d4b5b793fee2d14cdf5909099484420992485c | ddrum001/interview-prep | /cracking/ch3/linked_que.py | 1,595 | 4.0625 | 4 | class Node:
def __init__(self):
self.data = None # contains the data
self.next = None # contains the reference to the next node
class LinkedQue:
def __init__(self):
self.first_in = None # use first_in for deque
self.last_in = None # use last_in for enque
def enque(self, ... |
52d5a1b663893de759a1f5b68acf9dc2bd003a3a | Aasthaengg/IBMdataset | /Python_codes/p02401/s689359704.py | 329 | 3.65625 | 4 | while True :
a, op, b = map(str, raw_input().split(" "))
a = int(a)
b = int(b)
if (op == "?") :
break
elif (op == "+") :
print("%d" % (a+b))
elif (op == "-") :
print("%d" % (a-b))
elif (op == "*") :
print("%d" % (a*b))
elif (op == "/") :
print("%d"... |
058ae5d024f29ab5f59e49defe6736f451bd1402 | qy789955/hello-2 | /python/14paixu.py | 308 | 3.828125 | 4 | # 模块:具有一定功能的函数放在一个python文件中,这个文件就是模块
# 将一个功能定义进去函数
def mp(number):
for j in range(0,len(number)):
for i in range(j+1,len(number)):
if number[i]>number[j]:
number[j],number[i]=number[i],number[j]
return number
print(4) |
1a1d017a608b760f61cc9c21b8a00e8a967de189 | Tanmay53/cohort_3 | /submissions/sm_104_asheeh/week_13/day_4/session1/sets_difference.py | 177 | 3.859375 | 4 | set1 = {3,5,6,8,9,7,65,4,33,"aman"}
set2 = {5,6,8,99,4,6,8, "albert"}
difference = set()
for ele in set1:
if ele not in set2:
difference.add(ele)
print(difference) |
495ade75bfac76b0ed076583f65e2111955319e1 | VishalJadhav90/ProblemSolving | /BitwiseSwapOddEvent.py | 603 | 3.6875 | 4 | def swap_odd_even(n):
a = bin(n)
print(a)
bits = len(str(a)[str(a).find("0b") + 1:])
print(bits)
for i in range(0, bits):
if i%2 == 1:
if n & (1 << i) != 0:
now = 1
else:
now = 0
if previous == 0:
n = n & ~(... |
814fb4b2860b344720b9e320319ce6243dcc8232 | phugay/leetcodes | /first_bad_version.py | 735 | 3.5625 | 4 | # Given n = 5, and version = 4 is the first bad version.
# call isBadVersion(3) -> false
# call isBadVersion(5) -> true
# call isBadVersion(4) -> true
# Then 4 is the first bad version.
# The isBadVersion API is already defined for you.
# @param version, an integer
# @return a bool
# def isBadVersion(version):
cl... |
cbe0d0a1c2579db9256dbccbb6eaa38e5457e1c1 | ChefMask/codeoff | /faceoff_with_micheal.py | 1,006 | 4.21875 | 4 | #score converter created on 15 Feb 2020 by 4:16 A.M GMT+1
score = input("What is your score?")
score = int(score)
if score > 100:
print ("Invalid score... You can't be that brilliant")
elif score >= 70:
print ("Your grade is A")
if score >= 80 and score <= 100:
print ("Fantastic job.But ... |
87491212f032a3da3c94c15f25dda28c7ad2c0b6 | Eroica-cpp/LeetCode | /275-H-Index-II/Python/Solution01.py | 996 | 4 | 4 | #!/usr/bin/python
"""
==============================================================================
Author: Tao Li (taoli@ucsd.edu)
Date: Oct 1, 2015
Question: 275-H-Index-II
Link: https://leetcode.com/problems/h-index-ii/
==============================================================================
Follow ... |
0069f2b9007bd701715ed68e9f78de58292e378a | Akmalhakimteo/10.009-The-Digital-World | /DW_cohort5.2.py | 687 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 15:42:35 2019
@author: akmal
""" #RECURSION
# For or while loop - iterative
def printhello(n):
if n==0: #Terminating/stopping condition
pass
else:
print("Hello") #call yourself back
... |
a6458853bed4f5d31fc0eac5d1223a1e89fa2038 | sumit54/GitHub | /python/ConstructorChaining.py | 551 | 3.984375 | 4 | class Animal:
def __init__(self, animalName):
print(animalName+ ' is an animal.');
class Mammal(Animal):
def __init__(self, mammalName):
print(mammalName+ ' is a warm-blooded animal.')
Animal.__init__(self,mammalName)
class NonMarineMammal(Mammal):
def __init__(self, NonMarineMammalName):
pr... |
31d53d9b5e5da3c73104e4b00e8947d50c4f88d2 | jcgarciach/X-Serv-13.6-Calculadora | /calculadora.py | 501 | 3.609375 | 4 | #!/usr/bin/python3
import sys
if sys.argv[1] == 'sumar' :
print (float(sys.argv[2]) + float(sys.argv[3]))
elif sys.argv[1] == 'restar' :
print (float(sys.argv[2]) - float(sys.argv[3]))
elif sys.argv[1] == 'multiplicar' :
print (float(sys.argv[2]) * float(sys.argv[3]))
elif sys.argv[1] == 'dividir' :
try:
... |
92f8dc8ae61db940c6204a7465e59daced363623 | grgcameo/Macaron | /Pineapple/ByteOfPython/function1.py | 1,592 | 3.84375 | 4 | # function define
def say_hello():
print 'hello world'
say_hello()
say_hello()
# function with param
def print_max(a, b):
if a > b:
print a, 'is maximum'
elif a == b:
print a, 'is equal to', b
else:
print b, 'is maximum'
print_max(3, 4)
x = 5
y = 2
print_max(x, y)
# lo... |
f9bea505073ad8304b4f0ace0fdd1716dcb8c881 | wjl626nice/1902 | /python/20190429/demo05.py | 1,339 | 3.703125 | 4 | # 方法
'''
普通方法、静态方法和类方法
三种方法在内存中都归属于类,区别在于调用方式不同
普通方法:由对象调用;至少一个self参数;执行普通方法时,自动将调用该方法的对象赋值给self;
类方法:由类调用; 至少一个cls参数;执行类方法时,自动将调用该方法的类复制给cls;
静态方法:由类调用;无默认参数;
普通方法只能使用实例对象调用
类方法和静态方法,可以使用类调用,也可以使用实例对象调用
'''
class Foo:
def __init__(self, name):
self.name = name
def ord_... |
1e6f6d28e1f2dedff352e1038bac19f50bfbaed6 | maddiejohnson/CS115 | /LCS.py | 448 | 3.625 | 4 | def LCS(S1, S2):
if 0 == len(S1) or 0 ==len(S2):
return 0
elif S1[0]==S2[0]:
return 1 + LCS(S1[1:], S2[1:])
else:
return max(LCS(S1[1:], S2[1:]))
if not S1 or not S2:
return 0
else:
head1, tail1 = S1[0], S1[1:]
head2, tail2 = S2[0], S2[1:]
... |
6eef31702343bba99124c9503001273bad1492ca | yglj/learngit | /PythonPractice/廖雪峰Python/4.迭代.py | 1,315 | 4.0625 | 4 | # 遍历(iteration)可以通过for循环遍历一个可迭代对象
# 判断一个对象是否可迭代
from collections import Iterable
s=isinstance('abc',Iterable)
print(s)
s=isinstance([1,2,3],Iterable)
print(s)
s=isinstance(123,Iterable)
print(s)
#内置函数enumerate可以把list变成索引—元素对
for i,value in enumerate(['a','b','v']):
print(i,value)
def findMinAndMax(L):... |
698426f744872cca0241ad7b8e64e11d2b8aa325 | CS6-IdeaventionsAcademy/more-control-ifelifelse-bmutarelli | /RapisCaveAdventure.py | 7,811 | 4.15625 | 4 | #Brogan Mutarelli
#Dec 5th, 2017
#Raspi's Cave Adventure
#A text based adventure game
import time
def cls():
print ('\n' * 60)
cls()
def wrong():
print ("Please enter a diffrent answer")
time.sleep (1)
def left_cave():
print ("You walk into the left tunnel")
print ("You come across a river and s... |
e6ece2b987809b39f79a7f6ab219b4ed0cc95727 | SumitPugalia/heuristics | /python/rat.py | 1,304 | 3.78125 | 4 | def path(maze):
source = (0, 0)
destination = (len(maze) - 1, len(maze[0]) - 1)
visited = {}
sol = []
res = []
sol.append(source)
return recursePath(maze, source, destination, sol, res, visited)
def recursePath(maze, source, destination, sol, res, visited):
moves = [(1, 0), (-1, 0), (0,... |
7dca6c757fdbbf97575fa0128f683ff24d322c62 | zacherymoy/cs-sprint-challenge-hash-tables | /hashtables/ex4/ex4.py | 1,168 | 4.25 | 4 | def has_negatives(arr):
# create a dict wih a key for the original number
# and a value for the count of corresponding negatives
cache_list = [1]*len(arr)
# actual cache is now housing the list values
# as keys in a dictionary
actual_cache = dict(zip(arr, cache_list))
# next step is to check... |
d16b1462dec3d323c1728917064c98b59f3b34ed | ManishSharma-01/group-project-main | /Student_management_system.py | 9,693 | 3.765625 | 4 | from tkinter import *
from tkinter import messagebox, ttk
import sqlite3
root = Tk()
root.title("Student Management System")
root.geometry("800x800")
conn = sqlite3.connect("management.db")
c = conn.cursor()
# creating tables
#
# c.execute("""CREATE TABLE entries(
# first_name text,
# last_name text,
# username text,... |
3842335094427c425e69f37e528f04b030f78a04 | ericosur/ericosur-snippet | /Workfile/rotate_str.py | 569 | 3.8125 | 4 | #!/usr/bin/env python3
# coding: utf-8
''' rotate string '''
import itertools as it
def rotate_string(token):
''' rotate_string '''
sss = [set(), set(), set()]
for ii, cc in enumerate(list(token)):
sss[ii].add(cc.upper())
sss[ii].add(cc.lower())
for x in it.product(sss[0], sss[1], ss... |
cf7edfcee123988eeff34a8752a6a0ab65532226 | Rain0Ash/Programming_University | /Practice/03/Python/3.py | 1,178 | 3.71875 | 4 | while True:
try:
first, second = map(int, input("Введите первое и второе число, разделив их пробелом: ").split())
print("", "x + y = " + str(first + second), "x - y = " + str(first - second), "y - x = " + str(second - first),
"x * y = " + str(first * second), sep='\n')
if sec... |
d327bc981bcf0d88eee477ab9981a5312010caad | hetal149/Python_Django | /Day5/class_interest.py | 339 | 3.703125 | 4 | #calculate Interest
class cal3:
P=0
R=0
T=0
def __init__(self,P,R,T):
self.P=P
self.R=R
self.T=T
def callinterest(self):
I=self.P*self.R*self.T/100
self.I=I
def display(self):
print("Interest is",self.I)
myc=cal3(1000,3.75,5)
myc.callinterest()
my... |
37e1f55058f403089f6a309352571786d0b530e6 | SelivanovEgor/Python-first-steps | /Основы Python/2. Условные конструкции/chocolate.py | 489 | 3.78125 | 4 | try:
n = int(input("Введите число n: "))
m = int(input("Введите число m: "))
k = int(input("Введите число k: "))
except:
print("Вы ввели не числа!")
else:
if k > n * m:
print("NO")
else:
try:
if (k % n == 0) or (k % m == 0):
print("YES")
el... |
8a6616ee8022bd928d91a7c4902aafe3093ef09f | hallymsw/YouTube_Python_Beginner | /source/ch3/listEx7.py | 88 | 3.6875 | 4 | a=[1, 'a', 'b', 'c', 4]
# 0 1 2 3 4
a[1:3]=[]
print(a)
blist=[]
print(blist) |
d9caf7a41c8075abb7422f1d306bcf55971d97a6 | Shimada666/LeetCode | /python/844. 比较含退格的字符串.py | 678 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
:author: Shimada666
:url: https://github.com/shimada666
:copyright: © 2019 Shimada666 <Shimada666@foxmail.com>
:license: MIT, see LICENSE for more details.
"""
import itertools
class Solution:
def backspaceCompare(self, S: str, T: str) -> bool:
def F(S):
... |
00ff311fdc57e0b4edacbac658da91de453f8529 | heroca/heroca | /ejercicio71.py | 147 | 3.578125 | 4 | lista=["ana", 7, 9]
print("Nombre del alumno:")
print(lista[0])
promedio=(lista[1]+lista[2])//2
print("Promedio de sus dos notas:")
print(promedio) |
4524d64b7a561fadd33d14eb9f6896f6f0b5dc09 | mrjamrd/diplopython | /cap2/funcionDentro.py | 358 | 3.6875 | 4 | """
Una funcion dentro de otra funcion
"""
def getNombre(nombre):
texto = f"El nombre es: {nombre}"
return texto
def getApellido(apellido):
texto = f"El apellido es: {apellido}"
return texto
def allShow(nombre, apellido):
texto = getNombre(nombre) +" \n "+ getApellido(apellido)
return text... |
56ece079d71c270c7283623d162b9fae040197ee | AkashBalani/LeetcodePr | /arrays/wigglesort/wigglesort.py | 171 | 3.5625 | 4 | ## Accepted Solution
class Solution(object):
def wiggleSort(self, nums):
for i in range(len(nums)):
nums[i:i+2] = sorted(nums[i:i+2], reverse=i%2) |
f69d2bd6555fad63beff2d0d38d8fb51d0aa7215 | MarkHofstetter/python-2020-10-27 | /020-db/demo_select.py | 355 | 3.984375 | 4 | import sqlite3
conn = sqlite3.connect("students.db")
search_name = input("namen eingeben: ")
# BÖSE!!!
# sql = 'SELECT * FROM student WHERE name ="' + search_name + '"'
# nur mit bind variablen Wert vom User übernehmen
cursor = conn.execute('select * from student WHERE name = ?', (search_name,) )
for row in cursor:... |
c6e9b3e012f1b1752e03972593fc92c62a9c7bca | TaranSinghania/Yet-Another-Centralized-Scheduler | /log_analysis.py | 5,431 | 3.90625 | 4 | """
Performing Log Analysis
Functions:
* Parses log file specified
* Calculates mean and median task completion time
* Calculates mean and median job completion time
* Plots number of tasks scheduled on each machine vs time
"""
import sys
import matplotlib.pyplot as plt
class stats:
"""
Handles the following... |
9fc8ed758aa5e15ac16c20a80fe2dc6416008969 | cybelewang/leetcode-python | /code326PowerOfThree.py | 382 | 4.25 | 4 | """
326 Power of Three
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
"""
class Solution:
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
return n > 0 and... |
c033400866f1bf5b0e7b69700c38abd17fe88c66 | srcmarcelo/Python-Studies | /PythonTest/ex001.py | 165 | 4 | 4 | n1 = int(input('write a number:'))
n2 = int(input('another number:'))
s = n1 + n2
print('so, the sum of the number {1} and the number {0} is {2}'.format(n2, n1, s))
|
4a81c9109aea28ea6463f6c42227bb78353c977e | gonzalob24/BlackJack | /Hands.py | 1,258 | 3.78125 | 4 | from Decks import Deck
class Hands(Deck):
def __init__(self):
"""
Inherit functions from deck
"""
Deck.__init__(self)
self.hand_cards = [] # Creates an empty hand
self.value = 0 # 0 value
self.ace = 0 # Will keep track of aces
def add_card(self, car... |
9a58a8f437a1f3b1e7a3b7f688193a58f65e0c14 | gajomi/enzymatica | /inference/random_variable.py | 1,921 | 3.75 | 4 | class RandomVariable(object):
"""
A representation of a random variable, that defines the probability distribution over some space.
The space is the bounds of which the random variable exists, and the Pfun is the function provided
to the random variable that defines the probability density at a poin thtat is pr... |
830bc0389c4c5d278f03d4dd4d194aad2ecd5279 | endy-see/AlgorithmPython | /ZuoShen/14-IsPalindromeList.py | 2,695 | 3.71875 | 4 | """
判断一个链表是否为回文结构
题目:给定一个链表的头节点head,请判断该链表是否为回文结构
例如: 1->2->1,返回true。 1->2->2->1,返回true。 15->6->15,返回true。 1->2->3,返回false。
进阶: 如果链表长度为N,时间复杂度达到O(N),额外空间复杂 度达到O(1)。
"""
class Node:
def __init__(self, val):
self.value = val
self.next = None
# need n extra space
def isPalindrome1(head):
stack... |
d55c577ed8170fb3c8dda0a3762c3be6c3d3b596 | TanvirMobasshir/CSE246 | /lab_4/2.py | 356 | 3.875 | 4 | def sieve(n: int):
prime_numbers = [True] * (n+1)
prime_numbers[0] = prime_numbers[1] = False
i = 2
while i<=n:
if prime_numbers[i]:
print(i)
j=i*i
while j<=n:
prime_numbers[j]=False
j+=i
i+=1
if __name__ == "__main__"... |
82e59baa7153f6a81c7cca54248387c52c4f7c36 | stephenchenxj/myLeetCode | /202_Happy Number.py | 1,409 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 11:33:29 2020
@author: chen
202. Happy Number
Easy
1876
397
Add to List
Share
Write an algorithm to determine if a number n is "happy".
A happy number is a number defined by the following process: Starting with any positive integer, replac... |
4f8e8f3ad6ae7603894386ca2c6cd459fa06f4e6 | gsudarshan1990/Training_Projects | /Classes/class_example29.py | 1,003 | 4.65625 | 5 | """
This is another example of the class which elaborates on the type error
#Rewrite the "Number" class
#This time, however, require arguments for value and
#even in the constructor. Then, inside the constructor,
#create new instance variables called value and even that
#copy the values of the arguments passed into th... |
aa28ec0e4665f9a85776f577e6256746d99149ce | ninadpathak/Python-Projects | /Enumeration.py | 207 | 3.671875 | 4 | import time
def main():
a = input("Enter something: ")
enum(a)
def enum(a):
for i in range(0, len(a)):
print(a[i], end=' ')
time.sleep(0.1)
print()
main() |
cd84e2e60cbd1cb3285585cc6b273ff1ac0ffd63 | zabiullakhangithub/Python_Session1_Assignment_1.3 | /Assignment 1.3.py | 604 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 22 10:47:53 2018
@author: zabiulla.khan
Assignment 1.3
Write a Python program to accept the user's first and last name and then getting them
printed in the the reverse order with a space between first name and last name.
"""
#Get the first name from user
f... |
5294821a2832d7ca79ccf79e46bd8d6cd9367945 | binchen15/leet-python | /tree/BST/prob938.py | 1,394 | 3.546875 | 4 | # Range sum of BST
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def rangeSumBST(self, root, L, R):
"""
:type root: TreeN... |
4251f69fde97db97a800df161020be8526ead759 | asperaa/back_to_grind | /bactracking/291. Word Pattern II.py | 1,148 | 3.796875 | 4 | """We are the captains of our ships, and we stay 'till the end. We see our stories through.
"""
"""291. Word Pattern II
"""
class Solution:
def wordPatternMatch(self, pattern, str):
return self.helper(pattern, str, 0, 0, {}, {})
def helper(self, pattern, str, i, j, p_hash, s_hash):
if i ... |
198174acb9405756296d30ae4dde1fd8b2cb2827 | sanmankar/python_challange | /Py_Bank/main_backup.py | 2,009 | 3.53125 | 4 | import os
import csv
# Define function to count year and months
def sub_calc(val):
# Initialize variables...
cnt = 1
cnt_yr = 1
net_amount = 0
avg_amount = 0
grtst_increase = 0
grtst_decrease = 0
prior_val_incr = 0
prior_val_dcrs = 0
msg = []
for row in val:
net_... |
feb62c5a7e28b95481a048cce01d3f8732e497a3 | futureesch/ops401reading | /python/brute1of3.py | 1,442 | 4.125 | 4 | #!/usr/bin/env python3
# Author - Tom Esch
# Last Revised - 4/26/2021
# Ops Challenge - Automated Brute Force Wordlist Attack Tool Part 1 of 3
# Import libraries
import time, getpass
# Declare functions
def iterator ():
filepath = input("Enter your dictionary filepath:\n")
#filepath = ~/ops401reading/python
... |
ccade5a8809e1671aa430510b3672f5f22deca47 | hhs44/leetcode_learn | /机器人大冒险-robot.py | 837 | 4 | 4 | from typing import List
class Solution:
def robot(self, command: str, obstacles: List[List[int]], x: int, y: int) -> bool:
newx,newy=0,0
u_num = command.count("U")
r_num = command.count("R")
r = x/r_num
u = y/u_num
if r*u_num >y or u*r_num>x:
while True:... |
7fdbe63487b74c80ef7e45505ec5a97a2d115682 | bjk116/Sudoku | /data/importer.py | 919 | 3.546875 | 4 | """
Used to import .csv files into board classesto be played.
"""
import os
import csv
import sys
sys.path.append('..')
from components.board import Board
def parse_csv(file_path):
"""
Parses csv data.
"""
board=[[None for i in range(0,9)] for j in range(0,9)]
with open(file_path) as csv_file:
... |
1a4d93fb4ed4768aa3249ad0d6c7a637352556bc | Liu-Rundi-SDUWH/Applied-Time-Series-Analysis-in-Python | /作业二/pythonCode/1-DataVisulization.py | 8,663 | 4.15625 | 4 | '''
A quick introduction
'''
import matplotlib.pyplot as plt
import numpy as np
y = [3,4,1,5,2,10]
plt.plot(y,color = "b")
plt.xlabel('My x label')
plt.ylabel('My y label')
plt.title('My first plot :)')
plt.savefig("1-1.png")
n = 50
height = np.random.randint(30, size=n)
# print(height)
height1 = np.a... |
593fca2668402d00b23ccc9bffa593a7f5a48874 | jasuil/python | /day003/database/ex003.py | 497 | 3.875 | 4 | '''
.open mysql_lite.db
sqlite> .table
address menu student
sqlite> select * from menu;
짱성일|2000
성일짱|2300
jasuil|2700
'''
import sqlite3 as sql
conn = sql.connect("mysql_lite.db")
c = conn.cursor()
# foodName = input("food name?")
# foodPrice = int(input("food price?"))
#
# query = "insert into menu (menu, pri... |
cc0d3a067ed90b46fb50fb838d636031bb31bb2e | louiss007/MachineLearning | /naviebayes.py | 4,991 | 3.71875 | 4 | import csv
import random
import math
## step 1: load data...
def loadCsv(filename):
lines = csv.reader(open(filename, "rb"))
## for lin in lines:
## print lin
dataset = list(lines)
for i in range(len(dataset)):
dataset[i] = [float(x) for x in dataset[i]]
return dataset
##filename = '... |
85bf1c2a95b8484f70c3f3eb8bcafa3a44db0299 | simrangrover5/PythonAdvaceBatch11am | /OOPs/file1.py | 163 | 3.578125 | 4 | try:
a = input("\n Enter any number : ")
b = input("\n Enter any number : ")
except KeyboardInterrupt as e:
print("ERROR --> ",e)
print("hello world")
|
f999a50b98ea542fb74bd628850ed2388c2e70c6 | billiepander/basic_datastructure-algorithmwithpython | /DataSructur&Algorithm_with_python/LinkedList_09.py | 2,436 | 3.921875 | 4 | class LinkedList:
class __Node:
def __init__(self, item, next = None):
self.item = item
self.next = next
def getItem(self):
return self.item
def setItem(self, item):
self.item = item
def setNext(self,next):
self.next = n... |
98a9911caf1ee682ab7d28c78b4d585e56f45490 | NickC148/Python_Bootcamp | /Day 3/Excercises/All.py | 3,319 | 4.34375 | 4 | # Take this list a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and print out all
# the elements of the list that are less than 5. Instead of printing the elements
# one by one, make a new list that has all the elements less than 5 from this list
# in it and print out this new list.
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ... |
dac77f7afe30383314e0741f7198d4b5dee45bd4 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/222/users/4325/codes/1601_1800.py | 210 | 3.6875 | 4 | numberA = float(input("A:"))
numberB = float(input("B:"))
numberC = float(input("C:"))
quoc = ((numberA**2)+(numberB**2)+(numberC**2))
div = int(numberA+numberB+numberC)
result = quoc/div
print(round(result,7)) |
8d70897cd2006f0f09a3edb86964693e8055b601 | priyabrata88/EDURE | /edure_env/lib/python2.7/site-packages/timeutils/timespan.py | 4,778 | 4.15625 | 4 | """TimeSpan"""
# Author: Michal Ciesielczyk
# Licence: MIT
import datetime
class TimeSpan(datetime.timedelta):
"""Represents a time span.
All arguments are optional and default to 0. Arguments may be integers or
floats, and may be positive or negative.
As in the base :py:class:`python:da... |
753b67d1d6937ff472d432428fc20bc753dcc4e2 | yazid138/Python-learn | /kondisi.py | 607 | 4.03125 | 4 | #!/bin/python3
nilai = int(input("Berapa nilaimu: "))
if nilai > 11:
print("Masukan nilai Kembali: ")
elif nilai > 7:
print("Selamat Kamu Lulus!")
else:
print("Kamu harus ikut Ujian lagi!")
umur = input("berapa umur kamu? ")
aku = "bocah" if int(umur) < 10 else "dewasa"#ternary
print (aku)
... |
eb9e8ba69e636f569463122c0cc0fdf7f0dbabfb | ganiganesh92/learningAlgos | /bintree.py | 1,121 | 4.3125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Binary Search Tree
@author: sriram
"""
class Bintree():
def __init__(self):
self.root = None
def _insert(self, root, node):
if root is None:
return node
else:
if root["value"] > node["value"]:
r... |
d371c46017ca427215d4059e284c94a3951be3d7 | 390892467/pystudy | /map.py | 335 | 3.609375 | 4 | def left_fold(fn,*args):
# print(args)
# type(args)
it = iter(args)
# print(type(it))
ret = next(it)
for x in it:
ret = fn(ret,x)
return(ret)
def add(x,y):
return x + y
print(left_fold(add,1,2,3,4,5))
def inc(x):
return x + 1
print(filter(inc,[1,2,3,4]))
print(list(filter(inc,... |
a9908c272f228fef2c18adc4e88ae73090558449 | AsjadA/QuestionMarkCheck | /QuestionMarkCheck.py | 422 | 3.53125 | 4 | def QuestionMarks(s):
qnum=0
has10=False
dig=0
for ch in s:
if ch.isdigit():
if int(ch)+dig==10:
if qnum!=3:
return "false"
has10=True
dig=int(ch)
qnum=0
elif ch=="?":
... |
ea7d557a2768f620c58e3b1e429b036404a6e545 | srinathalla/python | /algo/arrays/reveseInteger.py | 385 | 3.5 | 4 | class Solution:
def reverse(self, x: int) -> int:
rev = 0
i = 0
symbol = 1 if x > 0 else -1
x = abs(x)
while x > 0:
reminder = x % 10
x = x // 10
rev = rev*10 + reminder
return rev*symbol if rev < 2**31 else 0
s = Solution()
pr... |
51d3c737d3671337f346f2bd689dde42a4e175d5 | wernerweinhartner/aulas_python | /lista02_02.py | 316 | 4.125 | 4 | #Faça um Programa que peça um valor e mostre na tela se o valor é positivo ou negativo.
a = float(input('Informe um numero qualquer: '))
if a > 0:
print('O numero %.2f eh positivo' % (a))
elif a < 0:
print('O numero %.2f eh negativo' % (a))
else:
print('O numero %.1f eh igual a zero' % (a))
|
7c79234053f888e0c82020917b69e0e713c7c976 | bluerain109/Python_Tutorials | /continue.py | 466 | 4.09375 | 4 | #Make a program to loop through and what jerseys are still allowed (for a sports team)
numbersTaken = [2, 5, 12, 13, 17,]
print("Here are the numbers that are still available:")
#to loop through the numbers and check which is available
for n in range(1, 20):
if n in numbersTaken:
continue
print(n)
#c... |
92d6d9848dc1fdc425bdd73a1bba6cb004e76413 | xnbya/pythonstuff | /python/maths chal/task5.py | 426 | 3.75 | 4 | maxfactor = int(input("Enter the largest factor"))
mby = 1
found = False
while not found:
#print(mby)
works = True
nototest = mby * maxfactor
# if(nototest % 1000 == 0):
# print(nototest)
x = maxfactor
while(x > 0):
if(nototest % x != 0):
works = False
... |
a1826553b4be2ce748d62cfaae839182f74b7128 | JnanaRM/Handling-program-flow-in-python-code-along | /code.py | 2,016 | 3.609375 | 4 | # --------------
import json
from collections import Counter
with open(path) as f:
data = json.load(f)
#print(data)
# Code starts here
# Can you find how many deliveries were faced by batsman `SC Ganguly`.
fir = data['innings'][0]['1st innings']['deliveries']
counterv = 0
for rec in fir:
for key,val in r... |
affeffdc7783ce58e930c3dfc8ba014f7253c92a | myendlessblue/likelion | /hw3.py | 612 | 3.515625 | 4 | class Character():
def __init__(self, name, age, gender) :
self.name = name
self.age = age
self.gender = gender
def intro(self):
print("%s은/는 %d세이고, %s입니다."
%(self.name, self.age , self.gender))
zzang9 = Character("짱구", 5, "남자")
ddora = Character("도라에몽", 14, "남자")
detec... |
0a31bcadc1c691527db24253b0b082e2ce9bf194 | dongsen2019/mysql | /mysql_4-基础操作命令.py | 2,503 | 3.5625 | 4 | # 3.mysql基础操作命令
"""
使用方法:
方式一:通过在命令行敲命令来操作(有助于命令的掌握)
方式二:通过图形界面工具,如Navicat等(在熟练掌握后再使用)
方式三:通过编程语言(python,php,java,go...)执行mysql命令
"""
# SQL(Structured Query Language) 结构化查询语言
"""
SQL语言分为4个部分:DDL(定义)、DML(操作)、DQL(查询)、DCL(控制)
"""
# SQL语句中的快捷键
"""
\G 格式化输出(文本式,竖立显示)
\s 查看服务器端信息
\c 结束命令输入操作
\q 退出当前sql命令行模式
\h 查看帮助
"""
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.