blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
921dbb6ba7e8bd79d80b20cc4cff54b75d512f39 | turner-white/python-code | /HW07p2.py | 1,943 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Oct 8 19:18:59 2020
@author: turne
"""
import numpy as np
from matplotlib import pyplot as plt
def function(n): #define a function that does the specified things so that I can easily call it 1000 times later
A = np.random.random((n,n)) #create an n by n matrix o... |
bab521dd966c38f062609ec868f8d8555d78cebe | eoinkfitz/python_Learning_Exercises | /Analysis of Olympic Medals.py | 7,138 | 3.65625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
olympics = pd.read_csv('C:\\Users\\LydonLaptop\\PycharmProjects\\pythonProject\\Olympic_Medals_Table.csv')
print(olympics.head(10))
#Class 1 Transforming DataFrames & class # 2 New columns
#ranking the medals table
olympics_ranked = ... |
9f99804e741bd224d8bb2e5b922ab8bfdae41675 | V2xray1024/pyHack | /车牌摇号.py | 842 | 3.828125 | 4 | '''
Description: 车牌摇号练习
Author: yrwang
Date: 2021-08-30 20:11:42
LastEditTime: 2021-09-02 21:37:46
LastEditors: yrwang
'''
import random
import string
count = 0
while count < 3: # 摇号次数限制为 3次
car_numbers = []
for i in range(20):
n1 = random.choice(string.ascii_uppercase) # 车牌号第一个字母
n2 = "".joi... |
413b165742eadb5cb089988983f4e3a7268e3952 | dfshan/ns2utils | /qlentrace.py | 765 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
''' The routines used for analyzing queue trace file
'''
def parse_line(line):
""" Parse a queue trace line into a dict
"""
result = {}
line = line.split()
if len(line) < 5 or line[0][0] == "#":
return result
result["time"] = float(line[0])... |
cae106f6b6ac161e0bdbb8b0cd300563adff4a30 | obayomi96/Python-beginner | /piglatin.py | 491 | 4.09375 | 4 | # A Pig Latin translator will move the first letter of a word to the last and append "ay" to the word
pyg = 'ay'
# input a word
original = raw_input('Enter a word:')
# if input is a string and is alphabet only
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
# formated,... |
db530e72f798f785e771a98ed784f9d4a41c195f | RaulMira0812/IA-final-project | /src/PathFinding.py | 3,589 | 4.15625 | 4 |
# Each node represents the board tile for the algorithm
class Node:
def __init__(self,pos=[0,0],element = None,parent=None,final_pos = [0,0]):
#The tile position in the board
self.pos = pos
#Parent node
self.parent = parent
#Future Knowledge
self.h = self.manhattanDistance(self.pos,final_pos)#The distanc... |
9250576bc79d67320ab7e302db82a405b42fe80c | rohinimandewalkar/Mandewalkar_Rohini_Spring2017 | /Assignment 3/Q1_PartOne.py | 2,378 | 3.890625 | 4 |
# coding: utf-8
# # Q1_PartOne: NYC VEHICLE COLLISION ANALYSIS
# # For each month in 2016, find out the percentage of collisions for each month in Manhattan out of that year's total accidents in New York City.
# # Display a few rows of the output use df.head ().
# # Generate a csv output with four columns (‘Month’,... |
2e4e0f85f5517566a01e0c40bd36e327eacfad8f | Kroki1412/2048Game | /2048Game.py | 15,803 | 3.71875 | 4 | import random, os
def win():
global Elements
for i in range(len(Elements)):
if Elements[i] == 2048:
print("You won the game!")
quit()
def loose():
global Elements
Loose = 0
for i in range(len(Elements)):
if Elements[i] == 0:
Loose = 0
... |
b41e06fe0d26da3797c613d2b4022baf8acbd7c9 | kalabanana/python3_notes | /handling.py | 1,569 | 3.8125 | 4 | # Import
#mymodule.py ->
def divide(dividend, divisor):
return dividend/divisor
print("module name: ", __name__)
#code.py
from mymodule import divide
import sys
print(sys.path) #first path always the path of the file u ran
# adding a libs folder
#path = module/libs/mylib.py
#sometimes it require the __init__.py ... |
bbfdc1426921624207c185a236063517ebf8d89a | oloj-hub/pythondz | /lab2/cher_3.py | 106 | 3.578125 | 4 | import turtle
turtle.color('pink')
for i in range(4):
turtle.forward(90)
turtle.left(90)
|
c7fd6e4f93448f7968292d7c41a2c8ccff7db848 | oloj-hub/pythondz | /lab7/ball_lib.py | 1,119 | 4.25 | 4 | class ball():
def move(self):
"""Переместить мяч по прошествии единицы времени.
Метод описывает перемещение мяча за один кадр перерисовки. То есть, обновляет значения
self.x и self.y с учетом скоростей self.vx и self.vy, силы гравитации, действующей на мяч,
и стен по краям окна (раз... |
143b5464645847ea5681315f1195b5488f6e63d8 | oloj-hub/pythondz | /lab2/cher_4.py | 105 | 3.546875 | 4 | import turtle
turtle.color('pink')
for i in range(1000):
turtle.forward(1)
turtle.left(360/1000)
|
cfe5eebd342441e4a779ea7b107b1333c88751e5 | yvaldesp83/ProyectoGit | /cursor.py | 446 | 3.921875 | 4 | import sqlite3
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
cur.execute("create table people (name, age)")
who = "Analia"
age = 12
# This is the qmark style:
cur.execute("insert into people values (?, ?)",
(who, age))
# And this is the named style:
cur.execute("select * from people where name=:who... |
6d052f1c0e5c03577d9f069926559472b7a69352 | Tower5954/Tip-Calculator | /main.py | 597 | 4.03125 | 4 | #If the bill was $150.00, split between 5 people, with 12% tip.
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60
#Tip: You might need to do some research in Google to figure out how to do this.
bill = float(input("How much is the bill?\n"))
people = int(input("How many... |
78c8981c11d2a2565266e60b6be96dffebd536b4 | RawalD/Python-Data-Structures | /String Reversal/string_reversal.py | 245 | 4.0625 | 4 | def reverse_string(string):
if len(string) == 0:
return "Empty String"
string = string.strip()
string = string.split(" ")
return_string = string[::-1]
return return_string
print(reverse_string(" space here"))
|
bff9d026aeca4d22de7b54d3848fca38471c017f | khaled-El-eraky/Bikeshare-data-system | /bikeshare_2.py | 5,917 | 3.96875 | 4 | import time
import pandas as pd
import numpy as np
"""Cities_File dictionary"""
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
"""Function of getting raw input Form User"""
def get_filters():
print('Hello! Let\'s explore ... |
2b06cd8a4da5e7e4eb5fbd39069f29545bdac000 | chuganghong/Python | /20140310/if.py | 603 | 4.03125 | 4 | #!/usr/bin/python
#Filename: if.py
number = 23
t = True
while t:
guess = int(raw_input('Enter an integer : '))
if guess == number:
t = False
print 'Congratulations, you guessed it.'
print "(but you do not win any prizes!)"
elif guess < number:
print 'No,it is a litter hight... |
a82bcd8088e8d291aa5c12595286700bd727adc3 | piotrtar/hangman_refactory | /hangman_ref3.py | 3,861 | 3.71875 | 4 | import random #import random module
import time #import time module
import datetime
from list1 import cac # import list of country and capitals
from hang import man #imports picture of hangman
def lose_word(lives, HANGMAN_picture, guess):
if len(guess) == 1:
lives -= 1
HANGMAN_picture += 1
el... |
6d63007d90bae6eb2137cced9d5ee0b47665d547 | rvcjavaboy/udemypythontest | /Methods_and_Functions/function_test/pro4.py | 229 | 4.15625 | 4 | def old_macdonald(name):
result=""
for c in range(0,len(name)-1):
if c==0 or c==3:
result+=name[c].upper()
else:
result+=name[c]
return result
print(old_macdonald('macdonald'))
|
6bea2e28b1f4c893a3ad2707bc44874f0493ba1a | SeanPlusPlus/ProjectEuler | /001-025/020_factorial_sum.py | 260 | 3.65625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
# https://projecteuler.net/problem=20
def main():
nums = str(math.factorial(100))
ans = 0
for char in nums:
ans += int(char)
print ans
if __name__ == '__main__':
main()
|
cd848b4d1a7c4db4b370817b60dd734d0af4a8ba | SeanPlusPlus/ProjectEuler | /051-100/057_sq_root_convergants.py | 876 | 3.8125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
from fractions import Fraction
# https://projecteuler.net/problem=57
def frac(i, f=(Fraction(1, 2))):
if i == 2:
return Fraction(1, (2 + f))
i -= 1
f = Fraction(1, (2 + f))
return frac(i, f)
def main():
i = 0
for n in range(... |
003769c212e58d53b276791eb115c81ef87ec496 | SeanPlusPlus/ProjectEuler | /026-050/047_distinct_prime_factors.py | 1,016 | 3.765625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import time, math
# https://projecteuler.net/problem=48
def primes(n):
primfac = []
d = 2
while d*d <= n:
while (n % d) == 0:
primfac.append(d)
n //= d
d += 1
if n > 1:
primfac.append(n)
return primfac
... |
a42f5cd43889ae1b58ec758227251767254d7518 | mihirverma7781/Python-Scripts | /chap3/for_loop_strings.py | 229 | 3.8125 | 4 | # # name ='mihir'
# # i=0
# # for i in range(len(name)):
# # print(name[i])
# # i=i+1
# name ='mihir'
# for i in name:
# print(i)
num = input('enter a number : ')
sum = 0
for i in num:
sum=sum+int(i)
print(sum)
|
193984f2b1a75e3fe73674077515af6471606304 | mihirverma7781/Python-Scripts | /chap4/exercise_one.py | 212 | 4.03125 | 4 | def digit(a,b):
if a>b:
print(f'{num1} is greater than {num2}')
else:
print(f'{num2} is greater than {num1}')
num1= input('enter num 1 : ')
num2= input('enter num 2 : ')
digit(num1,num2)
|
8c87417982da9200fd69422c770f3f36c1aafbd7 | mihirverma7781/Python-Scripts | /chap17/ex1.py | 294 | 3.921875 | 4 | def divide(a,b):
try:
c = a/b
except ZeroDivisionError:
print('enter a positive integer')
except TypeError:
print('enter valid type')
else:
print(f"division value is --> {c}")
finally:
print('done one more attempt??')
divide(1,"m") |
348cec75c40413c5b4fde951d0451be5588ae875 | mihirverma7781/Python-Scripts | /chap3/exercise4.py | 121 | 3.625 | 4 | no = input('enter a number : ')
length = len(no)
sum = 0
i=0
while i<length:
sum += int(no[i])
i = i+1
print(sum) |
c052133b3e1f048e9ccc60b431e599ad15ae80d1 | mihirverma7781/Python-Scripts | /chap4/exercise_two.py | 271 | 4.21875 | 4 | def greater(a,b,c):
if a>b and a>c:
return a
else:
if b>a and b>c:
return b
else:
return c
num1 = input('enter num 1 : ')
num2 = input('enter num 2 : ')
num3 = input('enter num 3 : ')
print(greater(num1,num2,num3))
|
abc4fd49fef5f21934de7208fcad6d11d9ef6022 | mihirverma7781/Python-Scripts | /chap4/func_practice1.py | 392 | 3.875 | 4 | # # practice session
# def name(n):
# return n[-1]
# print(name('mihir'))
# def odd_even(num):
# if num%2 == 0:
# print('number is even ')
# else:
# print('number is odd ')
# def odd_even(num):
# if num%2 == 0:
# return'number is even '
# return'number is odd '
# print(od... |
26138e47ab0966e33f82e3bf410e494a0ff6eeb6 | mihirverma7781/Python-Scripts | /chap16/more_about_inheritance.py | 1,630 | 3.9375 | 4 | class Phone:
def __init__(self,brand , model , price):
self.brand = brand
self.model = model
self._price = max(price,0)
def make_a_call(self,phone_number):
print(f" calling {phone_number}....")
def full_name(self):
return f"{self.brand} {self.model} {self._pric... |
16b4c7af34bc90edea6e1ba7a58a7f6e43bfe7e4 | mihirverma7781/Python-Scripts | /chap10/set_comp.py | 163 | 3.703125 | 4 | # set comprehension not used
s = {num**2 for num in range(1,11)}
print(s)
name =['mihir','ishu','heer','irtika','radha']
names = {m[0] for m in name}
print(names) |
298e45648b043feee9cbc6a367652e5d1464645e | mihirverma7781/Python-Scripts | /chap14/practice.py | 298 | 3.515625 | 4 | # numbers = [1,2,3,4,5,6]
# def func1(a):
# return a**2
# num_square = list(map(func1,numbers))
# print(num_square)
# def func2(a):
# return a%2==0
# num_map = list(map(func2,numbers))
# num_filter = list(filter(func2,numbers))
# print(num_map)
# print(num_filter)
|
d704337728a29e47b14ba1e78643b1bef7528919 | mihirverma7781/Python-Scripts | /chap16/property_setter_decorator.py | 1,033 | 4.125 | 4 |
class Phone:
def __init__(self,brand , model , price):
self.brand = brand
self.model = model
self._price = price
# if price > 0:
# self._price = price
# else:
# self._price = 0
# self.complete_info = f"{self.brand... |
732ede5d8adbd00fbd3bc5cbd845549386cbe91b | mihirverma7781/Python-Scripts | /chap3/exercise5.py | 211 | 3.6875 | 4 | name = input('enter your full name : ')
i= 0
temp =""
while i< len(name):
if name[i] not in temp:
temp = temp+name[i]
print(f"number of letter : {name[i]} = {name.count(name[i])}")
i= i+1 |
daf762b962d14c86203cfccdd4a369d0fa895cea | mihirverma7781/Python-Scripts | /chap16/class_mtd.py | 629 | 3.890625 | 4 | class Person:
count_instance = 0
def __init__(self, f_name,l_name, age):
self.f_name = f_name
self.l_name = l_name
self.age = age
Person.count_instance+=1
# class method declaration
@classmethod
def count_instances(cls):
return f"you have created {cls.count_i... |
817603a6451e6ac6cffd5d32b47cfb2c13f3118d | mihirverma7781/Python-Scripts | /chap3/nad_or.py | 220 | 3.984375 | 4 | name = 'abc'
age = 19
if name =='abc' and age == 19:
print ('true')
else:
print('false')
# or statement
name = 'abc'
page = 19
if name =='wsbc' or page == 99:
print ('true')
else:
print('false') |
aefc3d951fb2ce727a819760559431b72d9291f3 | mihirverma7781/Python-Scripts | /chap2/string_methods.py | 235 | 3.515625 | 4 | # string methods part one
name = 'MihIr VerMa'
# len() function
print(len(name))
# lower() function
print(name.lower())
# upper() method
print(name.upper())
# title() method
print(name.title())
# count() method
print(name.count("i")) |
6e579c3d08e102e358e7d2bf1f46898db7671f26 | JayeshNaidu/Caesar-cipher-Encryptor-and-Decryptor | /EncDec/endc.py | 636 | 3.6875 | 4 | def enc():
mess=input('Enter text to be encrypted:\n')
code = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'
key=7
en = ''
res=''
for i in mess:
pos = code.find(i)
newpos = (pos+key)%52
res += code[newpos]
print('\nEncrypted code:',res)
def dec():
mess=input('Enter text to be decry... |
0824b7cbaab1651cca9e7653e02eba4a35eb9554 | ethanholter/Advent-of-Code-2020 | /Day 2/d2p2.py | 667 | 3.640625 | 4 | #Day 2 Part 2
# 1-3 a: abcde is valid: position 1 contains a and position 3 does not.
# 1-3 b: cdefg is invalid: neither position 1 nor position 3 contains b.
# 2-9 c: ccccccccc is invalid: both position 2 and position 9 contain c.
import re
input = open(r"Day 2\input.txt", "r").read().split("\n")
def solve(input):... |
4877f712766a56a45fa91fa613a8188cc4518642 | ethanholter/Advent-of-Code-2020 | /Day 2/d2p1.py | 1,191 | 4.09375 | 4 | #Day 1 Part 1
# Each line gives the password policy and then the password.
# The password policy indicates the lowest and highest number
# of times a given letter must appear for the password to be
# valid. For example, 1-3 a means that the password must
# contain a at least 1 time and at most 3 times.
# In the a... |
8508a1c5d5c6a924d2a65464d5f519bfc4eb71c3 | reddyonlinenow/codebreakers-solutions | /leetcode/98/98.py | 868 | 3.734375 | 4 | class Solution:
def isValidBST(self, root: TreeNode) -> bool:
# helper function to check if subtree values are within the restraints of a bst
return self._areNodesWithinBounds(root, -math.inf, math.inf)
def _areNodesWithinBounds(self, node, lowerBound, upperBound):
# base case
... |
9af7698747570cbdbd89fcb05518af68c7a59b60 | reddyonlinenow/codebreakers-solutions | /leetcode/680/680.py | 837 | 3.890625 | 4 | class Solution:
def validPalindrome(self, s: str) -> bool:
return self._isPalindrome(s, 0, len(s)-1, False)
# moves outwards to inwards to check if the string is a valid palindrome
def _isPalindrome(self, s, leftIndex, rightIndex, hasDeleted):
while leftIndex < rightIndex:
#... |
b6c887b3fa9c65d2ca8cc0c9c9205d4d24a9bfca | reddyonlinenow/codebreakers-solutions | /leetcode/735/735.py | 1,757 | 3.96875 | 4 | class Solution:
# Time complexity: `O(n)` since we run through the input array once.
# Space Complexity: `O(n)` since our solution can be the size of the input should nothing collide.
def asteroidCollision(self, asteroids: List[int]) -> List[int]:
asteroidsLeft = []
for asteroid in asteroids... |
8d90a7edcc4d49f85ea8d35dda6d58dcb7654bd0 | PinCatS/Udacity-Algos-and-DS-Project-2 | /min_max.py | 1,298 | 4.125 | 4 | def get_min_max(ints):
"""
Return a tuple(min, max) out of list of unsorted integers.
Args:
ints(list): list of integers containing one or more integers
"""
if ints is None:
return None
if len(ints) == 1:
return (ints[0], ints[0])
minValue = None
maxValue = ... |
7ecd5747d05929742e6054e42f11984cce8b009e | gemechis-elias/Simple-Calculator-Using-Python-UI-Tkinter | /tk_simple_calculator.py | 681 | 4.09375 | 4 | #github.com/gemechis-elias/simple-python-calculator
from tkinter import * #import all from tkinter module
from math import *
def evaluate(event):
res.configure(text = "መልስ = " + str(eval(entry.get())))
w = Tk()
#Display የምሆኑ ፁሁፎች ናቸው
Label(w, text=" Python tkinter Calculator").pack()
Label(w, text="").pack()
L... |
05c827aebd1352fc4c0a10e65fcb6cfaa3976a0f | nainaKaas/desktop | /python files/check.py | 302 | 3.828125 | 4 | from tkinter import *
root = Tk()
def new_winF(): # new window definition
newwin = Toplevel(root)
display = Label(newwin, text="Humm, see a new window !")
display.pack()
button1 =Button(root, text ="open new window", command =new_winF) #command linked
button1.pack()
root.mainloop() |
36913bf1ffd95dbab6a23a1b4930d3cfd08face9 | kRituraj/python-programming | /how_many_are_odd_and_how_many_are_even.py | 272 | 3.8125 | 4 | from array import *
MyArray = array("i",[1,3,4,6,89,6,4,2,5,55,67,32,2,11,76,37,81,46,7])
i = 0
even = 0
odd = 0
while(i < len(MyArray)):
if (MyArray[i] %2 == 0):
even = even + 1
else:
odd = odd + 1
i = i + 1
print(even)
print(odd)
|
78628a4bba3b8d9d9d70e8a6c84961b5f2e7ea02 | kRituraj/python-programming | /array-rotation-by-any-element.py | 386 | 4 | 4 | from array import *
arr = array("i",[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])
n = int(input("enter the element from where you want to rotate the array : "))
i = 0
while(i < n):
temp = arr[0]
j = 0
while(j < len(arr)-1):
arr[j] = arr[j+1]
arr[j+1] = temp
j = j + 1
i = i + 1
i =... |
6b626b3d1c4197a1e7788530b69133e0d0a0f16c | kRituraj/python-programming | /find_the_number_ofpositive_and_negative_numbers_in_an_array.py | 353 | 4.0625 | 4 | from array import *
MyArray = array("i",[1,2,-3,4,5,6,7,8,9,-1,33,-65,3])
i = 0
positive = 0
negative = 0
while(i < len(MyArray)):
if (MyArray[i] >= 0):
positive = positive + 1
else:
negative = negative + 1
i = i + 1
print("total positive elements are : "+str(positive))
print("total negativ... |
ce8084de7416c1a2056fde06da74e7fa401c8b35 | rubayetalamnse/Random-Projects-With-Python | /5.guess a number-easily.py | 425 | 4 | 4 | import random
num = random.randrange(40,70)
your_gusess = int(input("Guess the number! It's between 40 to 70: "))
while your_gusess!= num:
if your_gusess<num:
print("try higher!")
your_gusess = int(input("\nGuess the number! It's between 40 to 70: "))
else:
print("try lower!")
... |
8d3acf9ce62a4eba881baeb3c2fcdf17434ffc2e | yShimoka/Python-Bataille-Navale | /engine/input/InputListener.py | 386 | 3.515625 | 4 | # Copyright © 2019 CAILLAUD Jean-Baptiste.
# Import the abstract objects.
from abc import ABC, abstractmethod
class InputListener(ABC):
"""
Object that is used to listen to all the events of the application.
"""
@abstractmethod
def handle_input(self, event):
"""
Handles the spec... |
463bc4c835aa073f0c6b043e129332470d61ad0d | yShimoka/Python-Bataille-Navale | /battleships/objects/ShipBoard.py | 2,773 | 3.890625 | 4 | # Copyright © 2019 CAILLAUD Jean-Baptiste.
# Import the base board class.
from battleships.objects.Board import Board
# Import the engine.
import engine
class ShipBoard(Board):
"""
Board object that renders all the ships from the player.
"""
def __init__(self, parent):
"""
Class co... |
bf99aba029d94bd75c8dda7bf301e7e010b938d0 | yShimoka/Python-Bataille-Navale | /engine/logic/LevelManager.py | 971 | 3.703125 | 4 | # Copyright © 2019 CAILLAUD Jean-Baptiste.
# Import the abstract classes.
from abc import ABC, abstractmethod
class LevelManager(ABC):
"""
Base manager class for all game levels.
This class allows the simple manipulation of level objects.
Attributes:
config The configuration object of ... |
d8c4c542f70987915f9e1c9341de0a3730ca03ce | yShimoka/Python-Bataille-Navale | /battleships/objects/GameStateTexts.py | 3,170 | 3.53125 | 4 | # Copyright © 2019 CAILLAUD Jean-Baptiste.
# Import the engine.
import engine
class GameStateTexts(engine.GameObject):
"""
Simple game object that groups all game state texts together.
"""
# Lists all the showable texts.
TEXT_GAME_STARTING = 0x00
TEXT_GAME_NEW_TURN = 0x10
TEXT_GAME_REQ_... |
302598df44e0d3bd575d41e33a4917e662aea9e7 | Terehov2088/ClassWork | /lesson_functions.py | 1,414 | 3.765625 | 4 | #def <func_name>(<param_list>):
# <func_body_line1>
# <func_body_line2>
# <func_body_lineN>
import math
def print_hello():
print('Hello')
print_hello()
print_hello()
print_hello()
print_hello()
def print_hello_name(name):
print('Hello, %s!' % name)
print_hello_name('Vladimir')
def rectangle_square... |
e8ba8745a439e443f5417c2357013bc088dab0a6 | MatheusKraisfeld/7-segment-clock | /main.py | 4,354 | 3.546875 | 4 | # -*- coding: utf-8 -*-
'''
Autor: Matheus Kraisfeld Benevides de Lima
Projeto: Prova prática do processo seletivo do Studio Sol
Relógio de tamanho variável com LED de 7 segmentos
'''
import time
import os
import platform
from threading import Thread
from time import strftime
from LED_7_segmentos... |
65056b69a354a638a28376869b2558a7a9942126 | iamAjaykumar/Fix_password | /password_fixer.py | 6,257 | 4.03125 | 4 | user_name=input("Enter your Username:") #ask the user for username
password=input("Enter a password:") #ask the user for password
#string variables to check
specailChars="'[_#$%^&*()<>?/\|}{~:]'" #special characters defined
smallAlpha='abcdefghijklmnopqrstuvwxyz' #small alphabets
bigAlpha='ABCDEFGHIJKLMNOPQURSTUVWXYZ'... |
ba9b753f8a8e4253e0bfb9e5572475af5447add8 | bryan32796/-CS1411 | /cs1411/lab09/lab09.py | 2,313 | 3.734375 | 4 | import random
import os
def createNameDict(questionList):
playerNames = open("name.txt", 'r')
nameDict = {}
questionNumbers = {}
for name in playerNames:
name = name.strip()
#Problem with ammount of random numbers
#Sometiems 4 or 5
nameDict[name] = { random.randint(0,le... |
bbd3b4b664e10271f2652d110e7ca4c02522de98 | Anusha-Kanagala/Algorithms | /Python programs/PermutationArray.py | 631 | 3.609375 | 4 | class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
res = []
def permutSol(nums, temp):
if not nums:
res.append(temp[:])
return
for i in range(len(nums)):
... |
159c085d93e73300b3cfdcc326ee536a9be7987e | Anusha-Kanagala/Algorithms | /Algorithm for shortest path_Astar/Data.py | 2,527 | 3.6875 | 4 | # Reads france longitude file and stores node longitude values in a dictionary
# Path of the file
# Returns: Returns dictionary with path longitude values of each node
def read_france_map_longitude(file_path):
france_long = {}
with open(file_path, 'r') as f:
for i in range(18):
f.readli... |
c1d957f7ca914ba5113124684e8b0c21663df2bd | sakshigupta1997/code-100 | /code/python/day-1/pattern15.py | 326 | 4.1875 | 4 | '''write a program to print
enter the number4
*
**
***
****'''
n=int(input("enter the number"))
p=n
k=0
for row in range(n):
for space in range(p,1,-1):
print(" ",end='')
#for star in range(row):
for star in range(row+1):
print("*",end='')
print()
p=p-1
... |
8023df918f31341f470cbe7033cf85d60c0e4ffc | sakshigupta1997/code-100 | /code/python/day-1/pattern18.py | 594 | 3.8125 | 4 | '''program to pattern of diamond but without taking an input from user
using five loop
*
***
*****
*******
*********
***********
***********
*********
*******
*****
***
*
'''
p=6
m=5
y=0
for i in range(0,12):
if(i<=5):
for j in range(p,1,-1):
p... |
e5d19f13cc64e1184c926dd19ae7ab33becd17f8 | sakshigupta1997/code-100 | /code/python/day-1/pattern6.py | 289 | 3.625 | 4 | ''' write a program to print
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
YZ'''
count=0
for j in range(0,26):
if(count!=3):
print(chr(65+j),end='')
count=count+1
else:
print(chr(65+j),end='')
print()
count=0
|
76f927a06fcfb4a60a3ad3a3c18a63c2856e2a35 | diljara/mipt-py | /2021-09-20/4.py | 804 | 3.71875 | 4 | from random import *
import turtle
number_of_turtles = 5
steps_of_time_number = 100
# def move_turtle(unit):
# unit.penup
# unit.forward(10)
def set_pool(pool):
for unit in pool:
unit.penup()
unit.speed(speed='fastest')
unit.shape('circle')
unit.goto(randint(-100, 100), randin... |
a3fdafeff942ac3a0ba3e6c863eca8747d2e6d9b | diljara/mipt-py | /2021-09-13/10.py | 412 | 3.78125 | 4 | #десятб (цветочек)
import turtle
import numpy as np
turtle.shape('turtle')
turtle.speed('fastest')
def mnogoug(n, l, alpha):
angle = 180 - 180 * (n - 2) / n
turtle.setheading(alpha)
for i in range(1, n + 1, 1):
turtle.forward(l)
turtle.left(angle)
for i in range(1, 6):
mnogoug(50, 1... |
fb1fefc15783cdde5c3a596b8a6a86f7b730eef7 | mighty-raj/shortestpath | /Py_Implementation/DepthFirstSearch.py | 2,420 | 4.09375 | 4 | # Objects of this class would be used to define coordinates in the matrix
class Point():
def __init__(self, x, y):
self.x = x
self.y = y
# Objects of this class would be used to define every entry in the matrix including its coordinates and distance from source
class Node():
def __init__(self, ... |
609e07636cfbe915454775d871869090617773af | elliele/arithmetic-formatter | /arithmetic_arranger.py | 1,668 | 3.640625 | 4 | # Created by Ellie Le at 3/14/2021
def arithmetic_arranger(problems,solve=''):
total = 0
top_line =''
bottom_line = ''
sum_line = ''
dash = ''
if len(problems) > 5:
return 'Error: Too many problems.'
for problem in problems:
x = problem.split(' ')
top, op... |
9c968c908a6062c9cd737e25b291edc6e56dac25 | dianrob/thinkpython | /thinkpy64.py | 298 | 3.75 | 4 | def ispower(a, b):
if a == b:
return True
elif a % b == 0:
return ispower(a/b, b)
else:
return False
print(ispower(2, 10))
def gcd(a, b):
r = a & b
if gcd(a, 0) = a:
return a
elif gcd(b, r):
else:
return False
|
5748b0a468637f1c5ca9ce66fb1df7cd73d37194 | dianrob/thinkpython | /palindromes.py | 413 | 3.84375 | 4 | def first(word):
return word[0]
def last(word):
return word[-1]
def middle(word):
return word[1: -1]
def is_palindrome(x):
if len(x) > 2:
pal = last(x)
i_n = middle(x)
drom = first(x)
print(pal + i_n + drom)
is_palindrome('otto')
def palindrome_short(x):
if ... |
40966441222dbcadaced0297b343be2e3f9d6146 | danielljc/assignment | /graduate1/algorithm/assignment1/problem4_hanoi_tower.py | 936 | 3.8125 | 4 | # 题目:汉诺塔
#
# Description
# 汉诺塔问题中限制不能将一层塔直接从最左侧移动到最右侧,也不能直接从最右侧移动到最左侧,而是必须经过中间。求当有N层塔的时候移动步数。
#
# Input
# 输入的第一行为N。
#
# Output
# 移动步数。
count = 0
# 将x的第一个元素移到y
def move(x, y):
global count
y.append(x.pop())
count += 1
# 递归只要考虑初始情况与递归情况即可,拆分为1与n-1来看
def hanoi(n, a, b, c):
global count
# 初始条件
... |
17df310e9f698c865fc3fdc4057e67cd696c82a8 | OliverStrubin/ocr-dicegame | /start.py | 5,761 | 3.71875 | 4 | #Imports needed
import random
import time
global player1
global player2
P1Score = 0
P2Score = 0
#File Login System
def loginPlayerOne():
global player1
print("P1 please enter your account information.")
time.sleep(1)
UserName = str(input("Username: "))
Password = str(input("Passwor... |
9417834e61da6e0140d57365cfe02ae4e5275a49 | shifanmao/digital-wallet | /insight_testsuite/temp/src/graph.py | 1,618 | 4 | 4 | # Implementation of a graph class using dictionary
## Author: Shifan Mao
## Date: 11-06-16
class Graph:
""" undirected graph data structure """
def __init__(self, graph=None):
if graph == None:
graph = {}
self.__graph = graph
def nodes(self):
""" return nodes of graph
... |
0f2b462a9949622c7bb734654339148a094146db | CursosProteco/Python | /Intermedio/Viernes/Tkinter/gui3.py | 1,108 | 3.6875 | 4 | # BUTTON
from tkinter import *
from webbrowser import open_new #Módulo Para abrir páginas web
# Función que se va a ejecutar cuando se
# presione el botón 1
def fun1(): # LAS FUNCIONES NO RECIBEN PARÁMETROS
print('Hola Mundo!!')
# Función que se va a ejecutar cuando se
# presione el botón 2
def f... |
a657c3f94cd740a58d9d90a59f20613512a8186a | CursosProteco/Python | /Intermedio/Martes/Program_Concurrente/hilos2.py | 762 | 3.609375 | 4 | from funciones import contar, factorial, agregarLista
from threading import Thread
from time import time
###Definimos los hilos, estos ejecutarán las funciones
hilo1 = Thread(target=contar)
hilo2 = Thread(target=factorial)
hilo3 = Thread(target=agregarLista)
###Calcularemos el tiempo
inicio = time()
hilo1.... |
c11d6e53283962bb9aa11d89ac7579ea5e9af0e1 | CursosProteco/Python | /Básico/Jueves/poo2.py | 381 | 3.578125 | 4 | # Por convención, las clases empiezan con letra mayúscula
class Coche:
def arrancar(self):
print('RUUUMMMMM!!')
coche1 = Coche()
coche2 = Coche()
coche1.arrancar()
print(coche1 == coche2)
# Son de la misma clase pero son objetos diferentes
coche2.color = 'rojo'
# Podemos crear y asig... |
d496de0cf4599a90e399200469798f4af917e6b4 | CursosProteco/Python | /Intermedio/Viernes/Tkinter/gui1.py | 772 | 3.578125 | 4 | # ROOT Y LABEL
from tkinter import *
# Generalmente tkinter se importa de esta forma
# Para tener acceso a sus servicios
root = Tk() # Clase Tk
# Se genera una ventana raiz # root window
# Nos permite tratar a los widgets en una ventana como objetos
# Lo que nos sale es la instancia de la clase Tk
widget ... |
7d8dea7449836e49da538225fb6be832ea0d2801 | aravindanath/MarvelAutomation | /Day4/functions.py | 193 | 3.78125 | 4 |
def addNumber(a,b):
sumof= a +b
print("Sum of two numbers is :",sumof)
def mulNum(a,c):
mul = a*c
return mul
addNumber(20,30)
addNumber(44,21)
val =mulNum(22,2)
print(v+3) |
b1ba8aaf6029c39ae49bdc939b79e95e6f0870ea | aravindanath/MarvelAutomation | /day3/DictExample.py | 223 | 4 | 4 |
# KEY : VALUE
cars={"colour":"red","Doors":"4"}
print(cars.keys())
print(cars.values())
print(cars)
for l in cars.items():
print(l)
cars["wheels"]="4"
print(cars)
cars.pop("Doors")
print("After pop",cars)
|
c3d23ee2a61c1d187281e35b413293a89183635c | tchapeaux/project-euler | /018.py | 1,463 | 3.578125 | 4 | # triangles are represented as matrices
# A cell has coordinates (row, column)
# each cell (i, j) has two 'adjacent' cells at (i + 1, j) and (i + 1, j + 1)
# We suppose that cell values are positive
FILEPATH = "018_bigTriangle.txt"
def triangleFromString(string):
tri = []
string.strip()
rows = string.sp... |
b7ecd7359be48d08a606c6296d686510266b8729 | tchapeaux/project-euler | /001.py | 210 | 3.84375 | 4 | currentsum = 0
mul3 = 0
while (mul3 < 1000):
currentsum += mul3
mul3 += 3
mul5 = 0
while (mul5 < 1000):
currentsum += mul5
mul5 += 5
if (mul5 % 3 == 0):
mul5 += 5
print(currentsum)
|
860ddaee2fc422c689647f469a841f32c1d03dd5 | Iansdfg/9chap | /9 DP/109 · Triangle.py | 1,155 | 3.53125 | 4 | class Solution:
"""
@param triangle: a list of lists of integers
@return: An integer, minimum path sum
"""
def minimum_total(self, triangle):
# write your code here
n = len(triangle)
dp = [[0] * (i + 1) for i in range(n) ]
dp[0][0] = triangle[0][0]
for i in r... |
7a8e3131fe2a49b1b5e1269068e8917238cb7b64 | Iansdfg/9chap | /SystemDesign/Consistent Hashing/519 · Consistent Hashing.py | 958 | 3.765625 | 4 | class Solution:
"""
@param n: a positive integer
@return: n x 3 matrix
we will sort your return value in output
"""
def consistent_hashing(self, n):
# write your code here
results = [[0,359,1]]
#result[0], result[1] is #start, #end
#result[2] is # of mach... |
5fc40047f76a554eba28c36cbd0230b11421fba6 | Iansdfg/9chap | /2BFS/178. Graph Valid Tree.py | 924 | 3.75 | 4 | from collections import deque
class Solution:
"""
@param n: An integer
@param edges: a list of undirected edges
@return: true if it's a valid tree, or false
"""
def valid_tree(self, n, edges):
# write your code here
if len(edges) != n-1:
return False
node_to... |
9020d5fb5e7d79baf52444c57e41ac936249c68f | Iansdfg/9chap | /5Two pointers/6 · Merge Two Sorted Arrays.py | 699 | 3.9375 | 4 | class Solution:
"""
@param a: sorted integer array A
@param b: sorted integer array B
@return: A new sorted integer array
"""
def merge_sorted_array(self, a, b):
# write your code here
if not a or not b:
return a or b
upper, lower = 0, 0
res = []
... |
803716ba43b82a407aa756730b6d92fd054071d9 | Iansdfg/9chap | /3Binary_Search/414. Divide Two Integers.py | 878 | 3.90625 | 4 | class Solution:
"""
@param dividend: the dividend
@param divisor: the divisor
@return: the result
"""
def divide(self, dividend, divisor):
# write your code here
if dividend == 0 or divisor == 0:
return 0
if divisor == 1:
return dividend
... |
f00dfc08099c42cd6a532ae3b568155a594c0b3d | Iansdfg/9chap | /6DFS/34. N-Queens II.py | 993 | 3.546875 | 4 | class Solution:
"""
@param n: The number of queens.
@return: The total number of distinct solutions.
"""
def totalNQueens(self, n):
# write your code here
results =[]
visited = [0]*n
self.dfs(n, visited, [], results)
return len(results)
def dfs(se... |
868d69a014c48e6ef29854d7f326bd0a21f645a3 | Iansdfg/9chap | /9 DP/115 · Unique Paths II.py | 945 | 3.65625 | 4 | class Solution:
"""
@param obstacle_grid: A list of lists of integers
@return: An integer
"""
def unique_paths_with_obstacles(self, obstacle_grid):
# write your code here
rows = len(obstacle_grid)
cols = len(obstacle_grid[0])
dp = [[0 for _ in range(cols)] for _ in r... |
5113d7840adbe4339140003b3ca705ebbc7592d2 | Iansdfg/9chap | /4Binary Tree - Divide Conquer & Traverse/480. Binary Tree Paths.py | 1,756 | 3.796875 | 4 | from typing import (
List,
)
from lintcode import (
TreeNode,
)
##########Bottom Up##########
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: the root of the binary tree
@... |
0527a273d2b3dd538da3443c55bde5d44dfb395a | Iansdfg/9chap | /6DFS/152. Combinations.py | 733 | 3.515625 | 4 | class Solution:
"""
@param n: Given the range of numbers
@param k: Given the numbers of combinations
@return: All the combinations of k numbers out of 1..n
"""
def combine(self, n, k):
# write your code here
combinations = []
self.dfs(n, k, 0, [], combinations)
re... |
bee77302a5fae74003aeae091962bb470ba33a26 | Iansdfg/9chap | /6DFS/15. Permutations.py | 1,860 | 3.9375 | 4 | class Solution:
"""
@param nums: A list of integers.
@return: A list of permutations.
we will sort your return value in output
"""
def permute(self, nums):
# write your code here
permutions = []
visited = set()
self.dfs(nums, visited, [], permutions)
... |
bbd70de5846927601f5ff8d77da7e83fdff40e48 | Iansdfg/9chap | /5Two pointers/587. Two Sum - Unique pairs.py | 1,729 | 3.859375 | 4 | class Solution:
"""
@param nums: an array of integer
@param target: An integer
@return: An integer
"""
def two_sum6(self, nums, target):
# write your code here
nums.sort()
left, right = 0, len(nums) - 1
res = 0
while left < right:
twoSum = nu... |
d980bedadbcfc8b0e640c892b7b6cb038193a314 | Iansdfg/9chap | /3Binary_Search/254. Drop Eggs.py | 592 | 3.5625 | 4 | class Solution:
"""
@param n: An integer
@return: An integer
"""
def dropEggs(self, n):
# write your code here
# in short find smallest k that k*(k+1)>=n
end = 1
while end * (end + 1) / 2 < n:
end *= 2
start = 0
while start + 1 < ... |
e02ba552e441eb412b25f7f9d15299288e34ad37 | Iansdfg/9chap | /4Binary Tree - Divide Conquer & Traverse/85. Insert Node in a Binary Search Tree.py | 857 | 4.125 | 4 | """
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param: root: The root of the binary search tree.
@param: node: insert this node into the binary search tree
@return: The root of the new bin... |
227c52bdc9dfa25444372e4b0be8001e00a4a822 | Iansdfg/9chap | /2BFS/787. The Maze.py | 1,481 | 3.96875 | 4 | from collections import deque
class Solution:
"""
@param maze: the maze
@param start: the start
@param destination: the destination
@return: whether the ball could stop at the destination
"""
derictions = [(1, 0), (-1, 0), (0, 1), (0, -1)]
def hasPath(self, maze, start, destination... |
72bd9a5576b2f92021a78408c75574a11cc62ce2 | Iansdfg/9chap | /7HashHeap/606. Kth Largest Element II.py | 462 | 3.65625 | 4 | from heapq import heapify, heappop, heappush
class Solution:
"""
@param nums: an integer unsorted array
@param k: an integer from 1 to n
@return: the kth largest element
"""
def kthLargestElement2(self, nums, k):
# write your code here
heap = []
for num in nums:
... |
721a930b5260e0c0a0d08b70047510206572c529 | Iansdfg/9chap | /4Binary Tree - Divide Conquer & Traverse/93. Balanced Binary Tree.py | 832 | 3.84375 | 4 | from lintcode import (
TreeNode,
)
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: The root of binary tree.
@return: True if this Binary tree is Balanced, or false.
"""
... |
351d95f2e5e9caf386ecce0785e0509bd463ab7e | Iansdfg/9chap | /3Binary_Search/460. Find K Closest Elements.py | 2,591 | 3.703125 | 4 | class Solution:
"""
@param a: an integer array
@param target: An integer
@param k: An integer
@return: an integer array
"""
def k_closest_numbers(self, a, target, k):
# write your code here
upper = self.find_upper(a, target)
lower = upper - 1
res = []
... |
651bd7bb93a0806c246352ff841c5ee799263b87 | Iansdfg/9chap | /3Binary_Search/428. Pow(x, n).py | 431 | 3.59375 | 4 | class Solution:
"""
@param x {float}: the base number
@param n {int}: the power number
@return {float}: the result
"""
def myPow(self, x, n):
# write your code here
if n < 0:
n = -n
x = 1/x
base = x
ans = 1
while n:
if ... |
08b814d21d66522f0521943f3c3e3183405bb629 | Iansdfg/9chap | /6DFS/18. Subsets II.py | 1,433 | 3.765625 | 4 | class Solution:
"""
@param nums: A set of numbers.
@return: A list of lists. All valid subsets.
we will sort your return value in output
"""
def subsets_with_dup(self, nums):
# write your code here
nums.sort()
subsets = []
self.dfs(nums, 0, [], subsets)
... |
df387310a2ebc03672845567c4dd50aff6a65b9e | Iansdfg/9chap | /5Two pointers/5. Kth Largest Element.py | 1,395 | 3.703125 | 4 | class Solution:
"""
@param k: An integer
@param nums: An array
@return: the Kth largest element
"""
def kth_largest_element(self, k, nums):
# write your code here
# right bondary is len(nums) - 1 b/c we need to use num[right] to partition
# the Kth largest the index is k ... |
38f3d819b4f9e56f6213405014f1b3c243366dca | zc256/PythonCalculator | /Calculator/calculator.py | 1,190 | 3.53125 | 4 | from Calculator.addition import add
from Calculator.subtraction import sub
from Calculator.multiplication import mult
from Calculator.division import divide
from Calculator.squared import squared
from Calculator.squareRoot import squareRoot
from Calculator.addSub import addSub
from Calculator.sqrtSquared import sqrtSqu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.