blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
cca5cd9fbe4688a2ad706b4508bf73b8ca537c04
udaybhaskar578/Hacker-Rank-Challenges
/Strings/Easy/CamelCase.py
214
3.75
4
#!/bin/python3 # Question : https://www.hackerrank.com/challenges/camelcase # Time Complexity: O(n) #!/bin/python3 import sys s = input().strip() x = 0 for c in s: if c.isupper(): x = x+1 print(x+1)
6f1f70ebeeabc6b49122bebb6682ddb227e4dbc2
sandeepmaity09/python_practice
/hackerrankcodeday4.py
697
3.640625
4
class Person: def __init__(self,initialAge): if initialAge>=0: self.age=initialAge else: self.age=0 print("Age is not valid, setting age to 0.") def yearPasses(self): self.age=self.age+1 def amIOld(self): if self.age < 13: ...
3eb80523aa611c5d1c5c05f146f4154388edc1f0
sandeepmaity09/python_practice
/Python Gui/combobox.py
675
3.546875
4
import tkinter as tk from tkinter import ttk win=tk.Tk() win.title("Combo Box") aLabel=ttk.Label(win,text="Choose a Number:") aLabel.grid(column=0,row=0) def clickMe(): aButton.configure(text="I'm Clicked") aLabel.configure(text="Hello"+number.get(),foreground='blue') aButton=ttk.Button(win,tex...
5232db97f8a5c8e5eb2de5554a8a7b451858b8f3
sandeepmaity09/python_practice
/data_structure/disjoint1.py
331
3.953125
4
#!/usr/bin/python3 #Three-Way Set Disjointness:- determine if the intersection of the three sequences is empty. #Running time analysis = O(n) power 3 def disjoint1(A,B,C): """Return True if there is no element common to all three lists.""" for a in A: for b in B: for c in C: if a==b==c: return False r...
a41146719b2944e6dfdabc5e9be39625296dc1bd
sandeepmaity09/python_practice
/design2.py
126
3.8125
4
#!/usr/bin/python3 row=int(input("Enter the number of rows : ")) i=1 while i <= row: x= "*" * i print(x) i=i+1
04d8e6bdfde271594b614e385b5f9b1c1ecef7dd
sandeepmaity09/python_practice
/salesmansalary.py
591
3.828125
4
#!/usr/bin/python3 """Salesman basic salary is 1500, for every camera he will sell he will get 200 and the commission on the month's sale is 2%. The input will be number of cameras sold and total price of the cameras.""" basic_salary=1500 camera_sell=200 commission=0.02 camera_sole=int(input("Enter Numbers of ...
bf0d3e56763cca5dc8024581746ab9eafcb6313b
sandeepmaity09/python_practice
/tuple.py
354
4.59375
5
#!/usr/bin/python3 empty=() # creating tuple print(type(empty)) empty=tuple() # creation tuple print(type(empty)) empty="hello", # <---- note trailing comma for create a tuple with only one item print(empty) empty=23,34,'heelo' # to create tuple x,y,z=empty # sequence unpacking of tuple print(type(x...
975eb35f2c500489c4e0e78f54cebb3fadb49242
sandeepmaity09/python_practice
/data_structure/disjoint2.py
254
4.125
4
#!/usr/bin/python3 #Running time algorithm = O(n) power 2 def disjoint2(A,B,C): """Return True if there is no element common to all three lists.""" for a in A: for b in B: if a==b: for c in C: if a==c: return False return True
9fcef2361eb851cb7ccd3e424f7f5e750a21bb33
sandeepmaity09/python_practice
/list_as_queue.py
307
3.859375
4
#!/usr/bin/python3 from collections import deque queue=deque(["Eric","John","Michael"]) print(queue) queue.append("Terry") queue.append("Graham") print(queue) print(queue.popleft()) #the first to arrive now leaves print(queue.popleft()) #the second to arrive now leaves print(queue) #print the queue
6b376457f2ba578b186d8cfedae71e5bfd293fbe
sandeepmaity09/python_practice
/design1.1.py
123
3.875
4
#!/usr/bin/python3 row=int(input("Enter the number of rows : ")) n=row while n >= 0: x = "*" *n print(x) n-=1
792f5f920817fba182d9d1dd3d0c8d3832871e05
Maxon2019/Py_ProgectsLNIP
/Translator.py
717
3.75
4
import tkinter as tk from googletrans import translator win = tk.Tk() win.title('Translator') win.geometry('200*70') #Function def translation(): word = entry.get() translator = Translator(service_urls = ['translate.google.com ']) translation1 = translator.translate(word,dest ='ru') labe...
aad77f9b3290c70447c34f36439579ab8d47870d
Maxon2019/Py_ProgectsLNIP
/calc.py
1,079
4.09375
4
password = input('Enter your password:') hard = 0 if len(password) > 6: # for nums hard += 1 if 'a'or 'A' in password: # A hard += 1 if 'b'or'B' in password: # B hard += 1 if 'c'or'C' in password: # C hard += 1 if 'd'or'D' in password: # D hard += 1 if '...
b59d89326ba92cf33e3ef8d942c8cbb89fd50b09
JohnnySheng/learn_python
/others/favorite_languages.py
543
3.96875
4
from collections import OrderedDict favorite_languages = OrderedDict() favorite_languages['jen'] = 'python' favorite_languages['sarah'] = 'c' favorite_languages['edward'] = 'ruby' favorite_languages['phil'] = 'python' for name, language in favorite_languages.items(): if name in friends: print("Hi," + name...
4589b0d8e9c31882841896cec8b077769cb58257
JohnnySheng/learn_python
/others/foods.py
567
4.15625
4
my_foods = ['pizza', 'falafel', 'carrot cake'] friend_foods = my_foods[:] my_foods.append('cannoli') friend_foods.append('ice_cream') print("My favorite foods are:") print(my_foods) print("\nMy friend's favorite foods are:") print(friend_foods) print("The first three items in the list are: ") print(my_foods[0:3]) pr...
e912317db534f94e4f6684e482abdfd5708b80c7
JohnnySheng/learn_python
/others/squares.py
480
3.921875
4
squares = [] for value in range(1,10): square = value**2 squares.append(square) print(squares) digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -1] print(min(digits)) print(max(digits)) print(sum(digits)) squares = [value**2 for value in range(1,11)] print(squares) for number in range(1,21): print(number) bigDa...
2569c7e4a40dba03d1390142daab91ede158eb53
Call-Me-AJ-01/Graphical-User-Interface-Python
/(1) Basic Tkinter Widgets/(11) Message Box.py
777
3.703125
4
from tkinter import * from tkinter import ttk from tkinter import messagebox # Creating object for the window root = Tk() # Title For The Window root.title('Message Box') # Creating Function def msg1(): msg_in=messagebox.askquestion("Delete",'Are You Sure..?') if msg_in=='yes': print('D...
cbb0016efc49178c8181c0b56a98dec535c370ea
Call-Me-AJ-01/Graphical-User-Interface-Python
/(1) Basic Tkinter Widgets/(10) Spin Box.py
2,971
3.609375
4
from tkinter import * from tkinter import ttk # Adjusting The Screen Resolution Graphics For Better View try: from ctypes import windll windll.shcore.SetProcessDpiAwareness(1) except: pass # Creating Object for the Window root = Tk() # Title For The Window root.title('Grid Layout') # Fix...
7f2de84e25f258f2f445311126302e1b24f434fd
Call-Me-AJ-01/Graphical-User-Interface-Python
/(1) Basic Tkinter Widgets/(12) Text Editor.py
616
3.609375
4
from tkinter import * from tkinter import ttk # Creating The Object For The Window root = Tk() #Title of The Window root.title('Text Editor') #Creating a function to display def display(): print(text.get(0.1,END)) # Creating The Text Field text = Text(root,width=30,height=10,font=('Timesnewroman 10 ...
707c4ca81faa0813cb9ee8c0d68af0b427b84062
SDRU/had
/Snake.py
5,811
3.640625
4
import sys from time import sleep from random import randint import pyglet from pyglet import gl from pyglet.window import key from draw import draw_rectangle, draw_text ### sys.argv makes a list of all arguments we call with Python, second one is scaling unit size, e.g. python Snake.py 20 if len(sys.argv) == 2: ...
01761f3af6331d485e3cf901aaf1af008b8d21f4
agrahamlincoln/space
/overlays.py
5,900
3.890625
4
""" overlays.py Stores the scores and information about the game Also displays notifications and displays to the user 5/5/2014 Graham Rounds """ #Initialize import pygame """ Class Overlay Generic Overlay Class which displays a pygame sprite at a designated location on the screen The spri...
ff9eea0bdb3ee4f2697f58c58aa28f0cc9c5bb20
Floozutter/project-euler
/python/p002.py
1,184
4
4
""" Project Euler - Problem 2 "By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms." """ from itertools import takewhile from typing import Generator def evenfibs() -> Generator[int, None, None]: """ Yields even Fibonacci numbers, ...
ca0592b5430cca0b075845b1f9a33690ff7cbbdb
Floozutter/project-euler
/python/p004.py
1,723
4.34375
4
""" Project Euler - Problem 4 "Find the largest palindrome made from the product of two 3-digit numbers." """ from heapq import merge from typing import Iterable def palindromic(s: str) -> bool: """ Checks whether a string is a palindrome. """ size = len(s) for i in range(size // 2): if s...
566e4068778c5f39a1aea989b8840790888a652e
silviogn/data_science_engineering
/4_writing_efficient_code_python/examples.py
12,592
4.59375
5
#Course writing effective python code --------------------------------------------------------------------------------------------------------- #Built-in practice: range() # Create a range object that goes from 0 to 5 nums = range(6) print(type(nums)) # Convert nums to a list nums_list = list(nums) print(nums_list) ...
8056f057bd8fa11a7dfc6e8f41731d37be7dfbba
TrWesche/ca_sorts
/ca_bubblesort.py
491
4.21875
4
nums = [5, 2, 9, 1, 5, 6] # Define swap() below: def swap(arr, index_1, index_2): # pass temp = arr[index_1] arr[index_1] = arr[index_2] arr[index_2] = temp def bubble_sort(arr): for el in arr: for index in range(len(arr) - 1): if arr[index] > arr[index + 1]: sw...
542230af40652fe1d0238223fd8c157d8f8f9861
GuilleMunoz/Assembly_Line_Balancing_Problem
/classes.py
6,401
3.546875
4
import copy from math import exp from random import randint, random from numpy.random import permutation class Individual: """ Each individual is coded as a list of integers. The nth-element of the list corresponds to station asigned to the operation n. The fitness of a route is given by the sum of t...
1a441c50f06bb0ba2fc4090f14d6e5627377e02b
Talanvor/infa_2020_Snigir
/lab1-2/L2/exe5.py
250
3.65625
4
import turtle import numpy as m turtle.shape('turtle') N = 100 for j in range(1, 10, 1): for i in range(4): turtle.forward(20*j) turtle.left(90) turtle.penup() turtle.goto(-10*j, -10*j) turtle.pendown()
8342f250441f5c6e9e3fe84231d15265c9b67874
MalarSankar/learning
/Goride/final_goride_registration.py
1,791
3.6875
4
import re class Car: def __init__(self,car_category,car_number,color,company,model): self.car_category=car_category self.car_number=car_number self.color=color self.company=company self.model=model class Driver: def __init__(self,driver_name,driver_age,license_number,lic...
295747455091a5d327f2a5cfc6058fc2eb2ea1bc
LuisPatino92/holbertonschool-higher_level_programming
/0x0B-python-input_output/6-load_from_json_file.py
318
3.609375
4
#!/usr/bin/python3 """This module has the load_from_json_file function""" import json def load_from_json_file(filename): """Charges the json of and object and returns it""" jason_str = "" with open(filename, 'r', encoding='utf-8') as f: jason_str = f.read() return json.loads(jason_str)
f9b80902340fda78db2016b2e7b4d77984f5ba7f
LuisPatino92/holbertonschool-higher_level_programming
/0x06-python-classes/4-square.py
1,177
4.5625
5
#!/usr/bin/python3 """ This module has the definition of a Square class""" class Square: """ Model of a square """ def __init__(self, size=0): """ Constructor for Square Method Args: size (int): Is the size of the instance, 0 by default. """ if not isinst...
d098fa93e1def3706732bd290518efe0296b17ae
prathameshkurunkar7/Python_Projects
/Final Capstone Project/FindCostOfTile.py
388
4.21875
4
def find_cost(cost_per_tile, w, h): """ Return the total cost of tile to cover WxH floor """ return cost_per_tile * (w * h) w, h = (int(x) for x in input("Enter W and H : ").split()) cost_tile = float(input("Enter the cost per tile : ")) print( "Total cost of tile to cover WxH floor...
14d12e7ab8cf9f1837822740209448a86d00fc77
prathameshkurunkar7/Python_Projects
/FlaskAPI/linked_list.py
3,700
4.5
4
class Node: """Node to store data""" def __init__(self, data=None, next_node=None): """create a Node datatype Args: data ([type], optional): data to store. Defaults to None. next_node ([type], optional): pointer to next Node. Defaults to None. Example: ...
d37ac0b259b5d456182bd0e31a442247a2e424c5
agudelodiego/MundoPCs
/Orden.py
2,554
3.5625
4
""" REALIZADO POR: Diego Agudelo FECHA: Sep 27 2021 DESCRIPCION DEL ARCHIVO: El presente archivo esta dedicado al diseño de la clase Orden, la cual se encargara de crear cada una de las ordenes que hagan los clientes de. En una misma orden se podran tener varias computadoras """ #Importamos los modulos from Disposi...
d2e6c3738fe31bbd695157ae56af83e6e5ef72d5
drunowski/KattisProblems
/aaah.py
122
3.671875
4
string1 = input() string2 = input() x = len(string1) if(x < len(string2)): print('no') else: print('go')
2a60f5343b27fe587437abf1b972bbe9e7e04285
dougBelcher/Scripts
/temperature.6.3.py
674
4.375
4
# 6.3 - Challenge: Convert Temperatures def convert_cel_to_far(temp_cel): """Return the Celsius temp converted to Fahrenheit""" temp_far = temp_cel * (9 / 5) + 32 return temp_far def convert_far_to_cel(temp_far): """Return the Fahrenheit temp converted to Celsius""" temp_cel = (temp_far - 32) * ...
f4377a1ca83f36d0cd1099ec4976d53fab720ff9
dougBelcher/Scripts
/Morsels/plot_with_pandas.py
440
3.5
4
# Plot with pandas from RealPython import pandas as pd import matplotlib.pyplot as plt download_url = ( "https://raw.githubusercontent.com/fivethirtyeight/" "data/master/college-majors/recent-grads.csv" ) df = pd.read_csv(download_url) # print(f"{type(df)}") # pd.set_opti...
8818890d786a9381721c90dddb49fe36ebf3eb13
dougBelcher/Scripts
/PyBites/Bite 015. Enumerate.py
253
3.671875
4
# Bite 15. Enumerate 2 sequences names = ['Julian', 'Bob', 'PyBites', 'Dante', 'Martin', 'Rodolfo'] countries = ['Australia', 'Spain', 'Global', 'Argentina', 'USA', 'Mexico'] for index, name in enumerate(names, start=1): print(f"{index}. {name}\t")
dd192804b4c11cbef5aa64f2f88c30624a26f65d
dougBelcher/Scripts
/Morsels/add.py
533
3.65625
4
# I'd like you to write a function that accepts two lists-of-lists of numbers and returns one list-of-lists with # each of the corresponding numbers in the two given lists-of-lists added together. # # It should work something like this: # # >>> matrix1 = [[1, -2], [-3, 4]] # >>> matrix2 = [[2, -1], [0, -1]] # >>> add(m...
d4e6fb67e3f93a967a78b0fd9bf9806311363179
dougBelcher/Scripts
/ATBS/3 - your_name.py
128
4.25
4
# 3. your name name = '' while name != 'your name': print(f'Please type your name') name = input() print(f'Thank you!')
0f1ff233dbdb217d9926fd802a1a8c416f539f10
dougBelcher/Scripts
/smallest.py
206
3.75
4
smallest = None print 'Before:', smallest for itervar in [3,41,12,974, 15]: if smallest is None or itervar < smallest: smallest = itervar print 'Loop:', itervar, smallest print 'Smallest:', smallest
8e1e4b67f3d83d9554f0cb27b4ce35e85e93c6fb
vladisemen/OOPbyUnik
/main.py
1,206
4.09375
4
class Animal(): "Описание класса" voice = "" # конструктор (self~this в др ЯП) def __init__(self, name, age): self.__name = name # устанавливаем имя self.__age = age # устанавливаем возраст @property def age(self): return self.__age @property def name(self): ...
e16a00d5f78e6a7bcbdfa7ac06f5999a8d34a6df
lbarcik/MyProjects
/python_range_drill.py
221
3.859375
4
my_list = [0,1,2,3] my_list_len = len(my_list) for i in range(4): print(my_list[i]) print ("\n") for i in range (3, -1, -1): print (i) print ("\n") for i in range (8, 0, -2): print (i)
ea3e589927304050e95f69a1e205e5a7db720c71
JrdnVan/notes
/cs3331/lab03/WebServer.py
2,180
3.84375
4
""" (i) create a connection socket when contacted by a client (browser). x (ii) receive HTTP request from this connection. Your server should only process GET request. You may assume that only GET requests will be received. x (iii) parse the request to determine the specific file being requested. x (iv) get the requ...
127f9f10a7c2f433d5c035058234b7e537308413
MathiasEngstrom/sequence-python
/sequence.py
6,604
4.0625
4
import re class Sequence: """A class that represents DNA and RNA sequences and allows for comparisons and calculations on them. There is a method for reading files of single lined sequences with a single lined header. Attributes: __sequence: A string representing the actual sequence of ...
93653fb8c0fa8773da70dca56c3a38df76d81aec
GuoBayern/MachineLearning
/OnlyTest.py
127
3.625
4
a = [[1,2,3],[4,5,6],[7,8,9]] for x in a: print(x[0]) print(a[0]) print([example[2] for example in a]) print(a.count(a[0]))
bcbfa97a7d9b720b72baf9d41f3416423bb85ff5
jgartsu12/advanced_python_learning
/obj_oriented_program/invoice_three.py
336
3.546875
4
class Invoice: def __init__(self, client, total): self.client = client self.total = total def __str__(self): return f'Invoice from {self.client} for {self.total}' # dump out values visible from an obj inv = Invoice('Google', 500) # instantiate print(str(inv)) # => Invoice fro...
86e56d2b457b850fb4bc3e1bd21248762f5e406e
den01-python-programming-exercises/exercise-4-28-storing-records-jakeleesh
/src/exercise.py
646
3.96875
4
from person import Person import csv def main(): file = input("filename:") records = read_records_from_file(file) print("persons: " + str(len(records))) print("persons:") for person in records: print(person.get_name()) def read_records_from_file(file): records = [] # write here th...
4fb378146c4b8c716dfd3b87c0bd3ca8caedbeb4
ticotheps/Algorithms
/stock_prices/stock_prices.py
2,711
4.375
4
#!/usr/bin/python3 #---------------Understanding the Problem--------------- # Objective: Find the largest positive difference between two numbers in a # list of 'stock prices'. # Expected Input: a list of stock prices. # Example: [1050, 270, 1540, 3800, 2] # Expected Output: an integer representin...
bbcb8ad5f7484695f732a4d9254186f51453e1d9
paopee/paopee_memory
/Rocket build up #11.py
308
3.75
4
#needs 51 hours to power up #set alarm # time is now 2pm timex = 2 calculations = 3 #5pm in 2 days print ("time now is %d pm" %(timex)) print ("time finished should be %d pm in 2 days" %(calculations)) import time for i in range (1,183600,1 ): print (i) time.sleep(1) print ("rocket is ready")
65a4f1f52dc878a999493e7e68e3d8d65063cfe6
paopee/paopee_memory
/Vending Machine GC25.py
615
4.03125
4
pay = 0 print("Number 1:Coke\nNumber 2:Sprite\nNumber 3:Pepsi") while True: enter = int(input("Enter item number:")) if enter == 1 or enter == 2 or enter == 3: break if enter ==1 : pay = 3 print("$3.00") if enter ==2 : pay = 2 print("$2.00") if enter == 3: pay = 4 print("$4....
5906b4e19c8e1c7191c1e3eae69aef11bf1762ca
paopee/paopee_memory
/Random Roast Generator Challenge #16.py
340
3.84375
4
roast = ["Shut up", "Big L for", "U suck"] import random ans = "y" roasted = random.choice(roast) name = input("who do u want to roast name:") print (roasted, name) while ans == "y": roasts = input("Input a insult") roast.append (roasts) print(roast [3]) ans = input("Do u want to input another one y/...
57c2af31f1d324559067b5a7e245b6d4e9299b53
paopee/paopee_memory
/Are you sure that's a number? GC24.py
236
4.03125
4
j = int(input("How many digit is the number")) number_array = [] for i in range(j): number= input("Number:") number_array.append(number) if "." in number_array: print("That is a float") else: print("That is a integer")
fa61844b416b9bd4a9eb06a6570135d0afda96ac
AlexBlokhin1/mytests
/file_reader4.py
483
3.625
4
filename = 'file.txt' import os # import argparse # # parser = argparse.ArgumentParser() # parser.add_argument("square", type=int, help="display a square of a given number") # args = parser.parse_args() # # print(args.square**2) # def change_name(filename): index = filename.find('.') new_str = filename[:index] ...
bd455eb5379e2457ba5851e327bb06f07e567147
AlexBlokhin1/mytests
/mark8.py
1,757
3.734375
4
import random import collections american_names = ['Michael', 'John', 'Betty', 'Jacob', 'Drake', 'Alex', 'Angelina', 'Anabel', 'Simon', 'Sara', 'Andrew', 'Bill', 'Jack', ' llll'] abetka = 'abcdefghijklmnopqrstuvwxyz' def random_chars(abc, size=10): result_chars = [] for i in range(0, size): rand_i...
3ccbe0171ca6a2ac1a25ac968a84a7203cf82c91
weston-bailey/algorithms
/practice-problems/python/cube_sum.py
275
3.96875
4
def cube_sum(n): for a in range(n): for b in range(n): for c in range(n): for d in range(n): if a**3 + b**3 == c**3 + d**3: print(f'{a}^3 ({a**3}) + {b}^3 ({b**3}) = {c}^3 ({c**3}) + {d}^3 ({d**3})') break cube_sum(1000)
e963c1584480eedbcbceea93007bbf3b8e8b95aa
weston-bailey/algorithms
/python/linked_list.py
243
3.515625
4
from lib import linked_list test_list = linked_list.single() test_list.push(0) test_list.push(3) test_list.push(1) test_list.push(2) test_list.push(3) test_list.log('before for_each()') found = test_list.find_last(5) print('found', found)
52d8af9743e2dafaf96b7d1ca6c75113f482198d
weston-bailey/algorithms
/python/lib/quick_sort.py
886
3.734375
4
import random # return the list and the left and right indexes def quick_sort(unsorted_list): length = len(unsorted_list) return sort(unsorted_list, 0, length - 1) def sort(unsorted_list, left_index, right_index): # base case if len(unsorted_list) == 1: return unsorted_list if left_index < right_index...
da434377f10da631ea97e6f08d0aabfe9bb8e535
shieldslab/CPX
/examples/switch_and_neopixels.py
1,039
3.5625
4
# This program lights 5 neopixels, based on the switch position # We're going to import these two modules in nearly every program # Sleep allows us to, well, sleep. The CPX will run a while loop WAY too fast without a pause of some sort. # And when we import cpx, we get all kinds of cool functionality from time impor...
00d1a69685ff52798fd417f5428ddf2e9a6c01dc
shieldslab/CPX
/examples/acceleration_displayed_with_neopixels.py
1,103
3.84375
4
# This program lights 0-10 pixels, based on the x acceleration. # We're going to import these two modules in nearly every program # Sleep allows us to, well, sleep. The CPX will run a while loop WAY too fast without a pause of some sort. # And when we import cpx, we get all kinds of cool functionality from time impor...
99a247ca134cecf326f337cff43851f5eaea22bf
bmonsueir/cracking
/arrays_and_strings/2_permutation.py
247
3.90625
4
# return true if one string is a permuatation of the other def is_permutation(a, b): a = list(a) b = list(b) a.sort() b.sort() return a == b a, b = raw_input("enter 2 strings: ").split(" ") print is_permutation(a, b)
5ddb4adc4d508f7ff1c8b9347d21cccc83d817b8
liuruitao/2mouth
/31-day/2斐波拉契数列变生成器.py
107
3.609375
4
def fib(times): i = 0 a,b = 0,1 while i<times: yield b a,b = b,a+b i+=1 F = fib(5) print(next(F))
ee8a7d40b644286d072bbefb9a391331e0b60829
liuruitao/2mouth
/34-day/3多进程修改全局变量.py
231
3.640625
4
import os num = 0 ret = os.fork() #fork炸弹 #while True: # os.fork() #子进程和父进程的变量各不一样 if ret == 0: num+=1 print('我是子进程, num=%d'%num) else: num+=2 print('我是父进程, num=%d'%num)
910609fd6323077b1104cb37dd5d4017fb77ce19
liuruitao/2mouth
/35-day/5互斥锁.py
576
3.71875
4
from threading import Thread,Lock import time num = 0 def work(): global num mutex.acquire() #mutex非固定值 for i in range(1000000): num+=1 print('经线程1修改后全局变量是:%d'%num) mutex.release() #多线程共享全局变量,变量num经work改变后共享给work1 def work1(): global num mutex.acquire() for i in range(1000000): num+=1 print('经线程2修改后全局变...
14aab1bae6accd39a0058e0faf29c7fc6491aaed
lmendez2/mis3640
/class 7.py
1,260
3.859375
4
''' result = 0 for i in range(11): if i % 2 == 0: print('current i:', i) result =+i # result += means result plus i print(result) for i in range(2,11,2): print('current i:', i) result =+i # result += means result plus i print(result) def countdown(n): while n > 0: print(n) ...
754bc633381ff121f6507a0febca77631d9a0e93
lmendez2/mis3640
/my_abs.py
501
3.796875
4
def my_abs(n): if isinstance(n, int) or isinstance(n, float): if n >= 0: return n else: return -n else: print('invalid value') print(my_abs(4)) print(my_abs(59)) print(my_abs(-100)) print(my_abs('a')) def quadratic(a, b, c): pass 0 == a *x**2 + b...
ec035920c0b3d7fb886a5488fca3ba524f2c4c19
lmendez2/mis3640
/filedemo.py
741
3.5625
4
import os # fout = open('output.txt', 'w') # line_1= "how many roads must a man walk down \n" # fout.write(line_1) # line_2="before you cal him a man?" # fout.write(line_2) # fout.close() # print(os.path.exists('output.txt')) # print(os.path.isdir('exercises')) # def walk2(dirname): # """Prints the names of ...
29a6694265480001d2026137ba6837b7119733be
NicholasColonna6/CS-115
/Labs/lab4/lab4.py
866
3.75
4
''' "I pledge my honor that I have abided by the Stevens Honor System" ncolonna Created on Sep 28, 2017 @author: Colonna ''' def knapsack(capacity, itemList): '''returns both the max value and list of items that make this value without exceeding the capacity of the knapsack''' if itemList == []: ...
0cf29bd67c3622a8c6feeb4703bec041970f479e
zgwxh111/fun
/Data Structre & algorithm/function.py
3,354
3.5625
4
#!/usr/bin/env python # @Author : pengyun def convert(n, x): """ 在短网址系统会使用到这样的一个转化,将一个大的十进制数转化为一个 短的高进制的数。常用的转化是62进制。[Aa-Zz, 0-9] N 进制转化, 直接使用ascii码中的字符来代替了。 :param n: N进制 :param x: 一个十进制的数 :return: >>>convert(62, 563453245) V8;iS """ tmp = [chr(48+i) for i in range(n)] ...
55b20ca41e543233e4fb7ba479ac3093a8b3b07d
Mauricio-Fortune/Python-Projects
/randturtle.py
1,964
4.25
4
# Mauricio Fortune Panizo # COP 2930 # Python turtle with random number # 09/10/12 import turtle import random #what do they want to draw shape = (input("Do you want a rectangle, triangle, or both?\n")) turtle.pencolor("violet") turtle.fillcolor("blue") #Rectangle if shape == "rectangle" or shape == "Rectangle" or ...
ef1052bf7aadedfa0608e71629a892109832bfca
rleon5/Year-9DesignCS-PythonRL
/CylinderVolGUI.py
980
4.09375
4
import tkinter as tk import math # When you are dealing with event driven programming the program sits and waits for the user # to do something. These are programs where you click a button and something happens. What we # we do is BIND a function to a key. So when we click the button the function runs. # def submit...
0d2d8d9d895454cfc0c7fe2ca4ff0163349bbc24
jonte450/Intro_to_python
/Lesson_4/Conditional_Statements.py
448
3.640625
4
points = 174 # use this input to make your submission result = "" if points>=1 and 51 > points: result = "Congratulations! You won a wooden rabbit!" elif points>=51 and points < 151: result = "Oh dear, no prize this time." elif points>=151 and points < 181: result = "Congratulations! You won a...
3c757e0e0ab2e6b6a48b8f0cc4e4a4b2360afb36
SarveshMohan89/Python-Projects
/grade.py
580
4.375
4
score = input("Enter Score: ") try: score=float(score) except: print("Enter a valid value") quit() if score >=0.9: print("A") elif score >=0.8: print("B") elif score >=0.7: print("C") elif score >=0.6: print("D") elif score <0.6: print("F") # Write a program ...
8d5b7d048e87d6fdd6fc7e7c09f60a2d3b17439e
SarveshMohan89/Python-Projects
/Pay.py
564
4.28125
4
hrs = input("Enter Hours:") h = float(hrs) rate = input("Enter Rate:") r= float(rate) if h <= 40: pay = h * r elif h > 40: pay = 40*r + (h-40)*r*1.5 print (pay) #Write a program to prompt the user for hours and rate per hour using input to compute gross pay.Pay the hourly rate for the hours up to 4...
b14a58d0b87b704cd600c0fcc24b3dd24bea123d
cinxdy/Python_practice
/Python_Workbook/H03.py
975
3.515625
4
from random import * lotto_com = [0 for i in range(6)] lotto_user = [0 for i in range(6)] count = 0 i=0 while i!=6 : lotto_user[i]=int(input("%dth lotto number "%(i+1))) if lotto_user[i]>45 or lotto_user[i]<1 : print("Wrong!") else : dup = 0 for j in range(i) : if lot...
d3ae7e749cf00e71216ff34c67d45aae94d2d4cd
cinxdy/Python_practice
/Python_Workbook/A06.py
209
3.828125
4
kor = int(input("Input kor point ")) eng = int(input("Input eng point ")) math = int(input("Input math point ")) total = kor+eng+math average = total / 3 print("total is ",total) print("average is ",average)
5114d9694d7c4d2f83dd2775e2da7bb409c3a789
cinxdy/Python_practice
/Python_Workbook/D09.py
174
3.78125
4
while 1 : dan = int(input('dan?')) if dan <2 or dan>9 : print('Wrong!') else : for i in range(1,10) : print(dan,'X',i,'=',dan*i) break
50f6055dc26cc270a29d24a88812b4c252f92e61
cinxdy/Python_practice
/Python_Workbook/K04.py
808
3.671875
4
def load_point(filename): newlist=[] file = open(filename,"r") while 1 : list = file.readline().strip().split() if len(list)==2 : newlist.append([float(list[0]),float(list[1])]) else : break file.close() return newlist def get_area(x,y): if x==0 or y==0 : re...
d205b053a465555d40ae6b5c88d2de620fe00599
cinxdy/Python_practice
/Python_Workbook/F07.py
620
3.65625
4
number = [] floor_total = [0 for i in range(5)] line_total = [0 for j in range(3)] total = 0 #input for i in range(5): number.append([]) for j in range(3): newnum = int(input("%d0%d-ho person "%(i+1,j+1))) number[i].append(newnum) total += number[i][j] #sum for i in range(5): for ...
9054213d9c841a3b76c2f2119fa94feb4f9e689d
cinxdy/Python_practice
/Python_Workbook/H01.py
347
3.921875
4
from random import * count = 0 answer = randint(1,100) while 1: number_try = int(input("Try guess number between 1 and 100 ")) count+=1 if number_try > answer : print("answer is smaller number") elif number_try < answer : print("answer is bigger number") else : print("You got it! try count...
cb0cd132a4af328cb1007a0ece0b6f6935f5c240
cinxdy/Python_practice
/Python_Workbook/B08.py
534
4.1875
4
num1 = int(input('number 1?')) num2 = int(input('number 2?')) num3 = int(input('number 3?')) if num1==num2 or num2==num3 or num1==num3 : print('condition1 satisfied') if (num1>50 and num2>50) or (num2>50 and num3>50) or (num1>50 and num3>50) : print('condition2 satisfied') if num1+num2 == num3 or num2+num3 == ...
8a45588c47f236882b3eca1a0c4fd71c20c091fe
cinxdy/Python_practice
/Python_Workbook/H07.py
567
3.8125
4
from math import * number = [0 for i in range(10)] bunsan = [0 for i in range(10)] total = 0 total_bunsan = 0 number = list(map(int,input("Input 10 numbers between 1 and 100 : ").split())) for i in range(10) : total += number[i] average = total / 10 for i in range(10) : bunsan[i] = pow(number[i]-average,2) ...
e68046196688181ff057832a62bccca08b827556
cinxdy/Python_practice
/Tutor/yesul.py
270
3.65625
4
digit=int(input("큰 수를 입력하세요")) a=digit i=0 b=0 Sum=0 while a > 1 : a/=10 #a=a/10 i+=1 a=digit plus = i while plus != 0 : b= a//(10**plus) print (b,"+",end='') a=a-(10**plus*b) plus-=1 Sum+=b #print(Sum) print("=",Sum)
8554bd706b51b6a20ff638c6cebc47266c614be0
cinxdy/Python_practice
/Python_Workbook/C08.py
434
4.09375
4
num1 = int(input('number 1?')) num2 = int(input('number 2?')) num3 = int(input('number 3?')) if num1 > num2 : if num1 > num3 : max_num = num1 else : max_num = num3 else : if num2 < num3 : max_num = num3 else : max_num = num2 if num1 < num2 : if num1 < num3 : min_num = num1 else : min_num = nu...
534c295e1cf3e32e358a01c89a71d386969756b1
cinxdy/Python_practice
/Python_Workbook/I02.py
338
3.796875
4
def PrintCharWithBlank(blanks,size,ch) : for i in range(1,size) : for j in range(1,blanks+size-i) : print(" ",end='') for j in range(i) : print(ch,end='') print() ch = input("Character : ") size,blanks = map(int,input("Height and Blanks : ").split()) PrintCharWithBla...
86df435b692cb465c9047686125e0ac38c368919
league-python-student/level0-module4-Isaacpants
/_02_boolean/_b_sleepy_head.py
1,969
4.03125
4
""" Use boolean variables to control program logic between two different code paths. """ import turtle from tkinter import messagebox, Tk from turtle import Turtle if __name__ == '__main__': window = Tk() window.withdraw() isaac = turtle.Turtle() weekend_var1 = True test_passed = True game_o...
296f84561e7412b877e8ecfdbab65ba0a980ce44
nobbirahmed/weightedrandom
/weightedrandom_49.py
2,375
3.703125
4
# weighted random practice import random import sys #https://stackoverflow.com/questions/1761626/weighted-random-numbers def break_list(lst, size): total = 0 result = [[]] for v in lst: total += len(v) if total <= size: result[-1].append(v) else: ...
84ebf844fec7847104ee4e4a859e9105feae4723
MiguelMadero/DeepLearningLifeSciences-code
/ch6/tf_binding.py
1,813
3.6875
4
import deepchem as dc import tensorflow as tf import tensorflow.keras.layers as layers features = tf.keras.Input(shape=(101, 4)) # In the keras version we're not specifying this... why and how? # labels = layers.Label(shape=(1)) # weights = layers.Weights(shape=(1)) prev = features for i in range(3): convLayer = ...
7ad623afcc80e5022e991686058164462e2e9a30
jkoelmel/zoo_dbms
/Python_interface/database.py
8,663
3.625
4
""" This file is a portable API to be used by python programs that must connect to any database system """ import pymysql import configparser class DB: # SQL Operations DROP_DATABASE = 0 DROP_TABLE = 1 CREATE_DATABASE = 2 CREATE_TABLE = 3 INSERT = 4 SELECT = 5 UPDATE = 6 DELETE = ...
f542d3c709ad58b5681128e05499647ef6a8d787
SeongYong-Kim/Python-practice
/컴언과제1.py
1,587
3.96875
4
#1 hour = 0 minute = 0 second = 0 seconds = int(input("Enter seconds >> ")) hour = seconds // 3600 minute = (seconds % 3600) // 60 second = (seconds % 3600) % 60 print("{0}시간 {1}분 {2}초".format(hour,minute,second)) #2 print("임진왜란은\n1592년('선조 25년')부터\n1598년까지 2차에 걸친\n'왜군의 침략'으로\n일어난 전쟁이다. ") #3 num1 = int(input("첫번째 ...
c9e62bc561a65f39c84fc3ffa9cf005c7b62f889
anruly/Recursive
/test.py
193
3.875
4
def recursion(i): # 定义函数 print(i) if i / 2 > 1: re = recursion(i / 2) print('返回值:', re) print('上层递归值:', i) return i recursion(10)
5c8df7eafc6fcbd7faf5cdaaafd1a1c883521673
SandervanNoort/mconvert
/mconvert/newtools/create_dir.py
736
3.6875
4
import os import shutil import six def create_dir(fname, remove=False, is_dir=False, is_file=False): """If the directory for fname does not exists, create it""" if not isinstance(fname, six.string_types): print("cannot create_dir for {0}".format(fname)) return dirname = os.path.dirname(f...
c09be56ffce0eacd83483a84b5a6d1fbc2c90a8d
SandervanNoort/mconvert
/mconvert/newtools/normalize.py
844
3.625
4
import re import unicodedata import six def normalize(name): """Remove non-ascii strings""" # the input should by unicode if not isinstance(name, six.text_type): name = name.decode("utf8") # a unicode compatible with ascii output = unicodedata.normalize('NFKD', name) output = output....
99fb5b9ab621f42625732be923a803bd55e49d28
SandervanNoort/mconvert
/mconvert/tools.new
1,427
3.515625
4
#!/usr/bin/env python3 # -*-coding: utf-8-*- """Tools""" from __future__ import (division, absolute_import,unicode_literals, print_function) import collections class SetList(list): """Class which keeps all elements unique""" def __init__(self, init_list=None): list.__init__(...
b3a4b7c69512309479c0dfdceecf6331a494fe51
Workshopshed/EnchantedObjects
/Code/Examples/Python/GuessPrecipitation.py
1,337
3.9375
4
# Take the two command line arguments and generate a 1 to 5 rating of it it will rain # See http://www.tutorialspoint.com/python/python_command_line_arguments.htm import sys, getopt def guess_weather(rel_humidity, temp): # Temperature in Degrees C and Relative Humidity as a percentage # Based on an approximat...
ad48f86163e28512fd006f6f9ac9c857f493800a
pBouillon/codesignal
/arcade/intro/3_Exploring_the_Waters/arrayChange.py
1,100
3.75
4
""" You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a strictly increasing sequence from the input. Example For inputArray = [1, 1, 1], the output should be arrayChange(inputArray) = 3. Input/Output...
fa757a907024fabdf8c6eca41cb99a5ad539fd6f
pBouillon/codesignal
/arcade/intro/3_Exploring_the_Waters/palindromeRearranging.py
757
4.25
4
""" Given a string, find out if its characters can be rearranged to form a palindrome. Example For inputString = "aabb", the output should be palindromeRearranging(inputString) = true. We can rearrange "aabb" to make "abba", which is a palindrome. Input/Output [execution time limit] 4 seconds (py3) [input...
fc9291c1515757f676224610d815c283b70af940
pBouillon/codesignal
/arcade/intro/4_Island_of_Knowledge/arrayMaximalAdjacentDifference.py
703
4
4
""" Given an array of integers, find the maximal absolute difference between any two of its adjacent elements. Example For inputArray = [2, 4, 1, 0], the output should be arrayMaximalAdjacentDifference(inputArray) = 3. Input/Output [execution time limit] 4 seconds (py3) [input] array.integer inputArray ...
46e7b658c7f7d1e5cbe22662800a9eedf480148a
pBouillon/codesignal
/arcade/python/1_Slithering_in_Strings/Convert_Tabs.py
1,221
4.28125
4
""" You found an awesome customizable Python IDE that has almost everything you'd like to see in your working environment. However, after a couple days of coding you discover that there is one important feature that this IDE lacks: it cannot convert tabs to spaces. Luckily, the IDE is easily customizable, so you d...
1465736da62e4c627db1170adcaac7dd461bc4b9
pBouillon/codesignal
/arcade/the_core/2_Corner_of_0s_and_1s/Array_Packing.py
1,084
3.984375
4
""" You are given an array of up to four non-negative integers, each less than 256. Your task is to pack these integers into one number M in the following way: The first element of the array occupies the first 8 bits of M; The second element occupies next 8 bits, and so on. Return the obtained integer M. ...
15bdbb2e3120415aff51a54aa2f5c31486ca94f5
pBouillon/codesignal
/arcade/python/4_Complexity_of_Comprehension/Cool_Pairs.py
1,290
3.984375
4
""" A pair of numbers is considered to be cool if their product is divisible by their sum. More formally, a pair (i, j) is cool if and only if (i * j) % (i + j) = 0. Given two lists a and b, find cool pairs with the first number in the pair from a, and the second one from b. Return the number of different sums of ...
d9dafdd492d3d28036bae95508f9bc80582eca24
pBouillon/codesignal
/arcade/the_core/2_Corner_of_0s_and_1s/Mirror_Bits.py
505
4.1875
4
""" Reverse the order of the bits in a given integer. Example For a = 97, the output should be mirrorBits(a) = 67. 97 equals to 1100001 in binary, which is 1000011 after mirroring, and that is 67 in base 10. For a = 8, the output should be mirrorBits(a) = 1. Input/Output [execution time...