blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
7268b115110cd7b7564f7819a252c1ad71337111
StudiousStone/CNN_Accelerator
/Deep_Learning_from_Scratch/Ch03_Neural_Network/Activiation_Functions/step_function.py
231
3.578125
4
import numpy as np def step_function(x): y = x > 0 # Compare x with 0 which returns boolean type to y. return y.astype(np.int) # Transform boolean type to int value. # Test function print(step_function(np.array([-1.0, 2.0])))
640cdfbd67bcc920e76ab66aed2a1eabcbebed03
MaazShah2060/Hangman_game
/hint.py
501
3.6875
4
import random def give_clue(word): hinti1 = random.randrange(len(word)) hinti2 = random.randrange(len(word)) def replace_all(hinti): for i in range(len(word)): if word[i] == word[hinti]: cluelist[i] = word[hinti] return cluelist while hinti2 == hinti1: hinti2 = random.randrange(...
e833be3ea7d7014127926e2a405a5c128ef3de5e
guli732/python_simple
/stars.py
174
3.8125
4
for i in range(5): print(' ' * (5 - i), end='') print('*' * (i * 2 + 1)) for i in range(5, -1, -1): print(' ' * (5 - i), end='') print('*' * (i * 2 + 1))
94b6dc2022b9daf0a2a8c6c4e5a191faeb51f3eb
Chloe-Codes/project-euler-python
/eu4.py
904
3.84375
4
#################################################### ## ## ## Project Euler Exercise 4 Solution ## ## Chloe Dyke 2017 ## ## ## ## Solution: 906609 ...
2d91c7b4559bbaeef7988e13dce4b125e85ed655
slarkcc/common_web
/common/class_object.py
25,529
3.859375
4
# -*- coding: utf-8 -*- # @Time : 2018/2/8 13:55 # @author : slark # @File : class_object.py # @Software: PyCharm from functools import partial import math # 创建大量对象时节省内存 class Date(object): __slots__ = ["year", "month", "day"] # 使用slots后,不能再给实例添加新属性 def __init__(self, year, month, day): self....
ae9e8ccfee70ada5d6f60a9e8a16f3c2204078ca
OmarSamehMahmoud/Python_Projects
/Pyramids/pyramids.py
381
4.15625
4
height = input("Please enter pyramid Hieght: ") height = int(height) row = 0 while row < height: NumOfSpace = height - row - 1 NumOfStars = ((row + 1) * 2) - 1 string = "" #Step 1: Get the spaces i = 0 while i < NumOfSpace: string = string + " " i += 1 #step 2: Get the stars i = 0 while i < NumOfStars...
b61f342e7ce8ec8859e07dbe1ab4c1917f79743f
OmarSamehMahmoud/Python_Projects
/To_Do/Todo.py
769
4.09375
4
ToDo=list() Done=list() print("************************************") print("To Add New Item Press 1") print("To Print the To Do List Press 2") print("To Mark an item as Done Press 3") print("To Print the Done list Press 4") print("************************************") i=1 while i > 0 : choice=input("Please enter you...
4a2c3eb31eeb2b162d28fd64c80823550718e093
kapilchandrawal/Decorators-and-Generators
/print_file_content_generator.py
677
3.90625
4
#3) Use Generators to read the file And Print all the words in a file. def read_large_file(file_handler): for line in file_handler: word_arr= [] for i in line: if(i != " " and i != "/n"): word_arr.append(i) else: yie...
11bfd401d28dd8a98793ab5576f12f4a413d9db3
hectorpla/inference_fol
/unification_test.py
2,403
3.5625
4
import homework3 as hw3 import itertools def var_name_generator(): name_tab = ['x', 'y', 'z', 'w', 'p', 'q'] counter = itertools.count(1) while True: num = next(counter) stack = [] name = '' while num: num -= 1 stack.append(name_tab[num % 6]) ...
9ed6da10988cdca419a06290c6f66b8540f0a773
jaehyek/Raspberri-Pi-GoPiGo-Robot-EKF-SLAM
/CalibrateRobot.py
1,061
3.640625
4
import MoveRobot import SenseLandmarks # Commands that are used to measure robot movement and sensing uncertainty. # The outputs wil be used to compte the move and sense uncertainty covariance matrices. # Constants NUMBER_OF_ITERATIONS = 15 # Get data for movement forward uncertainty def calibrate_move(): count =...
4e2ee1f8ba0536c153fb239fe59c363374adeda8
adityahari95/MachineLearning-HandsON
/Stemming.py
1,474
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 22 11:35:20 2019 @author: 10649929 """ import nltk from nltk.stem import PorterStemmer from nltk.corpus import stopwords paragraph="""I have three visions for India. In 3000 years of our history people from all over the world have come and invad...
5a4558a55bd9337d9b08cfb8cae9bd6fd32c65a8
fortunesd/PYTHON-TUTORIAL
/dictionary.py
1,232
3.828125
4
# A Dictionary is a collection that is unordered, chanagableand indexed. No duplicate member is allowed for this #create a Dictionary person_detail = { 'first_name': 'fortunes', 'last_name': 'onyekwere', 'age': 21 } # Use of a constructor person_details2 = dict(first_name = 'fortunes', last_name='onyekw...
b746c7e3d271187b42765b9bf9e748e79ba29eca
fortunesd/PYTHON-TUTORIAL
/loops.py
792
4.40625
4
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a set, or a string). students = ['fortunes', 'abdul', 'obinaka', 'amos', 'ibrahim', 'zaniab'] # simple for loop for student in students: print(f'i am: {student}') #break for student in students: if student == 'odinaka': ...
ba268ca83e056fe2fc07057d54f1e85018697e27
bangour2/Pyhton-codes-project
/cgi-html-141023/usr/lib/cgi-bin/clubs_sqlite/databaseSqlite.py
3,123
3.859375
4
''' Created on Aug 12, 2013 Database methods for the clubs example @author: Ben ''' import sqlite3 def getConnection(): ''' Return a connection to the database ''' conn = sqlite3.connect('clubs.db') return conn def getPersonById(ident): ''' Return a tuple with data from the p...
6d3f673aad4128477625d3823e3cf8688fc89f2f
CollinNatterstad/RandomPasswordGenerator
/PasswordGenerator.py
814
4.15625
4
def main(): #importing necessary libraries. import random, string #getting user criteria for password length password_length = int(input("How many characters would you like your password to have? ")) #creating an empty list to store the password inside. password = [] ...
2b33a5ed96a8a8c320432581d71f2c46b2a3998a
laufzeitfehlernet/Learning_Python
/math/collatz.py
305
4.21875
4
### To calculate the Collatz conjecture start = int(input("Enter a integer to start the madness: ")) loop = 1 print(start) while start > 1: if (start % 2) == 0: start = int(start / 2) else: start = start * 3 + 1 loop+=1 print(start) print("It was in total", loop, "loops it it ends!")
dfa330f673a2b85151b1a06ca63c3c78214c722e
joq0033/ass_3_python
/with_design_pattern/abstract_factory.py
2,239
4.25
4
from abc import ABC, abstractmethod from PickleMaker import * from shelve import * class AbstractSerializerFactory(ABC): """ The Abstract Factory interface declares a set of methods that return different abstract products. These products are called a family and are related by a hi...
8e5d40347622a1343bd63412cfff36569b59a7ed
rahulrsr/pythonStringManipulation
/reverse_each_word_in_sentence.py
270
3.875
4
def rev_words_in_sentence(statement): stm=statement.split() l=[] for s in stm: l.append(s[::-1]) final_l=' '.join(l) return final_l if __name__ == '__main__': m=input("Enter sentence for processing: ") print(rev_words_in_sentence(m))
1af1818dfe2bfb1bab321c87786ab356f7cff2d4
rahulrsr/pythonStringManipulation
/reverse_sentence.py
241
4.25
4
def reverse_sentence(statement): stm=statement.split() rev_stm=stm[::-1] rev_stm=' '.join(rev_stm) return rev_stm if __name__ == '__main__': m=input("Enter the sentence to be reversed: ") print(reverse_sentence(m))
44a267cf12ea6964c629eb312d8f2dbb0bc1d4fc
kjangeles/CyberSecurityProjects
/SimpleEncryptionProgram/simpleEncryptor.py
649
3.84375
4
#Team Members: Keren Angeles and Kimlong Seng def encrypt(text): result = [] for letter in text: l = ord(letter) - 42069 result.append(l) print("This is your encrypted message: ") for numbers in result: print(numbers, end='') print("", end='') decrypt(result) def de...
590419d3a0fa5cbf2b1d907359a22a0aa7fe92b5
kopelek/pycalc
/pycalc/stack.py
837
4.1875
4
#!/usr/bin/python3 class Stack(object): """ Implementation of the stack structure. """ def __init__(self): self._items = [] def clean(self): """ Removes all items. """ self._items = [] def push(self, item): """ Adds given item at the t...
7458151206849493ec6d11c461e58f3e57fdc41c
sophyphreak/Other
/MIT Class 1/square root.py
998
3.9375
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 2 04:03:21 2017 @author: Andrew """ ans = 0 neg_flag = False x = float(input("Enter an integer: ")) if x < 0: neg_flag = True while ans**2 < x: ans = ans + 1 if ans**2 != x: ans -= 1 while ans**2 < x: ans = ans + .1 if ans**2 != x: ans -= .1 ...
7bab6e6b4d6328d1d7e1f081acc39db79a172371
sophyphreak/Other
/MIT Class 1/hangman2.py
6,495
4.03125
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 6 22:41:15 2017 @author: Andrew """ # Hangman game # # ----------------------------------- # Helper code # You don't need to understand this helper code, # but you will have to know how to use the functions # (so be sure to read the docstrings!) import random WORDLIS...
757507b13da0f5967ffa77a0f44a98384e879042
sophyphreak/Other
/checkio/friends.py
2,168
3.953125
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 1 09:22:30 2017 @author: Andrew """ class Friends: def __init__(self, connections): ''' input: a tuple of sets with two items in each set returns: nothing ''' self.connections = connections ...
1c6f4e5ad0fec2cc8e05afd01ff5bcdefe0ef477
sophyphreak/Other
/MIT Class 1/alphabet challenge.py
2,141
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 1 21:15:27 2017 @author: Andrew """ s = "zyxwvutsrqponmlkjihgfedcba" if (len(s) != 1): alpha = "abcdefghijklmnopqrstuvwxyz" count = 0 alp1 = 0 alp2 = 0 begin = 0 end = 0 ans = "-" for letter in range(len(s)-1):...
7318acc044159b268cf0e54c6dd333da7b403e5e
sophyphreak/Other
/MIT Class 2/Lecture 1 scratchpaper 2.py
3,861
4.21875
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 22 01:31:21 2017 @author: Andrew """ class item(object): def __init__(self, name, value, weight): #create an item with a name, value, and weight self.name = name self.value = value self.weight = weight def getName(self): #r...
e2b92d3846bd3f2ae279893f87da8cc93c1aa59e
sophyphreak/Other
/fucking around/tkinterrrr.py
407
3.609375
4
# -*- coding: utf-8 -*- """ Created on Mon May 15 08:45:03 2017 @author: Andrew """ from tkinter import * top = Tk() L1 = Label(top, text = "Tax Calculator") L1.pack(side = TOP) L2 = Label(top, text = "Tax rate:") L2.pack(side = LEFT) E1 = Entry(top, bd = 4) E1.pack(side = RIGHT) L4 = Label(top, text = "") L4.pack(s...
8887355e340c2dc3f96e53c691ccd9ec138e34d8
sophyphreak/Other
/MIT Class 2/Lecture 2 problem 1.py
1,228
3.875
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 30 11:13:15 2017 @author: Andrew """ def yieldAllCombos(items): """ Generates all combinations of N items into two bags, whereby each item is in one or zero bags. Yields a tuple, (bag1, bag2), where each bag is represented as a list of whic...
2aad357016ad9d363ea5c2f52da24fcd4b1a84f6
sophyphreak/Other
/MIT Class 1/problem set 2 exercise 3.py
2,372
3.734375
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 3 04:43:48 2017 @author: Andrew """ # -*- coding: utf-8 -*- """ Created on Fri Feb 3 03:31:42 2017 @author: Andrew """ # round(number[, ndigits]) # (3329, 310) # (4773, 440) # (3926, 360) balance = 4773 annualInterestRate = .2 monthlyInterestRate = annualInterestR...
b94b4ab4bd64d84541e3decd164503daa21bd037
sophyphreak/Other
/checkio/power supply.py
5,311
3.84375
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 1 11:31:22 2017 @author: Andrew """ ''' Input: Two arguments. The first one is the network, represented as a list of connections. Each connection is a list of two nodes that are connected. A city or power plant can be a node. Each city or power plant is a unique s...
ba33a9cab7cde2c44a50016c9743bd72327240e1
hzhang22/hack
/grep-exercises/phone-numbers/gen_numbers.py
4,388
3.6875
4
import random import sys verbose = True numberQuality = 1 def getRandomNumberWithDelim(curNumbers, delim): thisNumber = '' while True: for x in range (1, 11): thisNumber += str(random.randrange(0,10)) if x%3 == 0 and x <=6 and not (numberQuality == 3 and random.uniform(0,1) > .5): thisNumbe...
2b549601aa4c1cea3bcdda541284f8a17a3ce794
Ankur-Bhalla/email_using_smtp
/email_sender.py
1,242
3.578125
4
# Sending Emails with Python using smtplib and email modules. import smtplib from email.message import EmailMessage email = EmailMessage() email['from'] = 'Ankur Bhalla' email['to'] = '<enter receiver email>' email['subject'] = 'You won 1,000,000 dollars!' email.set_content('I am a Python Master!') with smtplib.SMT...
289d459d9e0dda101f443edaa9bf65d2985b4949
YaraBader/python-applecation
/Ryans+Notes+Coding+Exercise+16+Calculate+a+Factorial.py
604
4.1875
4
''' Create a Factorial To solve this problem: 1. Create a function that will find the factorial for a value using a recursive function. Factorials are calculated as such 3! = 3 * 2 * 1 2. Expected Output Factorial of 4 = 24 Factorial at its recursive form is: X! = X * (X-1)! ''' # define the factorial function def fac...
84e848c7b3f7cd20142ce6326a8a5131b1ecacad
YaraBader/python-applecation
/Ryans+Notes+Coding+Exercise+8+Print+a+Christmas+Tree.py
1,956
4.34375
4
''' To solve this problem: Don't use the input function in this code 1. Assign a value of 5 to the variable tree_height 2. Print a tree like you saw in the video with 4 rows and a stump on the bottom TIP 1 You should use a while loop and 3 for loops. TIP 2 I know that this is the number of spaces and hashes for the tre...
241fa0c22d7775e05d937f0008f899fd545e05ad
tweninger/PSHRG
/graph.py
17,528
3.609375
4
import collections import heapq import itertools import random import bigfloat import treewidth PSEUDOROOT = 'multi-sentence' class Graph(object): """ This data structure does triple duty. It is used for: - semantic graphs - tree decompositions - derivation forests """ ...
1f014e718e7b15d05fbb0c55f2b1819f825bc0d8
gl59789/python_study
/example001.py
22,756
3.921875
4
def print_monthly_expense(month, hours): monthly_expense = hours * 0.65 print("In " + month + " we spent: " + str(monthly_expense)) print_monthly_expense("June", 243) print_monthly_expense("July", 325) print_monthly_expense("August", 298) def rectangle_area(base, height): area = base * height # the ar...
6f6873cf62a86040fb752a52e0107a03e87819cf
gl59789/python_study
/test.py
1,743
4.03125
4
#!/usr/bin/env python3 import csv import datetime import requests FILE_URL="http://marga.com.ar/employees-with-date.csv" def get_start_date(): """Interactively get the start date to query for.""" print() print('Getting the first start date to query for.') print() print('The date must be greater t...
7484545ad36c3a3f69a2e4ba23d0d560341ea08d
PseudoMera/Universal_Translator
/test_translator.py
1,876
3.5
4
import unittest import universal_translator class UniversalTranslatorTest(unittest.TestCase): '''Raises file not found error if the given file route is empty''' def test_empty_file_route(self): universe = universal_translator.UnitsTranslator('') with self.assertRaises(FileNotFoundError): ...
aa82a8532d95a78f041a29fdc44b655f056674a7
yanni-kim/python-
/Ex 06_27.py
4,150
3.859375
4
# x=10 # for i in range(x):#10번만큼 #횟수반복? # print(x)#10 # while x>10:#조건반복문 # # 주석 ctrl + / # # 전체주석 - 범위 설정 '''''' # for index in range(8): # #range(start=0,stop,step=1) # 1 2 3 # print(list(range(6))) #[0, 1, 2, 3, 4, 5] # # print(list(range(1,6))) #[1, 2, 3, 4, 5] # print(list(range(1,10))) #[1, 2, 3, 4,...
7970208b9889a001dbb9fecceaf5a765ceb8b46f
jdurbin/sandbox
/python/basics/scripts/dictionary.py
177
3.53125
4
#!/usr/bin/env python m = {'foo':40,'bar':9000,'killroy':100000} print m['bar'] s = set() s.add('foo') s.add('foo') s.add('bar') print s print 'foo' in s print 'mary' in s
e3c8b5241b67c829edc0b1ff4da04dd6e764a89a
jdurbin/sandbox
/python/basics/scripts/lists.py
738
4.15625
4
#!/usr/bin/env python import numpy as np a = [1,2,3,4] print a print a[2:5] # omitted in a slice assumed to have extreme value print a[:3] # a[:] is just a, the entire list print "a[:-1]",a[:-1] print "a[:-2]",a[:-2] #numpy matrix: # Note that [,] are lists, but (,) are tuples. # Lists are mutable, tuples are ...
9ade768d14ed30852d93b3394fae8d5b7a1ac68d
jdurbin/sandbox
/python/basics/scripts/classtest.py
685
3.890625
4
#!/usr/bin/env python #import SuperClass # OK.. I think there is not a 1-1 correspondence between modules (files) and classes. # So import SuperClass just means to import the file/module. # If you want to import the class SuperClass from the file SuperClass, you need something like: from SuperModule import SuperClas...
90fe75d8eb2eb8f8b2b4e105013c7f32baed9c3f
rowaishanna/DS-Unit-3-Sprint-2-SQL-and-Databases
/northwind.py
2,055
3.78125
4
import os import sqlite3 # construct a path to wherever your database exists DB_FILEPATH = os.path.join(os.path.dirname(__file__), "northwind_small.sqlite3") connection = sqlite3.connect(DB_FILEPATH) #connection.row_factory = sqlite3.Row # allow us to reference rows as dicts #print("CONNECTION:", connection) cursor = ...
1094b25304b97de57e1e9c940b56afc5945a181d
smileykaur/Travel-Insight
/Travel_Insights-master/src/data_preprocessing.py
5,102
3.546875
4
""" Step 2 : Data aggregation: aggregate data to generate text corpus: This will clean the raw data that was gathered from Reddit - - convert data to format that can be directly consumed by Dataframes, """ import pandas as pd import os from .config import ( AGG_BY_SUB, COMMENTS_COLS, REPLIES_COLS, ) class...
20d2c16838f90918e89bfcf67d7c1f9210d6d39a
vaishu8747/Practise-Ass1
/1.py
231
4.34375
4
def longestWordLength(string): length=0 for word in string.split(): if(len(word)>length): length=len(word) return length string="I am an intern at geeksforgeeks" print(longestWordLength(string))
24000008f2143fa725a07820e546aa038aee31dd
streetracer48/python-sandbox
/variables.py
702
3.84375
4
# A variable is a container for a value , which can be of various types ''' this is a multiline comment ordocstring (used to define a function purpose) can be single or double quotes ''' """ Variable Rules: - Variable names are case sensitive (name and name are different variables) - Must start with a letter or an ...
4d232316edef7a8dbf7ca88c1ffbb53efc179b3d
vineetdcunha/Python
/Ellipse_Area_Circumference.py
1,381
4
4
#Name: Vineet Dcunha #"I have not given or received any unauthorized assistance on this assignment." import math class ellipse_default: 'Creates a default ellipse class to set default parameters, find area and circumference' def __init__ (self,xcoord = 0,ycoord = 0, a = 0, b = 0): 'Creates an el...
c1fa87a3dd6e8f1393793502b206754432756c01
jueqingsizhe66/pyqt
/boobooexam.py
685
3.84375
4
#date :2013-1-18 #author :zhaoliang #function: the way to define class and constructor import sys import os class test(): def _init_(self,name1='test',age1=0): self.name=name1 self.age=age1 def setfun(self,new_name,new_age): self.name=new_name self.age=new_age def getfun(s...
4b19a8766b1202f65463b878b588b7396ec6830d
Ali1422/Working-Calculator
/calculator.py
2,261
4.09375
4
import time print("Welcome to Kala's calculator") while True: print("\nHere are the options") options = input("please enter 1 for addition, 2 for subtraction, 3 for division and 4 for multiplacation") if options == "1" : time.sleep(2) print("\n you have chosen addition") num1...
9c401c9d072f0c164ec7b397102b7c30bffdf507
st3fan/exercism
/python/list-ops/list_ops.py
779
3.765625
4
from functools import reduce def append(list1, list2): return list1+list2 def concat(lists): result = [] for list in lists: result += list return result def filter(function, list): return [v for v in list if function(v)] def length(list): n = 0 for _ in list: n += 1 ...
e0567b807de8d9de78b5b6446648a1738bde2c10
zhl2013/dba_syncer
/sync_mongo2mysql/test.py
1,211
3.921875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/3/16 14:15 # @Author : 马飞 # @File : file_upload.py # @Software: PyCharm # import sys # def is_number(s): # try: # int(s) # return True # except ValueError: # return False # # for line in sys.stdin: # a= line.split() # if...
e4682fe7b4cd8451783216fefea81cd111674f90
nadiia-tokareva/skillup
/lesson 3-9/3.py
1,314
3.9375
4
class Money: def __init__(self, name= None, symbol= None ): self.kind = '' self.name = name self.symbol = symbol def __str__(self) -> str: return f'The {self.name} is {self.kind} money and has symbol {self.symbol}' def money_type(self): return self.kind de...
2a2cecc407c7a7437dd75c7e154d18bdfa620ccd
kishorebiyyapu/Guvi-practice2
/prog122.py
432
3.59375
4
a,b,c=input().split('-') if b=='01': print("January") elif b=='02': print("Febrary") elif b=='03': print("March") elif b=='04': print("April") elif b=='05': print("May") elif b=='06': print("June") elif b=='07': print("July") elif b=='08': print("August") elif b=='09': print("Septemb...
09add573ddc4e808dcd768f8172487cb8acd36aa
josevictor1/CC
/Parte_1/codigos/micro04.py
299
3.65625
4
def micro04(): x = 0 num = 0 intervalo = 0 for x in range(5): print("Digite o numero: ", end = "") num = int(input()) if num >= 10: if num <= 150: intervalo = intervalo +1 print("Ao total, foram digitados "+str(intervalo)+" numeros no intervalo entre 10 e 150") micro04()
7462b7bb66c8da8ec90645eb00a654c316707b28
matheus-hoy/jogoForca
/jogo_da_forca.py
1,154
4.1875
4
print('Bem Vindo ao JOGO DA FORCA XD') print('Você tem 6 chances') print() palavra_secreta = 'perfume' digitado = [] chances = 6 while True: if chances <= 0: print('YOU LOSE') break letra = input('Digite uma letra: ') if len(letra) > 1: print('Digite apenas uma letra Mal...
d68850ca68e9d5d44b73956a58639a0a8ea8495e
samh99474/Python-Class
/pythone_classPractice/week3/Week3_Quiz_106360101謝尚泓/quiz4.py
885
3.796875
4
def main(): global grid_size global row_sign global col_sign row_sign = "-" col_sign = "|" print("Quiz 4") row_num = int(input("Numbers of rows:")) col_num = int(input("Numbers of colum:")) grid_size = int(input("Grid size:")) row_sign = row_sign*grid_size for i in rang...
16943c73ad58d206b2f4f13467ab0cc48f95596d
samh99474/Python-Class
/pythone_classPractice/week6(object)/download/Week6_Quiz_106360101謝尚泓/AddStu.py
1,978
3.875
4
class AddStu(): def __init__(self, student_dict): self.student_dict = student_dict def execute(self): try: print("新增學生姓名和分數") name = str(input(" Please input a student's name: ")) subject = "" score = 0 while subject != "exit": ...
c3d5f8a11f3eab94634fa09ff7a04d5eea1ff3fd
samh99474/Python-Class
/pythone_classPractice/week13_14(pyqt5_switch_widget_moreWidget)/Week13_Quiz_106360101謝尚泓/Server/DB/StudentInfoTable.py
1,640
3.53125
4
from DB.DBConnection import DBConnection class StudentInfoTable: def insert_a_student(self, name): command = "INSERT INTO student_info (name) VALUES ('{}');".format(name) with DBConnection() as connection: cursor = connection.cursor() cursor.execute(command) ...
3759b8b6d79be99ad7f3c65377f3424e3ba5d723
minjekang/Python_Study
/Python/Set.py
591
3.53125
4
# 집합 (set) # 중복 안됨, 순서 없음 my_set = {1,2,3,3,3} print(my_set) java = {"강민제", "나", "너"} python = set(["강민제", "유시온"]) # 교집합 (java와 python 모두 가능) print(java & python) print(java.intersection(python)) # 합집합 (java도 할 수 있거나 python 을 할수있는) print(java | python) print(java.union(python)) # 차집합 (java는 할 수 있거나 python 은 못하는)...
d606dea2a9da437609814862b06990ff4aa5e293
minjekang/Python_Study
/Python/Practice.py
2,561
3.671875
4
# # 자료형 # print(5) # print(-10) # print(3.14) # print(1000) # print (5+3) # print(2*8) # print(3*(3+1)) # # 문자열 # print('풍선') # print("나비") # print("ㅋㅋㅋㅋㅋㅋ") # print("ㅋ"*9) # # 참 / 거짓 # print(5>10) # print(5<10) # print(True) # print(False) # print(not True) # print(not False) # print(not(5 > 10)) # # 변수 # # 애완...
894abe59b869794b4a35903f04a750b1f9ee5788
brianbrake/Python
/ComputePay.py
834
4.3125
4
# Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay # Award time-and-a-half for the hourly rate for all hours worked above 40 hours # Put the logic to do the computation of time-and-a-half in a function called computepay() # Use 45 hours and a rate of 10.50 per hour to ...
4d1563e0ddbaa33a256eccac986f55d6e8cf265c
Ryuodan/Network-Routering-Simulation
/main.py
1,036
3.59375
4
import pygame from program import Program WIDTH=1024 HEIGHT=768 GREY=(210, 210 ,210) FPS=60 BACKGROUND_COLOR=GREY #GREY TITLE='ROUTING NETWORK SOFTWARE' pygame.init() def main(): #window information font = pygame.font.Font(None, 32) pygame.display.set_caption(TITLE) screen = pyga...
3a3ee184db496396981388e6ca1c285d23c3a9b8
Bill-Fujimoto/Intro-to-Python-Course
/4.3.4 CodingExercise3.py
3,440
4.40625
4
#Last exercise, you wrote a function called #one_dimensional_booleans that performed some reasoning #over a one-dimensional list of boolean values. Now, #let's extend that. # #Imagine you have a two-dimensional list of booleans, #like this one: #[[True, True, True], [True, False, True], [False, False, False]] # #Notice...
10bc6efce944ab2eb5480caa0f8a9c8f53041e5d
Bill-Fujimoto/Intro-to-Python-Course
/Coding Problem 4.5.6.py
3,342
4.28125
4
#This is a challenging one! The output will be very long as #you'll be working on some pretty big dictionaries. We don't #expect everyone to be able to do it, but it's a good chance #to test how far you've come! # #Write a function called stars that takes in two #dictionaries: # # - movies: a dictionary where the keys ...
26a172a959b18ab2384ff72573c464652f6cfb26
Bill-Fujimoto/Intro-to-Python-Course
/5.2.3 Worked Example2_Fibonacci.py
3,668
4.5625
5
#Let's implement the Fibonacci function we saw in the #previous video in Python! # #Like our Factorial function, our Fibonacci function #should take as input one parameter, n, an integer. It #should calculate the nth Fibonacci number. For example, #fib(7) should give 13 since the 7th number in #Fibonacci's sequence is ...
22ceb4fdbf728776340db36a64e54be289bef089
Bill-Fujimoto/Intro-to-Python-Course
/Coding Problem 4.4.5.py
3,630
4.1875
4
#Write a function called get_grade that will read a #given .cs1301 file and return the student's grade. #To do this, we would recommend you first pass the #filename to your previously-written reader() function, #then use the list that it returns to do your #calculations. You may assume the file is well-formed. # #A stu...
74c1a177115b9dd2e3b519e0581e1605814ef499
oschre7741/my-first-python-programs
/geometry.py
1,285
4.1875
4
# This program contains functions that evaluate formulas used in geometry. # # Olivia Schreiner # August 30, 2017 import math def triangle_area(b,h): a = (1/2) * b * h return a def circle_area(r): a = math.pi * r**2 return a def parallelogram_area(b,h): a = b * h return a ...
f58316ee96300c1b5e2dbd551a40c34131dac1de
PMardjonovic/InvoiceGUI
/views/calendar_view/main_header.py
1,020
3.640625
4
import tkinter as tk import calendar as cl class MainHeader(tk.Frame): def __init__(self, parent, controller, month, year, *args, **kwargs): # Call parent init tk.Frame.__init__(self, parent, *args, **kwargs) # Header displays month,year being currently displayed header_font = ("H...
153fbbfa4fd67c9cf4da273780fdd730aa6dd2d9
xystar2012/vsCodes
/PyCodes/PyQt5/basicdataType/queueOp.py
1,493
3.765625
4
#--*-- coding:utf-8 --*-- from random import randint from time import ctime from time import sleep import queue import threading class MyTask(object): def __init__(self, name): self.name = name self._work_time = randint(1, 5) def work(self): print("Task ...
cf918de06e0226a8d1d63f2ed10843aa572be889
xircon/Scripts-dots
/appjar/turt.py
310
3.625
4
# get the library import turtle import os wind = turtle.Screen() t = turtle.Turtle() # draw a square for loop in range(4): t.forward(100) t.right(90) t.home() yy = 10 for loop in range(100): t.dot ( yy,"cyan") yy=yy+5 t.home() t.write("Finished - click window to close") wind.exitonclick ( )
21302bc9e0310c4ea221a03de8847cd285f4d532
Adrian-Bravo/TallerBD
/Clase02/ejercicio3.py
250
3.5625
4
from library.modulos import num_perfecto def principal(): numero = int(input("Digite un numero: ")) if num_perfecto(numero): print("Es perfecto") else: print("No es perfecto") if __name__ == "__main__": principal()
6168ffa995d236e3882954d9057582a5c130763a
ghinks/epl-py-data-wrangler
/src/parsers/reader/reader.py
2,129
4.15625
4
import re import datetime class Reader: fileName = "" def __init__(self, fileName): self.fileName = fileName def convertTeamName(self, name): """convert string to upper case and strip spaces Take the given team name remove whitespace and convert to uppercase """ ...
f58c6f1c77b620906ebf67b72ca4c0e51139c689
jeffreymoon/MLearning
/PolynomialRegression.py
1,293
3.546875
4
# %% import numpy as np import matplotlib.pyplot as plt m = 100 X = 6 * np.random.rand(m, 1) - 3 y = 2 + X + 0.5 * X**2 + np.random.randn(m, 1) plt.plot(X, y, 'r.') plt.show() # %% from sklearn.preprocessing import PolynomialFeatures from sklearn.linear_model import LinearRegression poly_features = PolynomialFeatur...
a3f22bb6a8225ca7ad16589b0fe0a01d37c8d616
sh92/Online-Judge-Code
/leetcode/L874.py
3,271
4.0625
4
class MyCircularQueue: def __init__(self, k): """ Initialize your data structure here. Set the size of the queue to be k. :type k: int """ self.mylist = [0 for i in range(k)] self.maxSize = k self.size = 0 self.front = 0 self.rear = 0 ...
1e5c8ec60b8902f8d0769d91a11ce208bdf1f447
EaglesRoboticsTeam/ReceitaV1
/touch.py
2,271
3.5
4
import time # import the time library for the sleep function import brickpi3 # import the BrickPi3 drivers BP = brickpi3.BrickPi3() # Create an instance of the BrickPi3 class. BP will be the BrickPi3 object. BP.set_sensor_type(BP.PORT_1, BP.SENSOR_TYPE.TOUCH) # Configure for a touch sensor. If an EV3 touch senso...
2062c1161c2a14fcb99176f6d701f698d7940a5f
cheriezhang/LCode
/TowardOffer/22-verifySquenceOfBST.py
1,577
3.59375
4
# -*- coding:utf-8 -*- # 题目描述 # 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。 # 如果是则输出Yes,否则输出No。 # 假设输入的数组的任意两个数字都互不相同。 # 后序遍历: 左右根? # 二叉搜索树: 空树或者 # 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; # 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; # 测试用例: 5,7,6,9,10,11,8 # 最后一个是根节点 比根节点大的是右子树,比根节点小的是左子树 def VerifySquenceOfBST(sequence): if len(sequence) ==...
c6b5a92838a6826922be0740bdc360b0792d9c04
cheriezhang/LCode
/TowardOffer/24-Clone.py
2,250
3.671875
4
# -*- coding:utf-8 -*- # 题目描述 # 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点, # 另一个特殊指针指向任意一个节点), # 返回结果为复制后复杂链表的head。 # (注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空) class RandomListNode: def __init__(self, x): self.label = x self.next = None self.random = None class Solution: # 返回 RandomListNode ...
d9a7aa1391d393fa00c33b1c3dc1ceb19a97d5bb
rokitka007/PytPoz03-doUsuniecia
/obiektowosc/Car.py
976
3.78125
4
class Car(): def __init__(self, brand, model, year=2000): self.brand = brand self.model = model self.year = year self.velocity = 0 def presentCar(self): message = "{} {} created in {}".format(self.brand, self.model, self.year) if 2019-self.year >= 20: ...
9347651ce97a9a8deebf1d438ff7a753774fbeb9
4nu81/examen
/Quellcode/Log.py~
1,078
3.609375
4
class Log: """ logt die einzelnen Simulationsschritte in LogSpiel """ def __init__(self): """ Constructor """ self.LogSpiel = [] def LogZug(self, spieler, before, after): """ logt sich einen Spielzug. Die Anzahl der Spielzüge ist g...
64029fb960b2cf5985cf2c2a8d7cc7fdd48a0f3c
biam05/FPRO_MIEIC
/pe's/pe1-2/question5.py
223
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 3 22:23:25 2019 @author: biam05 """ dec = int(input('Decimal number (base 10):')) final = '' while dec > 0: final += str(dec % 2) dec = dec // 2 print(final[::-1])
d5748848d4bba68f90e4fe2e78eeb8b1e7ca9651
biam05/FPRO_MIEIC
/exercicios/RE04 Conditionals and Iteration/triangle(2).py
525
3.75
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 26 14:42:58 2018 @author: biam05 """ n1 = int(input("Size 1: ")) n2 = int(input("Size 2: ")) n3 = int(input("Size 3: ")) if n1 <= (n2 + n3) or n2 <= (n1 + n3) or n3 <= (n1 + n2) or n1 < 0 or n2 < 0 or n3 < 0: result = str("Not a triangle") else: if n1 == n2 and ...
ce8eafa856f062c4a15f773cd07cd837eaf4a177
biam05/FPRO_MIEIC
/pe's/pe1-1/question4.py
474
3.65625
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 3 21:46:03 2019 @author: biam05 """ tS = float(input('Swimming time:')) tC = float(input('Cycling time:')) tR = float(input('Running time:')) if tS + tC + tR >= 4: print('Time') else: if 1.5 / tS < 2: print('Swimming') else: if 40/tC < 20: ...
d8d328d0cc735abb7671d74ea4440e4467646b55
biam05/FPRO_MIEIC
/exercicios/RE12/parse.py
442
3.609375
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 23 16:26:15 2018 @author: biam05 """ def parse(filename): from ast import literal_eval as l_eval file = open(filename, 'r') content = file.read() content = content.split() contstr = '' for i in range(len(content)): if content[i][0] != '(':...
8f178542befde45bd673362d8dc469a19016bd18
biam05/FPRO_MIEIC
/exercicios/RE04 Conditionals and Iteration/triangle.py
1,203
3.84375
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 17 21:46:12 2018 @author: biam05 """ # # DESCRIPTION of exercise 4: # # Write a program that checks if a triangle is equilateral, isosceles or scalene, # with the 3 sides provided by the user, each one in different an input() statement. # See Google Docs for imp...
ce63daf21fdbd6dff7784d83eb6ccfc3b3d54d32
biam05/FPRO_MIEIC
/exercicios/RE02 Simple data/cast.py
235
3.734375
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 25 17:12:31 2018 @author: biam05 """ n = int(input("n = ")) nn = str(n) + str(n) nnn = str(n) + str(n) + str(n) expression = n + int(nn) + int(nnn) print("n + nn + nnn =", expression)
3e0567d81aa20bf04a43d2959ae3fff8b71501ec
biam05/FPRO_MIEIC
/exercicios/RE05 Functions/sumNumbers.py
955
4.34375
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 24 11:47:09 2018 @author: biam05 """ # # DESCRIPTION of exercise 2: # # Write a Python function sum_numbers(n) that returns the sum of all positive # integers up to and including n. # # For example: sum_numbers(10) returns the value 55 (1+2+3+. . . +10) # # Do N...
efec0a1054842d2fc586b9d5606784ad1009327b
biam05/FPRO_MIEIC
/exercicios/RE11/override.py
474
3.8125
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 11 10:44:03 2018 @author: biam05 """ def override(l1, l2): # new_list = [] # first_l2 = [l2[k][0] for k in range(len(l2))] # for i in range(len(l1)): # if l1[i][0] not in first_l2: # new_list.append(l1[i]) # return sorted(l2 + new_list, key ...
47f6f18ce5244de5980f05a07aaddfe28ef2e020
biam05/FPRO_MIEIC
/pe's/pe1-1/question5.py
233
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 3 21:52:38 2019 @author: biam05 """ dec = int(input('Decimal number (base 10):')) result = '' while dec > 0: result += str(dec%8) dec = dec//8 print(result[::-1])
5e0efb6d9833e39945641587a362f1a25a880b1b
biam05/FPRO_MIEIC
/exercicios/RE04 Conditionals and Iteration/concatenate(2).py
415
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 26 14:52:15 2018 @author: biam05 """ n1 = int(input("Number 1: ")) n2 = int(input("Number 2: ")) x = n1 y = n2 i = 0 result = 0 while y > 0: y = y % 10 result += (y*(10**(i))) y = n2 - result y = y / (10**(i)) i += 1 while x > 0: x = x % 10 res...
879343e31343bffa2623c9b72008dfcec0cedbcf
biam05/FPRO_MIEIC
/exercicios/RE04 Conditionals and Iteration/prime(2).py
309
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 26 08:35:26 2018 @author: biam05 """ n = int(input("Integer: ")) divisor_list = [] for i in range (1, n+1): if (n % i) == 0: divisor_list.append(i) if len(divisor_list) == 2: result = True else: result = False print(result)
e5bd2a104b7653dfdbdbea151f76197a2c191919
biam05/FPRO_MIEIC
/pe's/pe3/evaluate.py
155
3.59375
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 4 14:35:30 2019 @author: biam05 """ def evaluate(a, x): return sum(ai*x**e for e, ai in enumerate(a))
7e500b566439384504736f7ea2b7193119ac8080
mewhite/SwingCopters
/player.py
1,329
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 01 18:04:22 2015 @author: Nolan """ import pygame from pygame import transform import math class Player: height = 80 width = 80 image = transform.scale(pygame.image.load("orange_square.png"), (width, height)) def __init__(self, starting_position, accele...
bc6927f7570592cb9fa8313ab91bf9381d7b49f1
Gavinee/Leetcode
/055 跳跃游戏.py
938
4
4
""" 给定一个非负整数数组,你最初位于数组的第一个位置。 数组中的每个元素代表你在该位置可以跳跃的最大长度。 判断你是否能够到达最后一个位置。 示例 1: 输入: [2,3,1,1,4] 输出: true 解释: 从位置 0 到 1 跳 1 步, 然后跳 3 步到达最后一个位置。 示例 2: 输入: [3,2,1,0,4] 输出: false 解释: 无论怎样,你总会到达索引为 3 的位置。但该位置的最大跳跃长度是 0 , 所以你永远不可能到达最后一个位置。 """ __author__ = 'Qiufeng' class Solution: def canJump(self, nums): ""...
6e01d7745ab0f7d407b8716aed703579878abdcf
Gavinee/Leetcode
/006 Z字形变换.py
3,195
3.890625
4
""" 将字符串 "PAYPALISHIRING" 以Z字形排列成给定的行数: P A H N A P L S I I G Y I R 之后从左往右,逐行读取字符:"PAHNAPLSIIGYIR" 实现一个将字符串进行指定行数变换的函数: string convert(string s, int numRows); 示例 1: 输入: s = "PAYPALISHIRING", numRows = 3 输出: "PAHNAPLSIIGYIR" 示例 2: 输入: s = "PAYPALISHIRING", numRows = 4 输出: "PINALSIGYAHRPI" 解释: P I ...
8a89be31e992269795d379cf5fff80c55b2ff78e
Gavinee/Leetcode
/070 爬楼梯.py
1,754
3.875
4
""" 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 示例 1: 输入: 2 输出: 2 解释: 有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶 示例 2: 输入: 3 输出: 3 解释: 有三种方法可以爬到楼顶。 1. 1 阶 + 1 阶 + 1 阶 2. 1 阶 + 2 阶 3. 2 阶 + 1 阶 """ __author__ = 'Qiufeng' # 超时程序(递归形式) class Solution(object): ...
ad3bea526fb841fdbbaa4dc1d541f38fc85fad22
Gavinee/Leetcode
/617 合并二叉树.py
1,396
3.984375
4
""" 给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。 你需要将他们合并为一个新的二叉树。合并的规则是如果两个节点重叠,那么将他们的值相加作为节点合并后的新值,否则不为 NULL 的节点将直接作为新二叉树的节点。 示例 1: 输入: Tree 1 Tree 2 1 2 / \ / \ ...
73219c63946768b4458c9c4c9f30639a83829d19
AndyLaneOlson/LearnPython
/Ch3TurtleShapes.py
863
4.28125
4
import turtle #Set up my turtle and screen wn = turtle.Screen() myTurtle = turtle.Turtle() myTurtle.shape("turtle") myTurtle.speed(1) myTurtle.pensize(8) myTurtle.color("blue") myTurtle.penup() myTurtle.backward(400) myTurtle.pendown() #Make the turtle do a triangle for i in range(3): myTurtle.forward(100) myT...
1064355cabd4ecae5a0dcc2bef35f13179a16f56
pallavasija/inboxspammer
/inboxspammer.py
901
3.59375
4
#InboxSpammer (Python) #Importing SMTP library import time import smtplib #Specifying the From and To addresses toadd = raw_input("Enter email address of the recipient [to]: ") #Login credentials uname = raw_input ('Enter your GMAIL username: ') pwd = raw_input ('Enter your GMAIL password: ') #Asking the user fo...
c0994074084e337bba081ca44c37d2d4d8553f8f
xtom0369/python-learning
/task/Learn Python The Hard Way/task33/ex33_py3.py
368
4.15625
4
space_number = int(input("Input a space number : ")) max_number = int(input("Input a max number : ")) i = 0 numbers = [] while i < max_number: print(f"At the top i is {i}") numbers.append(i) i = i + space_number print("Numbers now: ", numbers) print(f"At the bottom i is {i}") print("The ...
e8551cb6543a8640c548e40d1206dd987c7635ad
ashutoshpandey1710/PythonFun
/deepestodd.py
563
3.609375
4
from tree import readTreeFromFile def deepestOdd(tree, level=1): if (not tree[1]) and (not tree[2]): if level % 2 == 1: return level, tree[0] else: return -1, None leftmax, leftnode = -1, None if tree[1]: leftmax, leftnode = deepestOdd(tree[1], level + 1) rightmax, rightnode = -1, None if tree[2]: ...