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
69486188208a77d18dcda672cfcd0f8718285f98
ethankoch4/trifles
/trifles/data_structures/singly_linked_list.py
2,242
3.75
4
'''Singly Linked List in Python. ''' class SinglyLinkedList: '''Native Python Class for implementing a Generic Singly Linked List. ''' def __init__(self): '''Instantiate a SinglyLinkedList with None root. __Returns__ ---- - (SinglyLinkedList): Instantiated SinglyLinkedLis...
8f21f4a118e03134b5fd1091a9610d6b79c3a751
Sandy4321/cython_lstm
/cython_lstm/layers/recurrent_layer.py
5,416
3.53125
4
""" Recurrent Neural Network Layer ------------------------------ Missing: LSTM, Recursive Gated, Language Models, Hierachical Softmax """ from .temporal_layer import TemporalLayer, quadratic_form from .layer import Layer import numpy as np REAL = np.float32 class RecurrentLayer(TemporalLayer): """ Recurrent...
e4e64380ef8f07a9556d4d0ae75492d24e7732ee
leifoo/lc-all-solutions
/061.rotate-list/0061_rotate-right.py
589
3.5
4
class ListNode: def __int__(self, x): self.val = x self.next = None class Solution: def rotateRight(self, head: ListNode, k: int) -> ListNode: if not head: return cur = head size = 1 while cur.next: size += 1 cur = cur.next...
15feb9b44891a01097a25bb203c8e5deef9bc618
prashantramnani/ai_games
/game.py
7,402
3.78125
4
import sys import pygame import numpy as np import random black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) green = (0, 255, 0) blue = (0, 0, 255) screenSize = width, height = 500, 500 ######################################################################3 def drawSnake(snake, screen): for l in s...
dbd856336c8f7e2e724e9b50c81494b3ca3a7771
tmjnow/Go-Python-data-structures-and-sorting
/Datastructures/queue/queue.py
1,054
4.28125
4
''' Implementation of queue using list in python. Operations are O(1) `python queue.py` ''' class Queue(): def __init__(self): self.items = [] def is_empty(self): return self._is_empty() def enqueue(self, item): self._enqueue(item) def dequeue(self): return self._d...
12a571a5d1341ee990bad27a11fa00623f87e44d
NumeroUno11/Loops-and-Functions
/loopfunctions.py
2,484
3.78125
4
import random database = {} def init(): isValidOptionSelected = False print("Welcome to bankPB") while isValidOptionSelected == False: haveAccount = int(input("Do you have an account with us: 1 (Yes) 2 (No) \n")) if(haveAccount == 1): isValidOptionSe...
dfbce0a39ce2d2c88301968b6b59024e8e89cc9d
thaycacac/kids-dev
/PYTHON/lv1/chapter3/exercise2.py
134
4.09375
4
number = int(input('Enter number: ')) if (number >=1 and number <=100): print('OK') else: print('Number is not between 1 and 100')
ec823610ba821cd62f067b8540e733f46946de34
thaycacac/kids-dev
/PYTHON/lv2/lesson1/exercise2.py
463
4.15625
4
import random number_random = random.randrange(1, 100) numer_guess = 0 count = 0 print('Input you guess: ') while number_random != numer_guess: numer_guess = (int)(input()) if number_random > numer_guess: print('The number you guess is smaller') count += 1 elif number_random < numer_guess: print('The...
0b08b132e35d60538813d9a86792c47144398689
thaycacac/kids-dev
/PYTHON/lv1/chapter4/excercise2.py
104
4.125
4
number = int(input('Enter number: ')) sum = 0 for i in range(number + 1): sum += i print('sum: ', sum)
2731e074d0054460fc05f4a63816c6585e0ec2ee
thaycacac/kids-dev
/PYTHON/lv1/chapter6/exercise2.py
646
3.84375
4
from random import * number_random = 0 count_wrong = 0 while True: for i in range(5): if(count_wrong == 0): number_random = randint(1, 300) guess = int(input('Enter number: ')) if(number_random == guess): print('You have correctly predicted the number ', number_random) elif(number_rando...
bdf300647124a738954bac75fc91f2df46608a4f
AronU/Car-Rental-Service
/Car_Rental/models/Customer.py
796
3.75
4
class Customer: def __init__(self, name, ssn, address, phone, birthday): self.__name = name self.__ssn = ssn self.__address = address self.__phone = phone self.__birthday = birthday def __str__(self): return "{},{},{},{},{}".format(self.__name, self.__ssn, ...
8a7ead024d61d0808c71c9bcd754c52e68a70569
AronU/Car-Rental-Service
/Car_Rental/repositories/CustomerRepo.py
4,544
3.796875
4
# This gives the class in this file access to the Customer class which is stored in the models folder. from models.Customer import Customer # This imports the CSV module, which includes all the necessary built-in functions, and allows this file(the class) to parse CSV files. import csv import os class CustomerReposito...
ffaee931ae4b5c111d498250e6ca42c61e7ebe91
AronU/Car-Rental-Service
/Car_Rental/ui/order_func.py
11,464
3.515625
4
# Gets acces to the printline funcson in the Universal_func named un_func in the code # All over the place in the ui from ui.Universal_func import printer, printline, date_chack import ui.Universal_func as un_func # Gets access to the OrderService class in the services folder. Used to get the available order lists. fro...
f2a3b9531e8ee76e618b7777d315a323109c07cf
shankarveruva/Projects
/Python/Calculate Nerd Score and Nerd Class/nerdScore.py
6,270
4.03125
4
# Author: Shankar Veruva # Date: 24th March 2019 # Functionality: cailculate the skill score by the equation # x, y, z are inputs def calculateSkillEquation(FandomScore, HobbiesScore, SportsNum): skillScore = 0 # intialize the output list # Please write your own program here # Importing math...
011d9ac704c3705fd7b6025c3e38d440a30bf59a
Saskia-vB/Eng_57_2
/Python/exercises/108_bizzuuu_exercise.py
1,540
4.15625
4
# Write a bizz and zzuu game ##project user_number= (int(input("please enter a number"))) for i in range(1, user_number + 1): print(i) while True: user_number play = input('Do you want to play BIZZZUUUU?\n') if play == 'yes': user_input = int(input('what number would you like to play to?\n')) for num ...
b572d0bda55a6a4b9a3bbf26b609a0edc026c0a3
Saskia-vB/Eng_57_2
/Python/dictionaries.py
1,648
4.65625
5
# Dictionaries # Definition and syntax # a dictionary is a data structure, like a list, but organized with keys and not index. # They are organized with 'key' : 'value' pairs # for example 'zebra' : 'an African wild animal that looks like a horse but has black and white or brown and white lines on its body' # This mean...
46d3046ffaeb7a4e7fe4617c4019bd8c9223dfdc
Amitaajay/Cipher-text
/code.py
578
3.6875
4
import sys check=sys.version if check.startswith("3"): value=int(input("Enter the offset: \n")) emsg=input("Enter the encoded message: \n") else: value=int(raw_input("Enter the offset: \n")) emsg=raw_input("Enter the encoded message: \n") omsg="" for c in emsg: if c.isupper(): n = ord(c) - ...
eddf5bc2602f8ea91c4819a84a851df8e91554c0
m09902004/Python-Learning
/30_exercise/30_exercise_08 (20190814).py
2,495
3.890625
4
# -*- coding: utf-8 -*- ''' 猜撲克牌。 ver.87 ''' #結構主體 def main(): choice = 'y' while choice.lower() == 'y': display_menu() point=get_goal() check_value(point) choice = input('''(」・ω・)」再一次!(/・ω・)/再一次!(y/n) : ''') input('\nO~ K~ Bye~ _(:з」∠)_') print('\014') #判斷大小 def check_value(...
4135065012aa3c5e0ac2e45c94b9cd3451e3f750
m09902004/Python-Learning
/30_exercise/30_exercise_18 (20190822).py
843
3.90625
4
# -*- coding: utf-8 -*- """ column 國語 數學 英文 自然 社會 row 小林 小黃 小陳 小美 ver.1 """ #匯入 pandas import pandas as pd #建立資料 grade = {'':['小林','小黃','小陳','小美'], '國語':[75,91,71,69], '數學':[62,53,88,53], '英文':[85,56,51,87], '自然':[73,63,69,74], '社會':[60,65,87,70]} #將各df建立為變數 grade_data = pd.DataFrame(grade) last_2 ...
d021f007fb8158367d40588bc52d34b313422d60
m09902004/Python-Learning
/30_exercise/30_exercise_06 (20190813).py
1,011
3.84375
4
# -*- coding: utf-8 -*- """ a符號 b欄數 c列數 ver.6 """ #結構主體 & 結果輸出 def main(): choice = 'y' while choice.lower() == 'y': display_menu() a=input('請輸入任意符號 : ') b=get_value() c=get_value() print() show(a,b,c) choice = input('''(」・ω・)」超好看!(/・ω・)/再一次!(y/n) : ''') print('\nO~ K...
22906c17833ea83e389aafe6d46ded13da763b57
ryannevares/RGB-HEX-Converter
/RGB-HEX-FINAL.py
4,755
4.21875
4
""" Author: Ryan Nevares Date: 30 October 2017 Title: RGB/HEX Converter Version 2.0 This is a program to interconvert RGB and HEX values. This program will run until the user intentionally stops it and will work using bitwise operators. """ from time import sleep from sys import stdout from textwrap import fill def ...
e1fb0850267815f2f8735e1d1f989e81f7c549f9
alveraboquet/Class_Runtime_Terrors
/Students/ian/py_labs/lab_rot/lab_rot.py
359
3.796875
4
""" ROT Cipher """ def rot(m, rotn=13): lm = [] for l in m.lower().strip(): lm.append(chr((ord(l) - 97 + rotn) % 26 + 97)) return "".join(lm) def main(): word = input("enter a word to process: ") rotn = int(input("enter the amount of rotation or enter for 13: ") or "13") ret = rot(word...
50267043f45f8de28b92e20697a088e45affb1ad
alveraboquet/Class_Runtime_Terrors
/Students/leon/lab_09/lab09_ver4.py
1,059
4.03125
4
# PDX Fullstack Week One Lab One Ver.2 def main(): # conversion data conv = { 'ft': 0.3048, 'mi': 1609.34, 'm': 1, 'km': 1000, 'yd': 0.9144, 'in': 0.0254 } # get user input for some number x of units x = input("HWhat is the distance? ") x = float(...
5d7bf667650a9536790ed75623c9bca6a7c58eed
alveraboquet/Class_Runtime_Terrors
/Students/tom/tic_tac_toe/tic_tac_toe-1.py
6,050
3.9375
4
class Player : def __init__(self, name , token): self.name = name self.token = token def display (self): s ="It Your Turn " + str(self.name) return s # class Game(Player): # def __init__(self, name, token, board): # super().__init__(length, width) # self.board...
001985d0dc236a357b5e06d509b9af04f8e6ace0
alveraboquet/Class_Runtime_Terrors
/Students/Ted/lab6_password_generator.py/Lab6.py
421
3.90625
4
import random #generate a password of length n using a while loop #and random.choice to get a string aof random numbers #use input,print,looping,random.choice... #the string builder pattern choices = [1,2,3,4,5,6,7,8,9,0] pword = "" length = int(input('How long a password do you need? ')) i = 0 while i < length: ...
7ec9c7dce3f0925c4f4246285fdc8d048049f7f9
alveraboquet/Class_Runtime_Terrors
/Students/leon/lab_08/lab08_v1.py
552
3.8125
4
# PDX Fullstack Lab 08 version 1 # guess the number game import random def main(): compy = random.randint(1,10) victory = False i = 0 while (i < 10) & (not victory): player = input("Guess a number between 1 and 10: ") player = int(player) if (player == compy): print...
b8dacea72fa568e9ba661053246b862087bcb1a8
alveraboquet/Class_Runtime_Terrors
/Students/will/Python/lab_9_ROT_Cipher/ROT_cipher.py
633
4
4
import string lower = list(string.ascii_lowercase) crypto_code = ''.join(lower[-13::]) + ''.join(lower[:13:]) crypto_code = list(crypto_code) code_dict = {} for item in crypto_code: code_dict[item] = 1 #print (code_dict) off_set = input("please enter an integer between 1 and 26: ") off_set = int(off_set) counter ...
793e45264df9239562ea359d2b1f704643e7c9e2
alveraboquet/Class_Runtime_Terrors
/Students/andrew/lab1/lab1_converter.py
1,903
4.4375
4
def feet_to_meters(): measurment = { 'ft':0.03048} distance = input("Enter a distance in feet: ") meters = float(distance) * measurment['ft'] print(f'{distance} ft is {meters}m ') def unit_to_meters(): measurment = {'ft':0.03048, 'km':1000, 'mi':1609.34} distance = input("Enter a distance in meters: ...
eae981e7b5c36e17239f0ea501cd9fa64ac556b0
alveraboquet/Class_Runtime_Terrors
/Students/Eric/Project/cal.py
5,601
3.921875
4
import math from tkinter import * #Creating Root Tkinter Widget root = Tk() root.title("Calculator") cell = Entry(root,width =17, borderwidth=10, font=("Courier", 32)) cell.grid(row=0, column=0, columnspan=5, padx=10,pady=10) def button_click(number): current = cell.get() cell.delete(0, END) cell.insert(0, str(...
d0625cb91921c28816cd5ab06a100cb3ae9e4bbb
alveraboquet/Class_Runtime_Terrors
/Students/cleon/Lab_6_password_generator_v2/password_generator_v2.py
1,206
4.1875
4
# Cleon import string import random speChar = string.hexdigits + string.punctuation # special characters print(" Welcome to my first password generator \n") # Welcome message lower_case_length = int(input("Please use the number pad to enter how many lowercase letters : ")) upper_case_length = int(input("How many...
dd42a6746075c658e247a3f312d5c77de6eaa9b9
alveraboquet/Class_Runtime_Terrors
/Students/cadillacjack/Python/lab11/make_change_v2.py
1,766
4.03125
4
''' Written by James Keicher This is a Cadillac Jack Production Completed : 10/19/20 ''' print(''' Welcome to Cadillac Jacks Change maker. You will be prompted to enter a Dollar amount. For less than $1, enter the amount as a decimal; I.E. 67 cents is equal to ".67" For any value over $1; Enter the whole dollars fol...
5a89444d7b72175ba533b87139a5a611a11a89a7
alveraboquet/Class_Runtime_Terrors
/Students/Jordyn/Python/Fundamentals1/problem1.py
224
4.3125
4
def is_even(value): value = abs(value % 2) if value > 0: return 'Is odd' elif value == 0: return 'Is even' value = int(input('Input a whole number: ')) response = is_even(value) print(response)
9f7f866b485f580629cdc0f4a48b0f0811dc8996
alveraboquet/Class_Runtime_Terrors
/Students/Joe/Lab7/Lab7Rockpaperscis.py
1,665
4
4
import random user_choice = input ('Rock, paper, scissors? ').lower() print(f'you chose {user_choice}') computer_choice = random.randint(1,3) #print (computer_choice) def get_computer(): global computer_choice #computer_choice = random.randint(1,3) if computer_choice == 1: print ('computer chooses rock') ...
c39f9a3e663be3789fb4397da60732b6f2aa3d42
alveraboquet/Class_Runtime_Terrors
/Students/Eric/Game/game.py
949
3.796875
4
class Player : def __init__(self, name , token): self.name = name self.token = token class Game(Player): def __init__(self, name, token, board): super().__init__(length, width) self.board = board player1n = input('What is your name Player 1: ') player1t = input('Do you wnat to ...
c6ba0e11395afaf1fb6fd48cb9a253436bace1ec
alveraboquet/Class_Runtime_Terrors
/Students/Eric/Lab6/V3/gen.py
1,120
3.734375
4
import random import string #Constant Values LETTERS = string.ascii_letters PUNCTUATION = string.punctuation DIGITS = string.digits #Emypt List llist = [] plist= [] dlist = [] #User Input Fuction with Anti Number def userinput(many): while True: x = input(f'\nHow many {many} do you want?\n\n') if (x.i...
d0a9746ed5de3bd8826b81df8ffc60d647504402
alveraboquet/Class_Runtime_Terrors
/Students/Ted/first_ass.py
135
3.90625
4
ask = float(input('What, in feet, would you like to convert to meters? ')) answer = (ask * 0.3048) print(f'Your answer is: {answer}')
d464e183398e378503dd9e085219de93ae1cf099
alveraboquet/Class_Runtime_Terrors
/Students/will/Python/Lab_API/weather_check/weather-request_final.py
773
3.859375
4
# import requests # user input "city name" city_name = input("Enter the city name of your intended destination: ") # creates a variable that ".get" the data available for the associated city provided response = requests.get(f"https://api.openweathermap.org/data/2.5/weather?q={city_name}&&appid=8af2aa7fa978da0c3dc608...
506086bf6dc229f9bb68630b2da387e32e2232a6
alveraboquet/Class_Runtime_Terrors
/Students/Eric/Lab10/l10.py
1,363
3.890625
4
def peaks(data): elist = [] # Empty List for x in range(len(data)): # Lenth of Data if x > 0 and x < len(data)-1: # Not First or Last Data Point if data[x+1] < data[x] and data[x-1] < data[x]: # Checking if New Number is bigger then the last and the next number elist.append(...
59bc2af7aeef6ce948184bb1291f18f81026ed9c
alveraboquet/Class_Runtime_Terrors
/Students/Jordyn/Python/Fundamentals2/problem3.py
296
4.1875
4
def latest_letter(word): length = len(word) length -= 1 word_list = [] for char in word: word_list += [char.lower()] return word_list[length] word = input("Please input a sentence: ") letter = latest_letter(word) print(f"The last letter in the sentence is: {letter}")
ce787d1009f048d9179001ed3e7ff5b29143520f
alveraboquet/Class_Runtime_Terrors
/Students/Jordyn/Python/Tic Tac Toe/TTT_CPU_v1.py
21,167
3.859375
4
import operator import random class Game: def __init__(self): self.breaker = 0 while self.breaker != 1: try: self.difficulty = int(input("Please choose your difficulty 1-10. 1 being easiest and 10 being impossible.\n> ")) if self.difficulty no...
b1be2e983f9ba13ab9db6924368410d04d7b7300
alveraboquet/Class_Runtime_Terrors
/Students/Ted/File_oop/bank_glitchy_acct.py
1,277
3.984375
4
class bankaccount: def __init__(self, number, name, balance): self.number = number self.name = name self.balance = balance def bankfees(self):#5% of balance fees = float(self.balance * .05) return (fees) def deposit(self): amount = float(input('How much a...
627275ef1f88b1c633f0114347570dc62a16f175
alveraboquet/Class_Runtime_Terrors
/Students/cadillacjack/Python/lab15/lab15.py
1,306
4.1875
4
from string import punctuation as punct # Import ascii punctuation as "punct". # "punct" is a list of strings with open ('monte_cristo.txt', 'r') as document: document_content = document.read(500) doc_cont = document_content.replace('\n',' ') # Open designated file as "file". "file" is a string for punc in punct:...
8b280951549f3c8df683a2a8e3e35140d608a01d
alveraboquet/Class_Runtime_Terrors
/Students/will/Python/Lab_6_password/random_password.py
1,045
3.984375
4
import string import random qty_lower = input( "please enter the number of lowercase letters you would like: ") qty_lower = int(qty_lower) qty_upper = input( "please enter the number of uppercase letters you would like: ") qty_upper = int(qty_upper) qty_nums = input( "please enter the number of numbers you would like:...
0c31b359da41c800121e7560fceac30836e2daec
alveraboquet/Class_Runtime_Terrors
/Students/tom/Lab 11/Lab 11, make change, ver 1.py
1,903
4.15625
4
# program to make change # 10/16/2020 # Tom Schroeder play_again = True while play_again: money_amount = input ('Enter the amount amount of money to convert to change: \n') float_convert = False while float_convert == False: try: money_amount = float(money_amount) ...
ee47fc4371f5e8b01047f8f7633a4d0f99c04efa
alveraboquet/Class_Runtime_Terrors
/Students/cleon/Lab_15_Count_Words/Lab15_Count_Words.py
737
3.59375
4
#Cleon #Lab 15 #10-21-2020 #version 1 from collections import Counter import string with open ('book.txt', 'r', encoding='utf-8') as document: document_content = document.read().lower() removed = string.punctuation for pun in document_content: if pun in removed: # removes punctuation ...
046f6874305f6e23666e56bd8e3dca6e0207d80c
alveraboquet/Class_Runtime_Terrors
/Students/ian/py_labs/classes_lab/ex2.py
830
4.09375
4
""" Import datetime b) Create a class with the following attributes: name last name surname address age telephone email Create a method that based on today’s time can return the person’s age. For instance, if this person was born in (1992, 3, 12) and I use this method, I should get 28 as a result """ from datetim...
8a8ce83b77498d38089aea25b1edd589330d8f0b
alveraboquet/Class_Runtime_Terrors
/Students/cadillacjack/Python/oop/volume.py
1,152
4.25
4
class Volume: def __init__(self, length, width, height): self.length = int(length) self.width = int(width) self.height = int(height) def perimeter(self): per = 2 * (self.length * self.width) return per def area(self): area = self.length * self.width re...
104bd40e38b212aa8d52362d86bd06e221e5d39a
alveraboquet/Class_Runtime_Terrors
/Students/tom/Lab 10/lab_10_peaks_valleys.py
913
4.03125
4
data = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9] # length is 21 peak_location = 0 peak_value = 0 data_length = len(data) def peak (data, data_length): peaks = {} x = 0 while x < data_length-3: if data[x] < data[x + 1] and data[x + 1] > data[x + 2]: peaks.update({x...
d6d589f5f58e9ebe07c05973e65a3575cdca4dbe
KawaharaSyuichi/algorithms
/sort/Bubble_Sort.py
449
3.5625
4
def bubblesort(A, N): sw = 0 flag = True i = 0 while flag: flag = False for j in reversed(range(N)): if j < i + 1: break if A[j] < A[j - 1]: A[j], A[j-1] = A[j-1], A[j] flag = True sw += 1 ...
cf780c3406e6d794a69fe1bf3ca216ef62154ac7
KawaharaSyuichi/algorithms
/ComputationalGeometry/Intersection.py
891
3.609375
4
# 線分の交差判定 """ 入力例: 3 0 0 3 0 1 1 2 -1 0 0 3 0 3 1 3 -1 0 0 3 0 3 -2 5 0 出力例: 1(交差する場合) 1 0(交差しない場合) """ def ccw(x_0, y_0, x_1, y_1, x_2, y_2): COUNTER_CLOCLWISE = 1 CLOCKWISE = -1 ON_SEGMENT = 0 a_x = x_1 - x_0 a_y = y_1 - y_0 b_x = x_2 - x_0 b_y = y_2 - y_0 cross_product = a_x * b...
98005425a217d5935bca90074a048cf1a6622841
panosadamop/pythonCourses
/geometric.py
212
3.546875
4
def myrange(N,logos): counter = 0 n = 1 while counter <= N: counter += 1 n *= logos yield n for i in myrange(5,10): print(i) print() for i in myrange(6,2): print(i)
bef87828e693fc293fb39f49d15eb42cba254ef0
ders03/C950
/src/utils/clock.py
3,160
3.65625
4
from enum import Enum class ClockState(Enum): STOPPED = 0, RUNNING = 1, PAUSED = 2 class Clock: # This is my timer class. def __init__(self, start_point = 500, timestep = 10, delay_start_point = 250, **kwargs): # Set up the clock. self.start_point = start_point self.timeste...
0bb09d26603ea00b8573597a8c00f602d31151e3
Alysson1013/estudos-ia
/fundamentos-python/listas.py
187
3.65625
4
vet = [1,2,3,4,5] print(vet) vet2 = [1,"dois", True] print(vet2) vet3 = [12, [1,2,3,4,5,6], False, "Carlos"] print(vet3) print(vet3[1][4]) print(len(vet3)) for n in vet3: print(n)
43cdb72bff8cc0ed45173f1cca2034b447498437
saviaga/CodeChallenges
/Strings/ReverseString.py
2,439
3.984375
4
""" https://leetcode.com/problems/reverse-string/description/ Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". We can reverse string in Python in 5 different ways 1) Using loop 2)Using recursion 3)Using stack 4)Using extended slice syntax 5)U...
27916236bdd48b14faf4f985d867b109afa43469
saviaga/CodeChallenges
/BinaryNumbers/NumberComplement.py
1,133
4.0625
4
""" https://leetcode.com/problems/number-complement/description/ Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero b...
97b627c1673e1df7e7e1437f4969c99493a01a67
gustavobonassa/PythonCodes
/uri1221-Npasso.py
380
3.96875
4
##Tem que ser mais rapido def isPrimo(num): if num == 2: return 1 if num !=0 and num != 1 and num%2!=0: for i in range(3,int(num//2),2): if(num%i==0): return 0 return 1 return 0 n = int(input()) for i in range(n): f = int(input()) if(isPrimo(f)): ...
2ce32f0d9fbe558e371202927a58d428f8048714
Nusmailov/BFDjango
/Week1/Informatics/1/A.py
95
3.578125
4
from math import sqrt a = int(input()) b = int(input()) c = sqrt(a*a*1.0 + b*b*1.0) print(c)
68db3ac8f548e8352489cdc20230ecccc778261e
Nusmailov/BFDjango
/Week1/Hackerrank/If-else.py
131
3.9375
4
a = int(input()) if a % 2 == 1 or (a> 5 and a < 21): print("Weird") elif a >= 2 and a <= 5 or ( a > 20): print("Not Weird")
492b428946d4e0b13f814247b0e8a54581c6e2b8
Nusmailov/BFDjango
/Week1/Hackerrank/Find the RunnerUp.py
234
3.5
4
from math import sqrt n = int(input()) s = input().split(' ') a = [int(i) for i in s] mx = a[0] for i in a: mx = max(i, mx) a = sorted(a) for i in range(n-1, -1, -1): if mx > a[i]: print(a[i]) exit() print(mx)
581e89fb5a461f186bdd0ee6d285f194bc02cbad
jaistudy1996/Code-Wars
/Python/8.py
609
3.96875
4
# Define a function isPrime that takes one integer argument and # returns true or false depending on if the integer is a prime. # Per Wikipedia, a prime number (or a prime) is a natural number # greater than 1 that has no positive divisors other than 1 and itself. import pdb def is_prime(num): if num > 1: ...
af840c01f066376e55d2eb147c4064dbc76d7dba
Dmitry7393/DesignPatternsInPython
/FactoryMethod/__init__.py
1,312
3.65625
4
import abc class Database(metaclass=abc.ABCMeta): def __init__(self): pass @abc.abstractmethod def info(self): pass class MySqlDatabase(Database): def info(self): print('MySqlDatabase') class SqlLite3Database(Database): def info(self): print('SqlLite3Databas...
39e8db2cac12bf6b66194b6422c7326014a4827b
Bridgetc9/Chatbot
/Query.py
673
3.578125
4
import requests def query_location(location, categories): """ Queries from Facebook Places API given a location, and a list of categories. Returns the Place with the most checkins, which is assumed to be the most popular. """ ACCESS_TOKEN = YOUR_ACCESS_TOKEN FB_PARAMS = {'categories' : str(...
b5ca95a2f84a671f938538d87f7e024ac0732cce
shuhart/algo-coursera
/toolbox/week1/fibonacci_last_digit/fibonacci_last_digit.py
467
3.828125
4
# Uses python3 import sys import numpy as np def fib_last_digit(n): a = [0] * (n + 1) a[0] = 0 a[1] = 1 for i in range(2, n + 1): a[i] = (a[i - 1] + a[i - 2]) % 10 return a[n] def get_fibonacci_last_digit_naive(n): if n <= 1: return n previous = 0 current = 1 f...
143a175bd2aa0bfd8d7ff678e5bddbdd141bf9cb
athenian-computational-thinking/list-practice-assignment-template
/my_test.py
637
3.75
4
from my_code import append_to_list from my_code import insert_to_list from my_code import remove_from_list from my_code import sort_ascending from my_code import check_list list = [3, 18, 2, 75, 8, 33] def test_append_to_list(): assert [3, 18, 2, 75, 8, 33, 123] == append_to_list(list) def test_insert_to_list()...
2b5872bfd9424079935f6298d3e9a3cc5f5509af
himanshugupta005/Python-String-Programs
/string_prog9.py
180
3.890625
4
str ="python is easy languge" n=5 first_part = str[0:n] second_part =str[n+1:] print("modified string after removing " , "nth character") print(first_part + second_part)
30d648c1146b38c44003a83b1e34ed0475d67d0c
himanshugupta005/Python-String-Programs
/string_prog12.py
252
3.859375
4
s=input("input the string") d={} l=s.split(" ") for item in l: c=0 for i in range(len(l)): if(item==l[i]): c+=1 d.update({item:c}) print(f"the frequency of each word is {d}")
8a7d7300b3b9bcd21ca105d74ff4de67f89fe3a4
himanshugupta005/Python-String-Programs
/string_prog7.py
152
4
4
str1="the lyrics is not that poor"'the lyrics is poor!' if str1('not','poor'): str1=str1.replace('not,poor' ,'good') print("the lyrics is good")
a36ded48387e6142931244ea0c709ac5afba9648
namuyan/nem-python
/nem_python/dict_math.py
730
3.625
4
#!/user/env python3 # -*- coding: utf-8 -*- class DictMath: @staticmethod def add(a, b): # result = a + b c = dict() keys = set(a) | set(b) for k in keys: c[k] = a[k] if k in a else 0 c[k] += b[k] if k in b else 0 return c @staticmethod ...
ac84b11cdbc213794caa460365da95f664b2084f
oguzbalkaya/ProgramlamaLaboratuvari
/enyuksektoplam.py
878
3.609375
4
#Listedeki elemanların ardışık sırada en yüksek toplamı liste_1 = [4,-3,5,-2,-1,2,6,-2] max_1=0 for i in range(len(liste_1)+1): for j in range(i,len(liste_1)+1): t=0 for k in range(i,j): t=t+liste_1[k] if max_1<t: max_1=t i_1,i_2=i,j print(max_1,i_1,i_2) ...
86f384250d8c2b46b25f0c85230cdc8dcf71cea8
oguzbalkaya/ProgramlamaLaboratuvari
/nElemanliListeOlusturma.py
246
3.75
4
#min ve max arasındaki tam sayılardan oluşan n elemanlı bir liste oluşturur. from random import randint as rand def listeOlustur(n=10,min=1,max=100): liste = [] for i in range(n): liste.append(rand(min,max)) return liste
707f1ad0867f4a4eb18c00d33b59a5026c87949e
saint1729/EPI
/primitive_types/bit_utilities.py
299
4.03125
4
def convert_binary_to_int(b): ans, bit_position = 0, 0 while b > 0: ans += ((b % 2) * (1 << bit_position)) b //= 10 bit_position += 1 return ans def convert_int_to_binary(n): x = '' while n > 0: x += str(n % 2) n >>= 1 return x[::-1]
37855e2d95eb23b31939d146d29fb469b930ad5b
Am4teur/LinkedList
/LL2.py
820
3.53125
4
import LL1 class Node(LL1.Node): def rmvDup(self): node = self nodeinit = node seen = [node.value] while(node.next != None): if(node.next.value in seen): node.next = node.next.next else: seen.append(node.next.value) ...
a37de74e059303446ef0e27e3fec4dacbaae7809
DhirendraPachchigar/daily-coding-problems-1
/python/376.py
1,643
3.953125
4
# ---------------------------------- # Author: Tuan Nguyen # Date created: 20200524 #!376.py # ---------------------------------- """ You are writing an AI for a 2D map game. You are somewhere in a 2D grid, and there are coins strewn about over the map. Given the position of all the coins and your current position, ...
731d621d829d63006f33ec3ca018a4886ce36a4b
ralster213/CyberSecurity
/Homework2-master/Email_Extractor.py
554
3.703125
4
#Email_Extractor.py #Name: #Date: #Assignment: import urllib.request from bs4 import BeautifulSoup def main(): #prompt the user for a webpage url url = 'https://www.unomaha.edu/college-of-information-science-and-technology/about/faculty-staff/index.php' url_html = urllib.request.urlopen(url) links = [] s...
bd89d612e7e9d15153ad804f85dfe64245c365a6
DanielY1783/accre_python_class
/bin/06/line_counter.py
1,440
4.71875
5
# Author: Daniel Yan # Email: daniel.yan@vanderbilt.edu # Date: 2018-07-25 # # Description: My solution to the below exercise posed by Eric Appelt # # Exercise: Write a command line utility in python that counts the number # of lines in a file and prints them. to standard output. # # The utility should take the name of...
b4d3854aea11e1cac0cece0b4dbd708b6d95d184
DanielY1783/accre_python_class
/bin/01/fib.py
1,338
4.53125
5
# Author: Daniel Yan # Email: daniel.yan@vanderbilt.edu # Date: 2018-06-07 # # Description: My solution to the below exercise posed by Eric Appelt # # Exercise: Write a program to take an integer that the user inputs and print # the corresponding Fibonacci Number. The Fibonacci sequence begins 1, 1, 2, 3, # 5, 8, 13, s...
d057261330bc9859a5002b7b67707b65b384e569
MiirHo3eIN/Python_Exersices
/hangman.py
3,379
3.5
4
import urllib.request import random def rnd_word(): word_url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain" response = urllib.request.urlopen(word_url) long_txt = response.read().decode() words = long_txt.splitlines() word_num = random.randrange(len(words)) ...
678d1c5a4e9aa3147f7193901e6e25480f4aa83a
sergiocg13/DataSience_School
/intermediate_python/dict_comprehensions.py
638
3.875
4
import math def run(): #Crear diccionario en donde las llaves sean 1 al 100 y los valores sean # llaves**3 # my_dict = {} # for i in range(1, 101): # if i%3==0: # my_dict[i] = i**3 # print(my_dict) #Creado con dictionary_comprehensions, numero no divisibles entre 3 #my_dict = {i...
a26afe3953ed862a4232ad173afaaffbdc292943
shoponmia01/Linear_Search
/linear.py
375
3.828125
4
def linear_search(list, search_number): found = False for i in range(0, len(list)): if list[i] == search_number: found = True break if found == True: print("Number is found at ",i, "index") else: print("Number is not found") list =[10, 30, 20, 5, 4...
84edb466c6702daead8d6a20f47f1b3cab563628
M-Efforts/Machine_Learning
/Data_processing/node_count.py
1,213
3.515625
4
# 读取文件,并将其中每一行的数据分割,然后分别对两列数据进行计数 data_txt = r'边表数据' read_folder = open(data_txt, "r") trainlines = read_folder.read().splitlines() # 返回每一行的数据 # 使用数组保存截取的数据 md_M = [] # Movie-Director中Movie节点个数 md_D = [] # Movie-Director中Director节点个数 ma_M = [] # Movie-Actor中Movie节点个数 ma_A = [] # Movie-Actor中Actor节点个数 mt_M = [] ...
b70b0b477f97f13196fa2b605002eb96f059a9e5
M-Efforts/Machine_Learning
/Data_processing/array_cut.py
394
3.671875
4
import numpy as np def array_split(): a = np.array([1, 2, 3, 4, 5, 6, 7]) offset = int(a.shape[0] * 0.8) print(a[:offset]) print(a[offset:]) def array_delete(array): temp = np.delete(array, 3-1, axis=0) for i in range(len(temp)): print(i) print(temp[i]) if __name__ == '__ma...
d9e3ccb764f381ace13e7524987ec345dbd11817
ishanichugh/angelhack
/app/app.py
2,118
3.5
4
# We need to import request to access the details of the POST request # and render_template, to render our templates (form and response) # we'll use url_for to get some URLs for the app on the templates from flask import Flask, render_template, request, url_for import csv import math import json from flask import send_...
507ec220e92770f98535eac387aebc59338922f4
Enkizen/MarchFun
/area.py
2,048
3.671875
4
#!/bin/python3 import math import os import random import re import sys class Car: def __init__(self,maxspd,speedtype): self.maxspd=maxspd self.speedtype=speedtype def __str__(self): st = "Car with the maximum speed of {} {}" return st.format(self.maxspd,self.speed...
5c70bec3535c175cf8ca450ccf707de40983fa3b
Enkizen/MarchFun
/oddeven.py
520
3.796875
4
import math import math import os import random import re import sys def oddeven(n): #n odd p weird if n % 2 !=0: print("Weird") if n % 2 == 0: if n >= 2 and n <= 5 : print("Not Weird") if n >= 6 and n <= 20 : ...
28df2973e6bd4d9f990744ea4e0fe28ded3a2c80
zjacreman/projeul_py
/projeul_p_30.py
769
3.578125
4
# Project Euler problem 30 # Find the sum of all numbers that can be written as the sum of fifth # powers of their digits. # For example, 1634 = 1**4 + 6**4 + 3**4 + 4**4 winners = [] for i in range(2, 354294 + 1): # (9**5) * 6; (9**5) * 7 is still a # 6-digit number, meaning that after...
93c2348a40af4177fc93e64f6afc710f3b4610ca
zjacreman/projeul_py
/projeul_p_5.py
1,714
3.90625
4
# Project Euler, problem 5 # What is the smallest number divisible by each of the numbers 1-20? import time from functools import reduce def find_prime_factors(num): """ Does what it says on the tin. """ factors = [] div = 2 while num > 1: while num % div == 0: factors.appe...
8db026b25313dccb758b0be69aa4cef777d824e6
Marpop/exercism-tasks-python
/word-count/word_count.py
550
3.890625
4
def word_count(phrase): words = phrase.lower().replace( '.', ' ').replace( ':', ' ').replace( ',', ' ').replace( '!', ' ').replace( '&', ' ').replace( '@', ' ').replace( '$', ' ').replace( '^', ' ').replace( '%', ' ').replace( '&', ' ')...
7fb38f526f3029adc630aba4d9b877ccd54ea128
howardlo/CodeQuestMentor2018
/Practice-CodeQuest2017/Problem11/Problem11.1.py
1,438
3.84375
4
# Howard: lowers = "abcdefghijklmnopqrstuvwxyz" uppers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" def reverse(word): n = len(word) non_letter_map = [] for i in range(0, n - 1): c = word[i] # print("c: " + c + " | " + str(letters.find(c)...
f3e6ea799867d547fe4296377a2b766dee46d28c
liuhuanhuan963019/python
/day18-matplotlib/新增的知识点.py
2,014
3.53125
4
import matplotlib.pyplot as plt # ------------------example 1--------------- # squares = [1,4,9,16,25] # # linewidth 设置曲线线条的粗细 # plt.plot(squares,linewidth=5) # plt.title("Square Numbers",fontsize = 24) # plt.xlabel("Value",fontsize=24) # plt.ylabel("Square of Value",fontsize=24) # # 设置刻度标记的大小 # plt.tick_params(axis...
68b16ed48ce493880089a903d9b05639fab8f817
liuhuanhuan963019/python
/day11-文件操作和模块操作/os模块.py
2,271
3.84375
4
''' os模块: 对文件进行重命名、删除等一系列操作,在python中可以利用os模块 os模块提供了一些系统级别的操作 import os 修改文件名:rename(需要修改的文件名,新的文件名) os.rename('1.py','2.py') 删除文件:remove(待删除的文件名) os.remove('3.py') 创建文件夹:mkdir(文件夹名称) os.mkdir('gl') 删除文件夹:rmdir(文件夹名称) os.rmdir('gl') 获取当前目录:getcwd()...
29d37d904ee9f70668105fe45b987de367bf90a5
liuhuanhuan963019/python
/day05/引用变量.py
731
3.84375
4
#encoding=utf-8 ''' 在python,值是靠引用来传递的,可以用id()查看一个 对象的引用是否相同,id是值保存在内存中那块内存地址 的标实 在调用对象过程中,实际传递的是对对象对引用 参数传递是通过引用来传递的 ''' # a = 1 #不可变类型 一旦确定,值改变会重新开辟一个新的内存空间 # def func(x): # x=2 #此时地址已经发生了改变 # print('地址{}'.format(id(x))) #地址发生了变化 # pass # # print('地址{}'.format(id(a))) # func(a...
48c7477e8cef288082884d6a3f42ce88430d06a8
liuhuanhuan963019/python
/day08-面向对象中/重写.py
1,152
3.625
4
#所谓重写就是子类中拥有与父类相同名字的方法,在子类中完全覆盖掉了父类中的方法 class Dog: # 此时在父类中定义了init方法,子类中未定义,实例化对象时调用的是父类中的方法,此时报错 def __init__(self,name,color): self.name = name self.color = color pass def fit(self): print("狗叫") pass pass class Rabbit(Dog): def __init__(self,name,color): ...
a3086a867d88215f1095b22bfc908992af9b190a
liuhuanhuan963019/python
/day02/课后习题.py
1,114
3.9375
4
""" 1。猜年龄 允许用户尝试三次 每尝试三次后询问是否还想继续 y继续 n否 猜对了 直接退出 2。升高1。75体重80。5根据bmi公式(体重除以身高的平方) 计算BMI指数 低于18。5 很轻 18。5-25 正常 25-28 过重 28-32 肥胖 高于32 严重肥胖 用if-else打印 """ weight = 80.5 high = 1.75 bim = 80/(1.75**2) if bim < 18.5: print('很轻') pass elif bim >= 18.5 and bim <= 25: print('正常') pass ...
a795e80fa3dc3a0d38f7fd311c0412fe766df644
liuhuanhuan963019/python
/day03/list.py
964
3.8125
4
#encoding=utf-8 ''' list python中非常重要的数据结构,是一种有序的数据集合 特点: 1。支持增删查改 2.列表中数据可变但是地址是不变 3。用[]来表示列表类型 4。支持索引和切片来进行操作 ''' li = [1,2,3,4,"你好"] print(len(li)) print(li[1:4]) #输出第二个元素到第四个元素后面的值 print(li[1:]) #输出第二个元素后面所有的元素 print(li[::-1]) #负数从右边开始输出 print(li*2) #列表中的数据输出两倍 print("追加之前---") print(l...
7d3366ba1ed2ab56d4d2710727be81abfbd188dc
liuhuanhuan963019/python
/day06/序列函数操作3.py
1,090
3.828125
4
#encoding=utf-8 ''' enumerate() 函数用于将一个可遍历的数据对象(如列表。元组,字符串)组成一个索引序列 同时列出数据和数据下标,一般用在for循环中 ''' # list = [1,2,3,4,5,6] # # for item in enumerate(list): # print(item) # ''' # 输出:(1, 2) # (2, 3) # (3, 4) # (4, 5) # (5, 6) # ''' # for index,val...
3c09c373183199e3b768f0efbb033c4d969dcdf2
liuhuanhuan963019/python
/day02/while.py
1,179
3.90625
4
#encoding=utf-8 ''' while 循环代码结构: while 条件表达式: 代码指令 1.初始值 2.条件表达式 3.自增或自减 否则导致死循环 ''' #例:输出1-100之间的数 # import random # index = 1 # while index < 100: # print(index) # index += 1 # pass # while index < 100: # number = int(input("请输入一个数:")) # computer = random.ran...
f9c8a382f7f3af154c55212cf4ac201c52638ceb
liuhuanhuan963019/python
/day01/位运算.py
151
3.6875
4
#encoding=utf-8 a = 3 print (bin(3)) #0b1 b=0b11 print (int(b)) #3 c = -2 print (bin(c)) #负数的二进制数, 正数取反加一 补码
96ce706f1316562f59654f0e494074f40a368f8e
karthik-crypto/python_logical_operators
/Exam.py
129
3.890625
4
X=35 user1=int(input("enter the value")) if X<=user1: print("user has passed in exam") else: print("user failed in exam")
21e83f08a72ea6902c2877a2a0efedf49f0b0d82
rshin808/quickPython
/Classes/EXclassdefaultargs.py
116
3.546875
4
class Animal: def __init__(self, name = ""): self.name = str(name) animal = Animal() print animal.name
1db59dcb55f8b898d4d57ad244edc677b590941b
rshin808/quickPython
/Classes/EXoverriding.py
1,387
4.34375
4
class Animal: def __init__(self, name): self._name = str(name) def __str__(self): return "I am an Animal with name " + self._name def get_name(self): return self._name def make_sound(self): raise NotImplementedError("Subclass must implement abstract method") ...