blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
6c82f9e0a254dc7458acce603280f7fd9dce8e46 | MingyuZuo/APythonTour | /Examples/IO/028.py | 998 | 3.59375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
'''
序列化
'''
'''
序列化成 bytes
'''
import pickle, os
# 序列化
d = dict(name='Bob', age=20, score=88)
print(pickle.dumps(d))
# 写入文件
filepath = 'dump.txt'
f = open(filepath, 'wb')
pickle.dump(d, f)
f.close()
# 读取文件,反序列化
readfile = open(filepath, 'rb')
d = pickle.load(readfile)
pri... |
bcc754fa09be93d86f515c00a6829a6fcaef8906 | MingyuZuo/APythonTour | /Examples/OOP/Basic/018.py | 926 | 3.640625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import types
class Animal(object):
def __init__(self, name='Animal'):
self.name = name
def run(self):
print('Animal is running...')
class Dog(Animal):
pass
def func():
pass
## type() 函数
print(type(123), type(123) == int)
print(type(Animal(... |
22818d67a4bfcfc48b6d0338a2981d0d41675cbc | MingyuZuo/APythonTour | /Examples/Generator&Iterator/007.py | 494 | 3.75 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# 切片(slice)
## 数组
L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']
print('L[0:3] ==> ', L[0:3]) # 取出前 n 个元素
print('L[:3] ==> ', L[:3])
print('L[1:3] ==> ', L[1:3])
print('L[-3:] ==> ', L[-3:])
print('L[-3:-1] ==> ', L[-3:-1])
print('L[:] ==> ', L[:])
print('L[::2] ==> ', ... |
34906305bba796477dfe3e640833a0ec7bd8ecba | adlienes/Python-Learning-Practices | /Loops/multiplication_table.py | 169 | 4.1875 | 4 | print("""**********
Multiplication Table Example
*************""")
for i in range(1,10):
for j in range(1,10):
print ("{} * {} ={}".format(i,j,i*j))
print("\n") |
96ab38d60c53bea9d3d91258b3682c7d0105b6dc | adlienes/Python-Learning-Practices | /Loops/atm_machine.py | 713 | 3.890625 | 4 | print("""***************
Transactions
1-) Balance Questioning
2-) Depositing
3-) Withdrawal
Press 'q' to exit
********************""")
money=1000
while True:
trans=input("Enter Transactions : ")
if(trans=="q"):
print("Exit from Atm")
break;
elif(trans=="1"):
print("Balance Questioning {} Tl".format(... |
16551f3a16466be2c3f146b1ef8d270217f8912e | KevinAS28/christmast-gravity | /christmas.py | 705 | 3.640625 | 4 | height = 22
idk = list(" "*height)
import time
def christmas(symb0, symb1, symb2):
top = """{0}\|/{0}-|- MERRY CHRISTMAS!!!{0}/|\\""".format("\n" + (" "*(height-1)))
print(top)
temp = ""
for i in range(height):
temp += (" "*(height-i)) + (("".join(symb1*i)) + (symb0) + ("".join(symb2*i)))+"\n"
topp = 0
for ... |
bd3bb1bfb10b525a6773cced83d8d9a671fd7a96 | Luisa158/LaboratorioFuncionesRemoto | /perfect.py | 342 | 3.75 | 4 |
def perfect_number (a):
suma=0
for i in range (1,a):
if a%i==0:
d=i
print(i)
suma=suma+d
res=suma-a
if res<=a:
print(a, "Is a almost-perfect number")
else:
print("Is NOT a almost-perfect number")
a=int(input("Ingrese un numero:... |
d98e9f4f3176ea7b929c2feb92cab99b587c3e93 | bado22/Think_Python | /10-1.py | 271 | 3.859375 | 4 | def nested_sum(integer_list):
integer_list_sum = 0
for i in integer_list:
if isinstance(i, int):
integer_list_sum += i
elif isinstance(i, list):
integer_list_sum += sum(i)
else:
pass
return integer_list_sum
a = [1, 2, 3, [4, 5, 6]]
print nested_sum(a) |
b2e65c3f530f301b4d716fc42ef2b134c93aeeab | bado22/Think_Python | /12-1.5.py | 145 | 3.71875 | 4 | t = [('a', 0), ('b', 1), ('c', 2)]
for letter, number in t:
print number, letter
for index, element in enumerate('abc'):
print index, element
|
b523abfd606107b029381730e2f6709eac2072d4 | bado22/Think_Python | /9-8.py | 109 | 3.921875 | 4 | def is_palindrome(word):
return word == word[::-1]
def is_palindromic_number(number):
for i in range()
|
88e6cb4b69972bb33d6e438dd803f62077e75ebb | bado22/Think_Python | /9-2.py | 372 | 3.6875 | 4 | def has_no_e(word):
for letter in word:
if letter == 'e':
return False
return True
def avoids(word, forbidden):
for letter in word:
if letter in forbidden:
return False
return True
def print_words_without_e(fin):
fin = open(fin)
for line in fin:
word = line.strip()
if has_no_e(word):
print wor... |
4a6fa0ce6310c9dd9c083c6ba8ab0a1bfd157558 | nate-browne/roman-num-calc | /RNC.py | 3,224 | 4 | 4 | #!/usr/bin/env python2
# Author: Nate Browne
# Version: 1.0
# Date: 05 May 2018
# File: RNC.py
# This file is a translation of the RNC.java file into python for use in other
# Python projects. Maintains the same OOP approach as the original Java file.
class RNC(object):
"""
Creates a RNC class used in the file... |
9ec440ca33fe98bb2ae893b935a7416c1546cb04 | RobertGolosynsky/python_dataflow_testing | /dataset/dictionary/tests/test_multi_dict.py | 764 | 3.5625 | 4 | import unittest
from core.multi import MultiDict
class MultiDictTest(unittest.TestCase):
def test_put_get(self):
d = MultiDict()
k = "key"
v = "some value"
d.put(k, v)
self.assertEqual(v, d.get(k)[0])
def test_put_get_2(self):
d = MultiDict()
k = "key"... |
4d8c690d131ffefd2e5ed6fb0a338690b3630aed | phuonghle/lehoaiphuong-fundamentals-c4e19 | /Session02/draw_triangle.py | 424 | 4.0625 | 4 | # ve hinh tam giac lech
# for i in range(3):
# nested loop
# cach 1
# for j in range(7):
# print("* " * (j)) => cach nay nhanh hon, chi co trong python, ko typical
# j += 1
# print()
# cach 2
n = 5
for i in range(n):
for j in range(n):
if (j < n - i - 1):
print(" ", end="") # ... |
3bd603073ea9640365183e7a6b11c36777d66c1c | phuonghle/lehoaiphuong-fundamentals-c4e19 | /Session05/session05 assignment/ex02.py | 506 | 4.1875 | 4 | # Write a program to count number occurrences in a list, with AND without using count() function
# cach 1
numbers =[1, 3, 5, 2, 5, 34, 65, 354, 22]
times = 0
finding = True
while finding:
number_to_find = int(input("Enter a number: "))
if number_to_find in numbers:
times = numbers.count(number_to_... |
eac908c665260801c99f90ec3624eae70cd0fd37 | phuonghle/lehoaiphuong-fundamentals-c4e19 | /Session03/session03 assignment.py/Hiep_da_shepherd.py | 959 | 3.875 | 4 | i = -1
flock = [5, 7, 300, 90, 24, 50, 75]
new_flock = flock
# print("Hello, My name is Hiep and here is my sheep sizes: \n", new_flock)
for i in range(-1, 3):
if i == -1:
print("Hello, My name is Hiep and here is my sheep sizes: \n", new_flock)
print("\n")
else:
print("MONTH {0}:".form... |
6c73f377a3474976b925be93dac5389ec9c49107 | phuonghle/lehoaiphuong-fundamentals-c4e19 | /Session02/draw_square.py | 158 | 3.5 | 4 | # not scalable to scalable
for i in range(3):
# nested loop
for j in range(7):
print("* ", end="")
print()
# print("* " * 7) -> OK |
71459a5e2575d957568d48203ca9ab9f63a1673b | Hannemit/data_science_projects | /src/data/make_dataset.py | 11,690 | 3.765625 | 4 | # useful tutorial on click: https://www.youtube.com/watch?v=kNke39OZ2k0&feature=youtu.be
# -*- coding: utf-8 -*-
import click
import logging
from pathlib import Path
from dotenv import find_dotenv, load_dotenv
import pandas as pd
import numpy as np
import os
from src.data import add_country_codes
INPUT_FILE = "./dat... |
c452b7120430e69d079ffb354534a5db4216a0c8 | d3zd3z/euler | /python3/pr041.py | 917 | 4.15625 | 4 | #! /usr/bin/env python3
"""
Problem 41
11 April 2003
We shall say that an n-digit number is pandigital if it makes use of all
the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital
and is also prime.
What is the largest n-digit pandigital prime that exists?
7652413
"""
from sieve import Sieve
... |
a3164934a32332c42c1d24faf60180c608aa3cf7 | d3zd3z/euler | /python3/pr022.py | 1,068 | 4.09375 | 4 | #! /usr/bin/env python3
"""
Problem 22
19 July 2002
Using names.txt (right click and 'Save Link/Target As...'), a 46K text
file containing over five-thousand first names, begin by sorting it into
alphabetical order. Then working out the alphabetical value for each name,
multiply this value by its alphabetical positi... |
13059b8ff84e9a26b134b6fab4570def98b1bb23 | d3zd3z/euler | /python3/sieve.py | 3,043 | 3.65625 | 4 | #! /usr/bin/env python3
"""
A simple prime number sieve.
"""
from collections import namedtuple
# Using bitarray will use a lot less memory, but is actually slower.
Factor = namedtuple('Factor', ['prime', 'power'])
class Sieve:
def __init__(self):
self._fill(8192)
def _fill(self, limit):
... |
e7747edfeae9984caf4eba0ce5502dd7269d3227 | d3zd3z/euler | /python3/pr010.py | 404 | 3.78125 | 4 | #! /usr/bin/env python3
"""
Problem 10
08 February 2002
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
"""
# 142913828922
from sieve import Sieve
def main():
s = Sieve()
sum = 0
prime = 2
while prime < 2000000:
sum += prime
... |
fe586cab6d259bfff18dc37ec3ffad4786fc092b | d3zd3z/euler | /python3/pr036.py | 558 | 3.578125 | 4 | #! /usr/bin/env python3
"""
Problem 36
31 January 2003
The decimal number, 585 = 1001001001[2] (binary), is palindromic in both
bases.
Find the sum of all numbers, less than one million, which are palindromic
in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include
leading ... |
bd2480e8c157e2c13666ae04acd8476df910f72f | d3zd3z/euler | /python3/pr007.py | 420 | 4.15625 | 4 | #! /usr/bin/env python3
"""
Problem 7
28 December 2001
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see
that the 6th prime is 13.
What is the 10 001st prime number?
"""
from sieve import Sieve
def main():
s = Sieve()
prime = 2
count = 1
while count < 10001:
prim... |
4edb9b20920f6da929b2c71e3cb6e34e15ce8d31 | zyx124/algorithm_py | /python/binary_search.py | 3,135 | 4.1875 | 4 | #! /usr/lib/python
# The general template for binary search is:
# - find mid
# - compare mid and target value to shrink the bound
# - check if the result after the loop is a qualified answer.
## Tips: when there is a certain range for the answer, the conditions to find left and right bound could be different.
## bi... |
62054e97b862666fbbf142aff1217396c49bd960 | vinniemx/Summer-Navi | /Q3.py | 387 | 3.796875 | 4 | def higher(dicio):
h = 0
for i in dicio:
if dicio[i]>h:
h=dicio[i]
else:
continue
return h
dict = {}
for i in range(5):
aluno=input("Nome do aluno: ")
nota=float(input("Nota do aluno: "))
dict[aluno]=nota
for i in dict:
if dict[i]==high... |
8c25231533174bf7ae06ab916828edcbf3f75e34 | HyeonGyuChi/knu_likelion_study | /week2/shin/17.py | 316 | 3.625 | 4 | # *
# * *
# * *
# *******
n = int(input())
if(n == 1):
print("*")
else:
line = [' *', '***']
for i in range(2, n):
for j in range(len(line)-1):
line[j] = ' ' + line[j]
line.insert(-1, ' *' + ' '*(2*(i-1)-1) + '*')
line[-1] += '**'
print('\n'.join(line)) |
78f239f58ed31a5167e193238480f2aad948a895 | HyeonGyuChi/knu_likelion_study | /week2/ji/Beakjoon_Star/Q2.py | 387 | 3.671875 | 4 | ''' By HyeonGyu
BAEKJOON STAR / 백준 별찍기
https://www.acmicpc.net/workbook/view/20
Q2
*
**
***
****
*****
'''
num = int(input())
for i in range(1,num+1) :
for k in range(i, num) :
print(" ", end="")
for j in range(i) :
print("*", end = "")
print()
'''0(n)'''
for i in range(1, num+1... |
30f40bcf2d3b225bd135dd8f66b246d11433cc93 | OctavioOp/python_intermediate | /python_intI.py | 741 | 3.6875 | 4 | import random
min1 = int(input('ingrese el numero menor: '))
max1 = int(input('ingrese numero mayor: '))
def radInt(min=0, max=100):
minus = max - min
if max > min and max > 0:
num = round(random.random() * minus + min)
return num
elif min > max:
return print('error valor maximo m... |
14616a9657cdd85d1f87d730c0dc3ffeb3a1690d | nmasharani/ProjectEuler | /Python/euler10.py | 259 | 3.859375 | 4 | import math
from sys import exit
def IsPrime(n):
if n % 2 == 0:
return False
i = 3
while i < int(math.sqrt(n)) + 1:
if n % i == 0:
return False
i += 2
return True
sum = 2
i = 3
while i < 2000000:
if IsPrime(i):
sum += i
i += 2
print sum
|
04dde1d48dbf399558154f27095325b42e2b638a | Leelesh-Sharma/Password-Genrator | /Main.py | 816 | 3.78125 | 4 | import random
import string
alphabets = list(string.ascii_letters)
numbers = list(string.digits)
special_ch = list(string.punctuation)
password = list()
def normal_password():
print('NORMAL PASSWORD')
digits = int(input('How many digits should your password may contain - '))
for _ in range(d... |
27c26c80c0858ef281cafc092af1c3218f001d08 | BayleeR/learn-arcade-work | /Testing/lab 8 text.py | 5,821 | 3.578125 | 4 | """ Sprite Sample Program """
import random
import arcade
# --- Constants ---
SPRITE_SCALING_PLAYER = 0.2
SPRITE_SCALING_SNOWBALL = 0.1
SPRITE_SCALING_FIRE = 0.1
SNOWBALL_COUNT = 50
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
#sound from OpenGameArt
class Snowball(arcade.Sprite):
def __init__(self, filename, spri... |
37fc2465382e12197e8fcac20c1bd210c3442616 | sincyjoseph/Python_Tutorial | /Car_Program/Car_Program.py | 798 | 3.5625 | 4 |
class Car:
def __init__(self,enginename):
print("Car created")
self.number_of_wheels = 4
self.engine = str(enginename)
self.registration_number = ""
def setRegistrationNumber(self,registrationNumber):
self.registration_number = str(registrationNumber)
def ge... |
c69bc0838ca8a3976ea720b3748d0580f52b487e | RobertWest105/Weather-App | /WeatherApp.py | 2,579 | 3.59375 | 4 | import tkinter as tk
from tkinter import font
import requests
from PIL import Image, ImageTk
from GetWeatherIcons import getWeatherIcons
# api.openweathermap.org/data/2.5/forecast?q={city name},{state code},{country code}&appid={your api key}
root = tk.Tk()
HEIGHT = 520
WIDTH = 680
def formatResponse(w... |
2495f0beb83fd09a7a6f4de11811486432b35c48 | ashraf-amgad/Python | /Python Basics/OOP/OOP_constructor.py | 478 | 3.796875 | 4 |
class Car:
def __init__(self, owner, color):
self._Owner = owner
self._Color = color
print("class is initalized--------------------")
def GetColor(self):
print("the car color is : " + self._Color)
def GetOwner(self):
print("the car owner is : " + self._Owner)... |
af89aafbb64f0a5db8732fe2b2651f614c1971a5 | Umercia/Ereaders_notes_export | /export_notes_from_kindle.py | 2,809 | 3.65625 | 4 | # -*- coding: utf8 -*-
################################################################################
# Program Python 3
# Author: Maurice Clere, 2018
# licene: GPL
################################################################################
# Obj: import kindle notes "My Clippings.txt" into SQLite Database "not... |
92aa676a3beccccf9e43265a062092e8ecc50951 | ChristineHu1207/Udacity-Programming-for-Data-Science | /bike_Share/updated_project2/project2_updated.py | 7,339 | 4.40625 | 4 |
import time
import pandas as pd
import numpy as np
CITY_DATA = {'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv'}
MONTH_DATA = ['january', 'february', 'march', 'april', 'may', 'june']
DAY_DATA = ['monday', 'tuesday', 'wednesday', 'thursday', 'f... |
10df295fd611d999742956923cfcb9e08c1b412a | Mithun133/Task_09 | /insert_at.py | 3,450 | 4.125 | 4 | class Node:
def __init__(self, data= 'Head', next=None):
self.data = data
self.next = next
class LinkedList:
def __init__(self):
self.head = Node()
def get_length(self):
count = 0
n = self.head
while n:
count = count + 1
n = n.next
... |
6e27b602350f922c77e5642094d9a48c81ca3ae1 | Arshdeep86/encpyhton | /MLregression.py | 1,594 | 3.6875 | 4 | import numpy as np
class RegressionModel:
def __init__(self):
self.b0 = 0
self.b1 = 0
self.mse = 0
self.fitforprediction = False
def fit(self,X,Y):
self.X = X
self.Y = Y
self.b1 = np.sum((self.X - np.mean(self.X)) * (self.Y - np.mean(self.Y))) / np.sum(np... |
3f017cc53589e0bcd8f458d8161f5c5df0a2bb82 | Arshdeep86/encpyhton | /session8G.py | 310 | 4.03125 | 4 | s1 = {'a','b',1,2}
print(s1)
s1.add('x')
print(s1)
s1.remove(1)
print(s1)
s1.pop() #pops first element of set
print(s1)
s1.clear()
print(s1)
data = [1,2,3]
s = set(data) # convert list into set
print(s)
list1 = [2,3,5,]
list1.clear()
print(list1)
set1 = {1,2,3,4,'a',1,4}
list2 = list(set1)
print(list2)
|
61aa44fa9f4af448b9fbabbf048e9573409b204a | Arshdeep86/encpyhton | /assignop.py | 485 | 4 | 4 | # Assignmnt operators in pyhton
num1 = 4 # equal assignment operator
num2 = 8
res = 0
res += num1 #res = res+num1
print("after assignment addition result is: ", res)
res -= num1
print("after assignment subtraction result is: ", res)
res /= num1 # res = 0/4
print("after division assignment result is: ", res... |
8497fa5bf6b12606698af93f71cc7feab3fb243f | Arshdeep86/encpyhton | /zometo.py | 995 | 3.96875 | 4 | amount = int(input("Enter an amount: "))
if amount > 100:
print("we have offers for you :")
print("1. you got 40% OFF , if you pay above 200 and you apply the promocode ZOMETO")
print("2. you got 50% OFF upto 150 , if you pay above 100 and you apply the promocode JUMBO")
promoCode = input("Enter Promo C... |
5e699a53240ed689e46c60c05338531f98d616ff | Arshdeep86/encpyhton | /session8c.py | 438 | 4.15625 | 4 | names = "john, joe, jack, jim"
spliitedNames = names.split(",")
print("after Splitting names are : ", spliitedNames)
for name in spliitedNames: # to show names in different lines
print(name.strip())
quotes = """Work Hard, Get Luckier
Search the Candle, rather than cursing the darkness
"""
words = quotes.split("... |
61efda5e3ebc0022b88c9c7eac8f7d0dc1f01f8d | Arshdeep86/encpyhton | /session24B.py | 399 | 3.8125 | 4 | # Regular Expressions
import re
quote = "Search the candle rather than cursing the darkness"
#result = re.match("Search",quote) # 0-6
#result = re.match("candle",quote) # None
#result = re.search("the",quote)
result = re.findall("the",quote)
print(result,type(result))
print("_________________________________")
#data... |
5556e584c4ebd13f74422d8376c988daaf6be485 | waverune/Python3 | /Great.py | 140 | 3.875 | 4 | x= int(input('X='))
y= 69
if x > y:
print(x)
print('is greater than 69')
else:
print(x)
print('is less than 69')
|
56d3ab67eb2f4fc2d371b091651b675b6c9937ee | maksimuslyandia/python_Task | /lib/client.py | 4,439 | 4.3125 | 4 | from lib.system import System
class Client:
rent_types_dict = {
"1": "hour",
"2": "day",
"3": "week"
}
def __init__(self):
self.system = System
# Initiates a list of all the cars
self.system.start()
def list_cars(self):
self.system.display_avai... |
686358f1d2b2eb44d4d3e39fd28bdf3e6bdcc4d3 | aliborji/AITeeko | /Submissions/Karman/mygames.py | 7,871 | 3.515625 | 4 | from games import (Game)
class GameState:
def __init__(self, to_move, board, firstPhase, label=None,):
self.to_move = to_move
self.board = board
self.label = label
self.firstPhase = firstPhase
if len(board) > 7:
self.firstPhase = False
else:
... |
8350c6f765d3f352f99fc180a196272b80a9ba73 | rootstream/realsense-rtmp-twitch | /startup-scripts/wifi-config.py | 1,651 | 3.578125 | 4 | import tkinter as tk
import tkinter.font as tkfont
import os
class Application(tk.Frame):
wifiSSID = str(os.environ['WIFI_CONFIG_SSID'])
wifiPASSWD = str(os.environ['WIFI_CONFIG_PASSWD'])
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
... |
e945b808bcafe094de47608e3e7b448b8e184837 | sagarippili/DataStructuresAndAlgorithms | /Queue.py | 1,165 | 3.90625 | 4 | class Queue():
def __init__(self, queueSize):
self._front = 0
self._rear = -1
self._queueSize = queueSize
self._queueArray = [None] * queueSize
def getQueueSize(self):
return (self._queueSize)
def setQueueSize(self, queueSize):
self._queueSize = q... |
076c8e279425ab773b0f26e763ca8b88d2a3291e | martatia/functions.py | /project.py | 2,995 | 4.40625 | 4 | #SIMPLE Calculator
import math
print("The simple calculator is only for two numbers")
def addition(a:float,b:float):
"""[counts sum of two numbers]
Args:
a (float): [number1]
b (float): [number2]
Returns:
[float]: [sum]
"""
return a+b
def substraction(a:float,b:float):
... |
091348ad3f843b23cec05eac8ae754403c7f9e91 | DiwWir-0721/ErdiwaWirengjurit_Assignment2 | /AliceNBob.py | 125 | 3.65625 | 4 | def stones():
i = int(input()) % 2
if i ==0:
print("Bob")
else:
print("Alice")
stones()
|
69a1a1f7fa9966903b12d067dfbeccd30c2b5e5d | Abeerdxx/python-spotcheck-solutions | /Functions/sc2.py | 449 | 3.875 | 4 | def remove_letter_from_text(text, letter):
return filter(lambda c: c != letter, text)
def encode_text(text):
return "-".join(map(lambda c: str(ord(c)), text))
def show_encoded_filter(text, letter):
updated_text = remove_letter_from_text(text, letter)
print("Updated text is " + updated_text)
enc... |
2c5910db4638ccd8278ba508aeee37f6e1c096cd | Abeerdxx/python-spotcheck-solutions | /File-IO/sc4.py | 736 | 3.640625 | 4 | import csv
stocks = [
{"name": "Apple", "price": 246},
{"name": "Tesla", "price": 328},
{"name": "Microsoft", "price": 140},
{"name": "Amazon"},
{"name": "Lionsgate", "price": 8},
{"name": "Netflix", "price": 276},
{"name": "Google"},
{"name": "Activision", "price": 55},
]
with open("s... |
d7b3b0c129410b18e28af98553e0662f04001f47 | JosephAMumford/CodingDojo | /Python/PythonFundamentals/Checkerboard.py | 568 | 4 | 4 | # You need two loops, one for y-axis and one for x-axis
for y in range(0,8):
# Create a string variable, print adds a line break so we build each row as a string
line = ""
for x in range(0,8):
# Here we check if row and column is even or odd, alternate patterns on odd rows
if y % 2 == 0:
... |
38ab3e5f42ed59483a17ab0ab46fa35c3aa600d4 | JosephAMumford/CodingDojo | /Python/PythonFundamentals/CoinTosses.py | 812 | 4.09375 | 4 | import random
# Keep track of heads or tails
total_heads = 0
total_tails = 0
# This function returns the result of a coin toss, simulated by a random number that is
# rounded to either 1 or 0, for heads or tails
def toss_coin():
result = ""
rand = random.random()
rand = round(rand)
# Tails
if ran... |
e07a54641912946501328b323b2b758f9c61d187 | JosephAMumford/CodingDojo | /Python/PythonFundamentals/MakingDictionaries.py | 825 | 3.90625 | 4 | # Input lists
name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar"]
favorite_animal = ["horse", "cat", "spider", "giraffe", "ticks", "dolphins", "llamas"]
# This function makes a dictionary out of two lists. It will test to ensure both
# lists are the same size. If not, the shorter list will be used ... |
f49062cb1bc8526566af7a7d478b047c5cd444f5 | JosephAMumford/CodingDojo | /Python/PythonFundamentals/FooAndBar.py | 1,369 | 4.15625 | 4 | # Program to evaluate if a number is prime or a perfect square
# If number is prime, print "Foo", if number is perfect square, print "Bar"
# Else print "FooBar"
# Variables
currentSquare = 1
currentPrime = 2
isSquare = False
isPrime = False
for x in range(100,100000):
isSquare = False
isPrime = False
... |
e8d40702ab6bc22a8997ff2ad35a92707eb930e0 | Sundarmax/Interview-practice-problems | /linkedlist/singly_list.py | 2,578 | 4.3125 | 4 | # Implementation of singly linked list
class Node:
def __init__(self,data):
self.item = data
self.next = None
class LinkedList:
def __init__(self):
self.start_node = None
def TraverseList(self):
if self.start_node is None:
print('List has no element')
... |
ec4cc89daa0d87eb5884db92cd7976ebbda020b6 | Sundarmax/Interview-practice-problems | /Array/binary_sort.py | 1,001 | 3.65625 | 4 | # segregate 0's and 1's in array
# first approach we can't track order of elements and Time complexity is 0(N)
# Time complexity of secon approach is O(N)
a = [1,0,1,1,1,1,0,0,0,1]
def BinarySort():
first = 0
last = len(a) -1
while first < last:
if a[first] == 0:
first+=1
if ... |
98f4fa652a9906affe0ac526602f0cb4c5352675 | Sundarmax/Interview-practice-problems | /stack/stack_list.py | 947 | 4.0625 | 4 | #Stack implementation by using linked list
class Node:
def __init__(self,data):
self.data = data
self.next = None
class StackList:
def __init__(self):
self.startNode = None
def PrintStack(self):
n = self.startNode
while n is not None:
print(n.data)
... |
06c10730c608d47db4fdd1a51556db93ce47f907 | mondher-bouazizi/currency_project | /utils.py | 3,254 | 3.5 | 4 | from google_images_download import google_images_download
import itertools
import os
import shutil
chromedriver = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe"
def set_chromedriver(chrome_driver_dir):
if os.path.exists(chrome_driver_dir):
global chromedriver
chromedrive... |
1768b55f74853bc4025281f878a4e9f9a44fa97a | rates37/Numerical-Methods | /Ordinary Differential Equations/midpoint.py | 2,898 | 4.125 | 4 | # Author: Satya Jhaveri
#
# The Midpoint Method aims to improve on Euler's method by using an estimate of the slope
# at the midpoint between the step. This is a predictor-corrector method, as it first estimates
# the value of the slope at the midpoint (predictor step), and then uses that value to approximate
# the ... |
a2c25789b81251bd6bb4ee6c964eedacc00a67e8 | mawilliams7/Lab_3 | /Main.py | 4,080 | 3.515625 | 4 | import NodeAVL
import NodeRB
import math
# Creates the AVL tree by reading the file and inserting the words to the tree
def AVL_tree(AVLTree):
tree = type_of_tree.NodeAVL()
line = []
file = open('glove.6B.50d.txt', 'r')
for lines in file:
line = lines.split()
w = line[0]
if ignore(w): #if the wor... |
937f194ab56587629027cc320956db151c2ef162 | tylergan/veryfirstproject | /Assingment /test_game.py | 1,919 | 3.53125 | 4 | '''
Author: Tyler Gan
Date: 22 May 2020
Purpose: This tests specfic aspects of my game file; this includes:
• Updating player coordinates
• Updating player water buckets
• Player interactions with fire, walls and the end object
'''
from game import Game
from cells import (
Start,
End,
Air,
... |
8dbfe0441e7ea1cde6b67fc5973a92f15f764d30 | tylergan/veryfirstproject | /Assingment /Archives/solver_class.py | 5,056 | 3.515625 | 4 | # import copy
# from game import Game
# from cells import (
# Start,
# End,
# Air,
# Wall,
# Fire,
# Water,
# Teleport
# )
# import sys
# def solve(mode, filename):
# game = Game(filename)
# if mode == 'BFS':
# commands = ['a', 'd', 'w', 's', 'e']
# X = Start()
... |
63a08253b853f919c9fef95eb44a3e71d6e82bb2 | thebelleSabrina/Boggle_Game_Solver | /boggle_game_solver/boggle.py | 2,886 | 3.5 | 4 | """
File: boggle.py
Name:
----------------------------------------
TODO:
"""
import time
# This is the file name of the dictionary txt file
# we will be checking if a word exists by searching through it
FILE = 'dictionary.txt'
def main():
"""
TODO:
"""
start = time.time()
lst = []
lst = read_dictionary(lst)
... |
b24ef4fca2e840e818d22583d820673ae91188dc | JaimePazLopes/learningPython | /src/moreTests.py | 790 | 3.90625 | 4 | def squareFunction(number):
return number ** 2
numbersToSquare = [2, 3, 4.5, 6, 10]
for number in map(squareFunction, numbersToSquare):
print(number)
listSquares = list(map(squareFunction, numbersToSquare))
print(listSquares)
def isEven(number):
return number % 2 == 0
numbers = [1,2,3,4,5,6... |
d9f79968d6c11ccae7b949e8ca3bd873e366f993 | JaimePazLopes/learningPython | /src/functionExercises.py | 7,146 | 3.71875 | 4 | def lesserEven(*args):
lesserEven = biggerOdd = None
for number in args:
if type(number) is not int:
continue
if biggerOdd is None:
if number % 2 == 1:
biggerOdd = number
elif lesserEven is None:
lesserEven = number
... |
f7e9f258ec99b6ce87204131f8111e12618f88f9 | webargus/ufrpe_crud | /crud/alunos.py | 7,277 | 3.71875 | 4 | """
*************************************************************************
* *
* Projeto CRUD / Sistema de Controle Acadêmico Simplificado *
* *
... |
11e6a1329ae188714ec0355aab7805f530b898df | IoanaMMT/Quiz-Master | /quiz_master.py | 5,625 | 4.0625 | 4 | print("Welcome to the Quiz Master")
print("Please answer to the following questions to the best of your abilities")
print("Let's do the introductions first")
name = raw_input("What is your name please?")
print("Nice to meet you {}!. Enjoy the quiz!".format(name))
print("Let's go to the first question!")
score_count = ... |
f1a92183c63cca252d9441a4fe90e2fe91c8c2ac | Floris1221/Ansta | /main.py | 707 | 3.515625 | 4 | from decimal import *
#@Florian Gaffke
def Code_generator(code1, code2):
list = []
code1 =int (code1.replace("-",""))
code2 =int (code2.replace("-",""))
for i in range(code1+1,code2):
i = str(i)
i="-".join([i[0:2],i[2:]])
list.append(i)
print(list)
def List_checker(inli... |
4dc9f2df79a5f7518f50e9012d4913eb40ea2247 | earayu/tetrisOnline | /login.py | 1,570 | 3.5 | 4 | from tkinter import *
import persistence
class Reg (Frame):
def __init__(self,master):
frame = Frame(master)
frame.pack()
self.f = master
self.lab1 = Label(frame,text = "用户名:")
self.lab1.grid(row = 0,column = 0,sticky = W)
self.ent1 = Entry(frame)
self.ent1.gr... |
9601f92d9d6f16253dc8786a855fdf1813416556 | mbetances805/projectEuler | /python_solutions/sum_even_fibonacci_numbers.py | 844 | 4.125 | 4 | # Each new term in the Fibonacci sequence is generated by adding
# the previous two terms. By starting with 1 and 2, the first 10
# terms will be:
#
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#
# By considering the terms in the Fibonacci sequence whose values
# do not exceed four million, find the sum of the even-valued ... |
9e2b8383dd0270062eebf972c5c20ddd32e11d95 | Nckc/Wordlistmaker-work-py | /makeWordList4.py | 611 | 3.640625 | 4 | #This finally seems to work! Cobbled together from online sources, but...
import re
import pyperclip
file = open(r"C:\Users\user\Dropbox\KC BUSINESS\EE\Readings\writings21.txt", 'r')
# .lower() returns a version with all upper case characters replaced with lower case characters.
text = file.read().lower()
fil... |
090ab8ca85d428e5719d84e2e95a193a7cc6d7d3 | Simran21Arora/Dictionary | /dictionary.py | 2,029 | 3.921875 | 4 | import json
import tkinter
window=tkinter.Tk()
window.title('Dictionary')
left_frame=tkinter.Frame(window)
left_frame.grid(row=0, column=0)
label=tkinter.Label(left_frame, text="ENTER WORD : ").grid(row=0,column=0)
input_field=tkinter.Entry(left_frame,font=("times",15))
input_field.grid(row=1,column=0)
lab... |
29427922e3689634cc84ec04dc2f6f2908ca9195 | Pineappluh/AoC-2020 | /6/6-1.py | 272 | 3.703125 | 4 | import fileinput
count = 0
current_set = set()
for line in fileinput.input():
if line == "\n":
count += len(current_set)
current_set = set()
else:
current_set = current_set.union(set(line.strip()))
count += len(current_set)
print(count)
|
25e8acb7067d4b75bd80630c1526a90ed1162f09 | aventador2018/Principle-Programming-Language-504-51 | /testdrive.py | 1,019 | 3.53125 | 4 | import Integrate1D
def main():
X0 = 1.0
XN = 2.0
NUM_RECT = 10
currentResult = 100
results = []
print('n', ' h', ' integral', ' error')
# Construct an instance of the Integrate1D class
intobject = Integrate1D.Integrate1D(function=myfunction)
# Perform integr... |
d991024dd86c83b9bc55f316d4146f73ea7721af | aventador2018/Principle-Programming-Language-504-51 | /Programming_Assignment_4.py | 524 | 3.953125 | 4 | # Given a regular expression, construct a non-deterministic-finite-state that recognizes the set that this expression
# represents
# (0U1)(0U1)*00
def nond(str):
result = ''
if len(str) == 3 and str[-2:] == '00':
result = 'Accepted'
elif len(str) > 3 and str[-2:] == '00' and (str[1:-2].find('0') =... |
e13afa31c7e643a2e8b64fc0c0d7ce66ee132a19 | aventador2018/Principle-Programming-Language-504-51 | /Programming_Assignment_2.py | 809 | 3.921875 | 4 | # Given the state table of a Moore machine and then input string, produce the output string generated by the machine
input = '1111'
def moore(str):
state = 0
output = ''
for i in str:
if state == 0:
if i == 0:
state = 0
output = output + '1'
... |
a3f07a88006ab6ca40fab67808ee789e0ee70b03 | Algomorph/LevelSetFusion-Python | /math_utils/parametrics.py | 1,896 | 3.609375 | 4 | # ================================================================
# Created by Gregory Kramida on 1/17/19.
# Copyright (c) 2019 Gregory Kramida
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Licen... |
49566cb36561436f0d1339c7391cd63d3a204381 | MaxAkonde/python | /course_1_assignement_6/03_02.py | 535 | 4.21875 | 4 | several_things = ["hello", 2, 4, 6.0, 7.5, 234352354, "the end", "", 99]
for i in several_things:
print(i)
for i in several_things:
print(type(i))
# Write one for loop to print out each element of
# the list several_things. Then, write another for
# loop to print out the TYPE of each element of the
# lis... |
ed089ae77b7cc25095cac6f001aca9bc9ae50f2d | MaxAkonde/python | /course_1_assignement_6/03_01.py | 145 | 4.09375 | 4 | my_str = "MICHIGAN"
for i in my_str:
print(i)
# Write one for loop to print out each
# character of the string my_str on a separate line. |
a0690d21e7a6a37ad2e4cc2f23f131d2bb4cbf95 | MaxAkonde/python | /guessTheNumber.py | 526 | 4.03125 | 4 | print("**** Guess The Number ****")
import random
MIN = 1
MAX = 100
def guessTheNumber(MIN, MAX):
guess = random.randint(MIN, MAX)
nb = int(input("Entrer le nombre mystere : "))
while nb != guess:
if nb > guess:
print("C'est moins !")
nb = int(input("Entrer le nombre myster... |
ac01c08ed8585dee3187a71c670bc731b1dfc3ef | SGBotic/SGBotic_Pi_2_Kit | /rpi_lab5.py | 1,712 | 3.515625 | 4 | 23# rpi_lab5.py
# In this lab, we will will look at how to read temperatue and humidity value from DHT11 sensor and post the data
# to thingspeak.com, an Iot cloud service.
#
# You can see our channel at https://thingspeak.com/channels/54511
# Import Python libraries
import httplib, urllib
import Adafruit_DHT
import ... |
ff0c7196315e9842c1320284d83068946b1b380f | raghubegur/PythonLearning | /0_tkinter/grid.py | 273 | 4 | 4 | from tkinter import *
root = Tk()
myLabel1 = Label(root, text='Hello World').grid(row=0,column=0)
myLabel2 = Label(root, text='My name is Raghu').grid(row=2,column=0)
#myLabel.pack()
#myLabel1.grid(row=0,column=0)
#myLabel2.grid(row=1,column=0)
root.mainloop()
|
6ec2e6db2b0e9981e93ae4d19b0affb552f9ac52 | wzwhit/leetcode | /145二叉树后序遍历迭代.py | 1,032 | 3.828125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
#二叉树后序遍历迭代算法,先遍历左子树,再遍历右子树,再访问根节点
class Solution:
def postorderTraversal(self, root: TreeNode) -> List[int]:
stack = []
out = []
l... |
96105a5e9ca338598457d77ddce4c51cd6c75aa7 | wzwhit/leetcode | /剑指offer/面19正则表达式.py | 1,384 | 3.828125 | 4 | # -*- coding:utf-8 -*-
import sys
# -*- coding:utf-8 -*-
class Solution:
# s, pattern都是字符串
def match(self, s, pattern):
# write code here
if not s and not pattern:
return True
elif not pattern:
return False
elif not s:
for i in range(len(patter... |
031498a32fe97e4cd45bc4ef15afe00653bb1186 | wzwhit/leetcode | /33搜索旋转排序数组2.py | 1,634 | 3.71875 | 4 | # 假设按照升序排序的数组在预先未知的某个点上进行了旋转。
# ( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。
# 搜索一个给定的目标值,如果数组中存在这个目标值,则返回它的索引,否则返回 -1 。
# 你可以假设数组中不存在重复的元素。
# 你的算法时间复杂度必须是 O(log n) 级别。
# 示例 1:
# 输入: nums = [4,5,6,7,0,1,2], target = 0
# 输出: 4
# 示例 2:
# 输入: nums = [4,5,6,7,0,1,2], target = 3
# 输出: -1
# 从中间分开,左右有个一为有序,在有序... |
8408203f25a7ad7add68a4364cdb8a6f6645693c | wzwhit/leetcode | /14.longest-common-prefix.py | 1,373 | 3.53125 | 4 | #
# @lc app=leetcode.cn id=14 lang=python3
#
# [14] 最长公共前缀
#
# https://leetcode-cn.com/problems/longest-common-prefix/description/
#
# algorithms
# Easy (31.59%)
# Total Accepted: 48.7K
# Total Submissions: 154K
# Testcase Example: '["flower","flow","flight"]'
#
# 编写一个函数来查找字符串数组中的最长公共前缀。
#
# 如果不存在公共前缀,返回空字符串 ""。
#
... |
c2361b921ae7ace6726a07891fc13a5fb66c0051 | wzwhit/leetcode | /剑指offer/面10斐波那契数列.py | 348 | 3.640625 | 4 | # -*- coding:utf-8 -*-
class Solution:
def Fibonacci(self, n):
# write code here
# 递归太慢,不如直接循环或者说动态规划
if n <= 1:
return n
n1 = 0
n2 = 1
out = 0
for i in range(2,n+1):
out = n1 + n2
n1, n2 = n2, out
return out |
c2d97605fda45edc62851f82ab4806c59b73df94 | wzwhit/leetcode | /71简化路径.py | 567 | 3.65625 | 4 | class Solution:
def simplifyPath(self, path: str) -> str:
if path == "":
return '/'
stack = []
s = path.split('/')#按/分割
for i in range(len(s)):
if s[i] == '.' or s[i] == '':#'.'和'//'不管
continue
elif s[i] == '..':#'..'删除栈顶
... |
55df809fb7aa32d6cba57ec00095cda4b18d978d | wzwhit/leetcode | /141环形链表.py | 1,252 | 4.09375 | 4 | # 给定一个链表,判断链表中是否有环。
# 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。
# 示例 1:
# 输入:head = [3,2,0,-4], pos = 1
# 输出:true
# 解释:链表中有一个环,其尾部连接到第二个节点。
# 示例 2:
# 输入:head = [1,2], pos = 0
# 输出:true
# 解释:链表中有一个环,其尾部连接到第一个节点。
# 示例 3:
# 输入:head = [1], pos = -1
# 输出:false
# 解释:链表中没有环。
# 进阶:... |
eb892b47a4a4ceafe8494c06a047bce091a88e1c | wzwhit/leetcode | /49字母异位词分组.py | 701 | 3.8125 | 4 | # 给定一个字符串数组,将字母异位词组合在一起。字母异位词指字母相同,但排列不同的字符串。
# 示例:
# 输入: ["eat", "tea", "tan", "ate", "nat", "bat"],
# 输出:
# [
# ["ate","eat","tea"],
# ["nat","tan"],
# ["bat"]
# ]
# 说明:
# 所有输入均为小写字母。
# 不考虑答案输出的顺序。
#Hash Table
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
... |
76d65e40ed7ecf1338ec1c85fe8921517fc67cd9 | wzwhit/leetcode | /125验证回文串.py | 661 | 3.859375 | 4 | # 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。
# 说明:本题中,我们将空字符串定义为有效的回文串。
# 示例 1:
# 输入: "A man, a plan, a canal: Panama"
# 输出: true
# 示例 2:
# 输入: "race a car"
# 输出: false
class Solution:
def isPalindrome(self, s: str) -> bool:
s = s.lower() # 大写转小写
a = []
for i in range(len(s)):
... |
78b39f1d050061e4b5b3f21568fa8e912f6d2129 | wzwhit/leetcode | /81搜索旋转排序数组II.py | 1,906 | 3.859375 | 4 | # 假设按照升序排序的数组在预先未知的某个点上进行了旋转。
# ( 例如,数组 [0,0,1,2,2,5,6] 可能变为 [2,5,6,0,0,1,2] )。
# 编写一个函数来判断给定的目标值是否存在于数组中。若存在返回 true,否则返回 false。
# 示例 1:
# 输入: nums = [2,5,6,0,0,1,2], target = 0
# 输出: true
# 示例 2:
# 输入: nums = [2,5,6,0,0,1,2], target = 3
# 输出: false
# 进阶:
# 这是 搜索旋转排序数组 的延伸题目,本题中的 nums 可能包含重复元素。
# ... |
ec5473d6e86b333ec27dec3bc42ea24b98abf788 | kzd0039/leetcode_problems | /63.py | 663 | 3.5 | 4 | def uniquePathsWithObstacles(obstacleGrid):
for r in range(len(obstacleGrid)):
for c in range(len(obstacleGrid[0])):
if r == 0 and c == 0:
obstacleGrid[r][c] = 1
elif obstacleGrid[r][c] == 1:
obstacleGrid[r][c] = 0
else:
... |
e2f787b07d182b00b080871f02cf5ae114165201 | kzd0039/leetcode_problems | /68.py | 1,106 | 3.578125 | 4 | def fullJustify(words, maxWidth):
ans = [ ]
c = 0
cur = [ ]
for ele in words:
if c + len(ele) <= maxWidth and len(cur) - 1 + c + len(ele)<= maxWidth:
cur.append(ele)
c += len(ele)
else:
blank = maxWidth - c
divide = len(cur) - 1
... |
be3977e1e15fe699ea5f21f996baa35a9bb89950 | kzd0039/leetcode_problems | /40.py | 661 | 3.84375 | 4 | def combinationSum2(candidates,target):
candidates.sort()
combinations = []
def backtrack(nums, curr_sum, i):
if curr_sum == target and nums not in combinations:
combinations.append(nums)
elif curr_sum < target:
for j in range(i+1, len(candidates)):
... |
236169ab30fd56343e74a33f80d1ded454e23379 | kzd0039/leetcode_problems | /34.py | 989 | 3.765625 | 4 | def searchRange(nums,target):
if not nums or (target < nums[0] and target > nums[len(nums)-1]):
return [-1, -1]
def binarysearch(nums, target, start, end):
if target == nums[start]:
return start
if target == nums[end]:
return end
mid = (end + start) // 2
... |
6f7796d030e6491eb3a75e67abb29257ba83a2c7 | kzd0039/leetcode_problems | /13.py | 515 | 3.71875 | 4 | def romanToInt(s):
dicts={'I':1,'V':5,'X':10, 'L':50, 'C':100, 'D':500, 'M':1000, 'IV':4,
'IX':9, 'XL':40, 'XC':90, 'CD':400, 'CM': 900}
l = len(s)
i = 0
result = 0
while i<l:
if i+1 < l and s[i:i+2] in dicts:
result += dicts[s[i:i+2]]
i += 2
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.