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
b9d23b8cb920e36f0bba01562c09da5d0f20bab8
codafett/python
/uncategorised/mileage.py
157
3.953125
4
print('Howe many kilometers?') kms = input('Enter kilometers: ') mls = round(float(kms) / 1.60934, 2) print(f'Ok, {kms} kilometeres is equal to {mls} miles')
f6ed8f161cea14cb794fe38de7ab8bcc7377a2f3
codafett/python
/uncategorised/scream.py
79
3.703125
4
times = int(input('How many times? ')) for n in range(times): print('Eejit!')
9a9ba9fd40e64c706627c92c7aa8af3b6de1f5fe
codafett/python
/uncategorised/single_letter_count.py
228
3.75
4
def single_letter_count(word, letter): return word.upper().count(letter.upper()) print(single_letter_count("Hello world", "h")) print(single_letter_count("Hello world", "z")) print(single_letter_count("Hello world", "l"))
b7f9295b252877ba77302e0a21f258716f98021a
alvinlao/force
/module2/project/pi/tests/gen_test.py
1,277
3.578125
4
import sys import math import random def getnoise(noise, x, y): x += random.randint(-1, 1) * noise y += random.randint(-1, 1) * noise return (x, y) def line(noise=0, accuracy=30): x = 0 y = 0 while(x < 320 or y < 240): if x < 320: x += 1 if y < 240: ...
38843ec0609717fe9e6e8dd02941d97bf1738afe
nismod/water_demand
/water_demand/main.py
2,690
3.8125
4
from typing import Union, Sequence from numbers import Number import numpy as np class WaterDemand: """ Simulate water demand based on a linear relationship between population size and water demand, plus a constant demand. This class is constructed with a sequence representing populations at arb...
100a71e4821d7c20563f41ed7c08907592f1585d
pradnyahaval/project_ppl
/py_assignments/Assignment_1/randomguess.py
414
3.984375
4
import random i=1 a=random.randint(0,9) print("You have total 5 chances to guess the number(between 0 and 9)") while i<=5: b=int(input("Guess the number\t")) if a==b: print("Correct guess!") break else: if a<b: print("entered number is more than actual number")...
7f6aa980161e2d8a05256b9a92aad58a80a9b505
pradnyahaval/project_ppl
/py_assignments/Assignment_1/dice.py
218
3.90625
4
import random i=1 while i>0: print("Output after rolling the dice:") print(random.randint(1,6)) print("\n") a=input("Do you want to roll it again? y or n\n") if a=='n': break
e9741eb199ece976fe5489d6d90705563e87cbcb
ylambda/advent-of-code-2020
/day02/solution.py
912
3.515625
4
db = [] with open("./input.txt") as f: for line in f.read().strip().splitlines(): rules, password = line.split(":") password = password.strip() rules, letter = rules.split(" ") minimum = int(rules.split("-")[0]) maximum = int(rules.split("-")[1]) db.append([password...
1f4114e2b7a25cf299f96d8c04689a7f7329e391
wuageluolaoshi/shiyanluo
/ageRange.py
331
3.84375
4
import sys age = int( sys.argv[1]) if 0 <= age and age< 10: print("you belong to kids") elif 10 <= age and age <18: print("you belong to teenageer") elif 18 <= age and age < 30: print("you belong to adult") elif 30 <= age and age < 60: print("you belong to older") elif 60 <= age and age < 120: print("you belong t...
5e39c566615dcba5941fa860cf6b5836ce6be8df
victortd/Deep_RL_Portfolio_Management
/final_code/RandomAgent.py
1,435
3.8125
4
import numpy as np DEFAULT_NUMBER_OF_ASSETS = 10 class RandomAgent: def __init__(self, history_length = 5, number_of_assets = DEFAULT_NUMBER_OF_ASSETS, keeping_proportion=.9): """Init a new agent. """ self.time = 0 self.history_length = history_length self.histo...
697a943b2cceb74f2503fd1130bd3fa263ff57cf
Robbot/Teclado
/The Complete Python/Section1/main.py
1,533
4.28125
4
# Coding exercise 2 name = input("What is your name? ") print(f"Hello, {name}") age = int(input("What is your age? ")) print(f"You are {age*12} months old") # Coding exercise 3 nearby_people = {'Rolf', 'Jen', 'Anna'} user_friends = set() #This is an empty set friend = input("What is the name of your friend? ") user_fr...
9e52749f436d5f61ae2e1294df70f71ce94e6659
dyedefRa/python_bastan_sona_sadik_turan
/03_Python_Operatorler/05_logical.py
296
3.71875
4
x = 6 hak = 5 devam = 'e' result = 5 <= x < 10 # and result = (x >= 5) and (x < 10) result = (hak>0) and (devam == 'e') # or result = (x>0) or (x % 2 ==0) # not result = not(x>0) # x, 5-10 arasında olan bir çift sayı mı ? result = ((x>5) and (x<10)) and (x % 2 == 0) print(result)
896785f9a67cae451dd0cc416ffc28e3f1afa9a3
dyedefRa/python_bastan_sona_sadik_turan
/06_Python_Fonksiyonlar/04_function-demos.py
2,127
3.8125
4
# 1- Gönderilen bir kelimeyi belirtilen kez ekranda gösteren fonksiyonu yazın. ''' word = input('word : ') count = int(input('count : ')) def yazdir(word,count): for n in range(0,count): print(word) yazdir(word,count) def yazdir2(word,count): print(word*count) yazdir2(word+'\n',count) ''' # 2- Kend...
386c9441e9591bdf394679d934333fd91467afa7
dyedefRa/python_bastan_sona_sadik_turan
/09_Python_Hata_Yonetimi/03_errors-demo.py
1,980
3.90625
4
liste = ["1", "2", "5a", "10b", "abc", "10", "50"] # 1: Liste elemanları içindeki sayısal değerleri bulunuz. ''' for item in liste: try: result = int(item) print(result) except ValueError as ex: continue ''' # 2: Kullanıcı 'q' değerini girmedikçe aldığınız her inputun sayı ...
3c197d6f1421e13bc5e77c54ab37fab85586d37e
dyedefRa/python_bastan_sona_sadik_turan
/06_Python_Fonksiyonlar/07_bankamatik.py
1,374
3.578125
4
# Bankamatik Uygulaması sadikHesap = { 'ad' : 'Sadık Turan', 'hesapNo' : '13245678', 'bakiye' : 3000, 'ekHesap' : 2000 } metinHesap = { 'ad' : 'Metin Oğuzhan', 'hesapNo' : '12345678', 'bakiye' : 3000, 'ekHesap' : 2000 } def paraCek(hesap, miktar): print(f"Merhaba {hesap['ad']}") ...
89e3546cabc88e7e6ba930f5ffe610bf6e13f97b
dyedefRa/python_bastan_sona_sadik_turan
/03_Python_Operatorler/04_comparison-demo.py
1,438
4.03125
4
# 1 - Girilen 2 sayıdan hangisi büyüktür ? ''' sayi1 = int(input("1. Sayı : ")) sayi2 = int(input("2. Sayı : ")) result = (sayi1 > sayi2) print(f"sayı 1 : {sayi1} Sayi 2 : {sayi2} den büyüktür : {result}") ''' # 2 - Kullanıcıdan 2 Vize (%60) ve Final (%40) notunu alıp ortalama hesaplayınız # Eğer ortalama 50 ve ü...
f6423a9c77bc97d4b4ed0ba8f26add555fc84b4d
ericojonathan/piintu
/Part_B/t3/largest.py
681
3.84375
4
def heap(a, size, largest=0): if size == 1: nArr = [] for i in a: nArr.append(str(i)) sep = '' sep = sep.join(nArr) if largest < int(sep): largest = int(sep) return largest for i in range(size): largest = heap(a, size-1, largest) ...
f71105cbe8a511fdeda6da71ab936021e7b18c42
AlexLB97/Graphical_Arrow_Scoring
/GST.py
5,765
4.0625
4
#Pseudocode #initiate graphics window #window is 500 x 1000 #window name is Target Plot #draw a target of predetermined size #create a button function that will zoom in #create a function that allows you to plot a predetermined number of arrows #create another function that allows the user to plot any number o...
b1b1155244c22fd2bef7b410307277f1d107b91c
RTR108/LD24H
/242.py
604
3.59375
4
from Tkinter import * import time # Create objects w = Tk(); f = Frame(); f.pack() time_var = StringVar() time_labelis = Label(f, textvariable=time_var, font="Courier 60", bg="Black", fg="#00B000") time_labelis.pack() # Create function for flashing def mirgot(): """Funkcija datu atjaunoshanai""" t = time.lo...
8fbc9cd8acac4daf6d8174b326e9b2bfdfc0a94e
oguzcam58/swe545AsynchronousServerClient
/client.py
2,178
3.625
4
#!/usr/bin/env python import socket # Import socket module import threading # Import threading module # ------------------------Client------------------------ class Client: threadCounter = 0 # Give number to threads def __init__(self): self.connection = socket.socket() # Create a socket object self.host = socket...
d6f55ebdcbe46d746a125c62cc518e8dcfe28f2b
JriteFS/DPFWP
/Week 3/Reusable Library Assignment/lib.py
1,648
3.703125
4
__author__ = 'jacobritenour' class FavoriteCars(object): def __init__(self): self.__car_list = [] def add_car(self, m): self.__car_list.append(m) def compile_list(self): output = '' for car in self.__car_list: #for each of the movies added output += 'Make: ' +...
f8fffaea0ee7965387ab52cfc5a8f45725cc463f
johnahnz0rs/CodingDojoAssignments
/python/python_fundamentals/hello_world.py
209
4.03125
4
# x = "Hello World! johnahnz0rs is l33t" # print x # y = 42 # print y num = 42 print 'a number:', num # a number: 42 print 'this is a number: ' + num # TypeError: cannot concatenate 'str' and 'int' objects
12c8f2225bd6d6426fe2d69abfeab96343a7dc29
johnahnz0rs/CodingDojoAssignments
/python/python_OOP/hospital.py
3,665
3.59375
4
class Patient(object): PATIENT_ID = 0 def __init__(self, name, allergies): self.patient_id = Patient.PATIENT_ID Patient.PATIENT_ID += 1 self.name = name self.allergies = allergies self.bed_number = None class Hospital(object): def __init__(self, name, capacity): ...
d5b582a3938073bfb5355322b4fe492b41de1d73
johnahnz0rs/CodingDojoAssignments
/python/python_fundamentals/scores_and_grades.py
829
4.3125
4
# Write a function that generates ten scores between 60 and 100. Each time a score is generated, your function should display what the grade is for a particular score. Here is the grade table: # Score: 60 - 69; Grade - D # Score: 70 - 79; Grade - C # Score: 80 - 89; Grade - B # Score: 90 - 100; Grade - A def scor...
c7dc7945f40f90865352e831416adde1e46f2332
alphagov-mirror/land-availability-import
/utils.py
895
3.671875
4
import time def transform_polygons_to_multipolygon(polygons): '''This method expects the Polygons ins GeoJSON format and will return a MultiPolygon in GeoJSON format too. ''' if len(polygons) == 0: return None multipolygon = { "type": "MultiPolygon", "coordinates": [ ...
141b7db9fdbd2459b33c2f26dc335e4856df3b7c
shunanl/my_pieces
/LRUCache.py
3,416
3.859375
4
class Entry: """Doubly-linked list entry class""" def __init__(self, key, val): self.key = key self.val = val self.prev = None self.next = None class DoublyLinkedList: """Doubly-linked list class""" def __init__(self): self.tail = None self.head = None ...
8dd895f1673b15f139be211d8a3efcb86c0c10f7
jazperez/data-structures-and-algorithms
/Python/chapter03/3.3 - Stack of Plates/Nick.py
3,689
3.765625
4
#!/usr/bin/python3 import unittest from random import randint class SetofStacks: def __init__(self, limit=5): self.stack = [] self.pointer = None self.limit = limit def length(self): if self.pointer is None: return 0 else: tlength = self.pointe...
4f80d2170d2a291f80f8ab41beefda8f8ef846b3
Yerkezhan91/seminar3
/linked_class.py
428
3.5
4
class MyQueue: def __init__ (self): self._qList=list() def isEmpty(self): return len(self)==0 def __len__(self): return len(self._qList) def enqueue(self,item): self._qList.append(item) def dequeue(self): assert not self.isEmpty(),"Cannot dequeue from an empt...
1156ac4fbd493c5c8b0a5026749901b093b1b09c
keyduq/programming-practices
/elementary/python/ej4.py
216
4.0625
4
# Write a program that asks the user for a number n and prints the sum of the numbers 1 to n n = int(input('Ingrese un numero: ')) total = 0 for i in range(n + 1): total += i print('La suma total es:', total)
71e372f9334ff3f23acb8403362c300ea6233dae
VSUA/Hacker
/Problems/Flower shop/task.py
190
3.8125
4
import itertools # flower_names = ['rose', 'tulip', 'sunflower'] for i in range(0, len(flower_names)-1): for flowers in itertools.combinations(flower_names, i+1): print(flowers)
a4882078a29b57e59fbffcce47b8469c03589cd4
nd-cse-34872-su21/cse-34872-su21-examples
/lecture01/exercise01-D/solution.py
635
3.734375
4
#!/usr/bin/env python3 import sys # Functions def read_matrix(): n = int(sys.stdin.readline()) return [list(map(int, sys.stdin.readline().split())) for _ in range(n)] def find_max_row(matrix): max_row, max_sum = 0, 0 for cur_row, cur_numbers in enumerate(matrix, 1): cur_sum = sum(cur_numbers...
92fc4eefd9db5809d21777fb2580712e83b3ed83
nd-cse-34872-su21/cse-34872-su21-examples
/lecture03/exercise03-A/template.py
312
3.90625
4
#!/usr/bin/env python3 # Perfect Square import sys def is_perfect_square(n): # TODO: Use binary search to determine if n is a perfect valid square return False def main(): for n in map(int, sys.stdin): print('Yes' if is_perfect_square(n) else 'No') if __name__ == '__main__': main()
f671682daf32bc810dde132de01a0e66d86d6920
nd-cse-34872-su21/cse-34872-su21-examples
/lecture02/exercise02-A/solution.py
740
4
4
#!/usr/bin/env python3 import collections import sys # Functions def is_anagram_count(s, t): sc = [0]*26 tc = [0]*26 for c in s: sc[ord(c.lower()) - ord('a')] += 1 for c in t: tc[ord(c.lower()) - ord('a')] += 1 return sc == tc def is_anagram_sorted(s, t): return sorted(s.lower()) == sorted...
30ef3b36e9f9dddbf5526b068c1451796e78da89
nd-cse-34872-su21/cse-34872-su21-examples
/lecture02/cheatsheet.py
366
4.25
4
#!/usr/bin/env python3 v = [1, 2, 3] # Create dynamic array v.append(4) # Append to back of array v.insert(0, 0) # Prepend to front of array print(len(v)) # Display number of elements for e in v: # Traverse elements print(e) # Traverse elements with index for...
0b83470ee7727e1a25e0c1164ea0bd7abe5b305c
nd-cse-34872-su21/cse-34872-su21-examples
/lecture04/exercise04-A/solution.py
494
3.765625
4
#!/usr/bin/env python3 import collections import sys # Functions def is_palindromic(s): ''' Counting Solution ''' # counts = collections.Counter(s) counts = {} for c in s: counts[c] = counts.get(c, 0) + 1 odds = 0 for count in counts.values(): odds += count % 2 return o...
16b747cfc9692b4d79d47af5ebcc35715c55c883
Reginaaaaaaaa/python
/homework/homework.py
273
3.859375
4
def even(n): i = 2 array = list() while i <= n: array.append(i) i += 2 return array def odd(n): i = 1 array = list() while i <= n: array.append(i) i += 1 return array print(even(50)) print(odd(50))
a66f65229d2b9e950c0c49814f21c73961449977
Reginaaaaaaaa/python
/lesson/lesson11.09.2.py
239
4.0625
4
def up_low(string): uppers = 0 lowers = 0 for char in string: if char.islower(): lowers += 1 elif char.isupper(): uppers +=1 else: pass return(uppers, lowers) print(up_low('Hello, my name is Jenny'))
fced373016433ed97ddc18fe23b80dd0e3e61fbd
Reginaaaaaaaa/python
/lesson2/les22.py
692
3.59375
4
#рекурсивная функция #def f(): # f() def f(n): print(n) if n>0: f(n-1) print(f(10)) def f(n, m): print(n) if n>m: f(n-1, m) print(f(6,5)) def fac(n): if n == 0: return 1 if n == 1: return 1 return fac(n-1) * n print(fac(6)) def f(...
e8020b154217f086176c6daa3ca2c11b75a6a6d6
Reginaaaaaaaa/python
/homework/16.09.2021.py
1,318
3.9375
4
def validate_number(a): if len(a) !=16: return False if a[0:3] !='+7-': return False if a[6] !='-' or a[10] !='-' or a[13] !='-': return False ba = a[3:6] + a[7:10] + a[11:13] + a[14:] digits = '0123456789' for sym in ba: if not sym in digits: return F...
5d4516ee49c856b156140192a0a9c1ca7a40e323
sancho-mgn/sports_programming
/MaximumDiscount.py
208
3.65625
4
def MaximumDiscount(N, price): price = sorted(price, reverse=True) return sum(price[i] for i in range(2, len(price), 3)) # print(MaximumDiscount(7, [100, 350, 500, 250, 200, 50, 400, 435, 23]))
a1d7bb44ecb1fe08dffdad7860dfc554896e065a
MatthewWest/PyBBIO
/examples/LiquidCrystal_glyphs.py
1,867
3.671875
4
""" LiquidCrystal_glyph.py Alexander Hiam <alex@graycat.io> An example to demonstrate the use of the LiquidCrystal library included with PyBBIO. Demonstrates creating and displaying custom characters. This example program is in the public domain. """ from bbio import * # Import the LiquidCrystal cl...
9df9ce4c51e0d880f5a693086a5935a97dbd60b3
noah-curran/CS422-PIoT
/server/command_line.py
2,126
4.0625
4
import sys import re from typing import Tuple MIN_PORT: int = 1024 MAX_PORT: int = 65535 def has_arg(index: int) -> bool: """Checks if there are at least `index + 1` arguments passed to the command line Args: index (int): The position of the expected argument Returns: bool:...
f1705276ec52154591de27009366f0e8c5e278be
anejaprerna19/LearninPython
/passwordchecker.py
396
4.25
4
#Password Checker Assignment from Udemy Course #In this simple assignment, we take user inputs for username and password and then calculate and print the length of password. username= input("What is your username? "); password= input("Enter the password "); pass_length= len(password) hidden_pass= '*' * pass_length pr...
64e5390ea42597cd73e501c604d46f025f5231d6
asud16/thirty_day_challenge
/chapter3.py
1,334
4.09375
4
# Exercises for chapter 3: Problems 3.1, 3.2, 3.3, and 3.4 in Think Python # Aparna Sud # 3.1) Moving the function call before the definitions doesn't yield any output but rather the following error message: NameError: name 'repeat_lyrics' is not defined. Python can't run the function before it's defined. # 3.2) How...
ab003941b8d8fa23e14a6206e198ecb03c312120
mbillard11/CodeAbbey
/CA_Arithmatic.py
305
3.515625
4
tot_lines = int(raw_input()) for i in range(0, tot_lines): line = raw_input() num = map(float, line.split()) base = num[0] incr = num[1] steps = num[2] total = 0 for x in steps: total = base + incr*x stepSum = stepSum + total print total,
33c9648dd5e0f5506706d5d3d1be94a3b9226223
kelvintiew/python_test
/PYD210.py
243
3.96875
4
side1 = eval(input()) side2 = eval(input()) side3 = eval(input()) #TODO if side1 + side2 > side3 and side2 + side3 > side1 and side3 + side1 > side2: print(side1 + side2 + side3) else: print('Invalid') """ Invalid """
e41528edddd98268df9b69f8e999363bfbd035c9
kelvintiew/python_test
/PYD201.py
196
4.09375
4
# TODO n = eval(input()) if n % 2 == 0: print('%d is an even number.' %n) else: print('%d is not an even number.' %n) """ _ is an even number. _ is not an even number. """
8e0a41c075b9ee28989db4015574221276afe24b
kelvintiew/python_test
/PYD802.py
201
3.734375
4
# TODO Str = input() Sum = 0 for i in range(len(Str)): print("ASCII code for '%s' is %d" %(Str[i], ord(Str[i]))) Sum += ord(Str[i]) print(Sum) """ ASCII code for '_' is _ """
251ed5e263204e33eadc9ab405d28ba7038ea7b3
yoavsharon80/WoG2
/MemoryGame.py
1,195
3.671875
4
import random from Utils import screen_cleaner as clear from Utils import interval def generate_sequance(difficulty): list_a = [random.randint(1,101) for i in range(difficulty)] print (list_a) #Dispaly numbers to player clear() print(list_a) for item in list_a: print(item) inter...
5708d9655020eb7e32c9fa8c4a9c0a970e70af1c
kenyihq/senati-algoritmia-foro
/console.py
6,361
4.0625
4
# Creamos una funcion el cual se imprime en consola, al correr el código def foro(): print(" RUTA OPTIMA ") print(" B ") print(" /|\ ") print(" / | \ ") print(" / | \ ") print(" F --|-- J ") print(" \ | / ") print(" \ | / ")...
f94cd72cd07d0cbcbfa10fd5a9c6b7413460fed7
isi-nlp/sbmt
/pipelines/scripts/syntax-mira/mira-features/tree.py
5,975
3.625
4
# tree.py # David Chiang <chiang@isi.edu> # Copyright (c) 2004-2006 University of Maryland. All rights # reserved. Do not redistribute without permission from the # author. Not for commercial use. import re class Node: "Tree node" def __init__(self, label, children): self.label = label self.c...
dbf44bba6263bb98d66f95f9e63f7acb55867d35
Kojoley/PlotMeNow
/test/test_numpy.py
378
3.578125
4
import numpy as np if __name__ == '__main__': a = np.empty([2, 0]) print a a = np.insert(a, 0, (2, 3), axis=1) print a a = np.insert(a, 0, (2, 3), axis=1) print a a = np.insert(a, 0, [8, 9], axis=1) print a a = np.empty([2, 0]) print a a = np.append(a, [2, 3], axis=1) ...
4a8231bd8f7602d8383f50057b8750220b1b2541
Kojoley/PlotMeNow
/test/test_arrays.py
218
3.765625
4
from numpy import * a = array([10,20,30,40]) append(a,50) print a append(a,[50,60]) print a a = array([[10,20,30],[40,50,60],[70,80,90]]) append(a,[[15,15,15]],axis=0) print a append(a,[[15],[15],[15]],axis=1) print a
2a204bb0df6b2482982e2e5b3e423b689a599e41
dusktreader/ambix
/ambix/utilities.py
469
3.5625
4
import collections import itertools def iter_not_string(val): """ Returns true if the argument is iterable but not a string """ return isinstance(val, collections.Iterable) and not isinstance(val, str) def compose_iters(*args): """ flattens iterables passed as arguments into a single iterabl...
a46860af4077867a47354b5e109e2715d09b529e
flinteller/unit_eleven
/paddle.py
1,653
3.90625
4
import pygame import random class Paddle(pygame.sprite.Sprite): def __init__(self, main_surface, color, height, width): """ This function creates creates a surface using each other params :param main_surface: :param color: :param height: :param width: """ ...
a3e4412796f1d5f1414ed1eb21e1f0013cbd0e73
Rafq77/Advent2015
/Advent2015/Day/Day22/d22.py
4,451
3.5625
4
import copy class Spell: def __init__ (self, Name, Cost = 0, TTL = 0, Dmg = 0, Heal = 0 , Armor = 0, Mana = 0): self.name = Name self.cost = Cost self.ttl = TTL self.dmg = Dmg self.heal = Heal self.armor = Armor self.mana = Mana def work(self, player, en...
63f2bc9c3c672fd76b389a541e5336de9a22833a
dhitalsangharsha/GroupA-Baic
/question7.py
597
4.0625
4
'''7) Write a python script to demonstrate at least 10 built in functions in Python.''' print("enter the intiger list items seperated by space") l= [int(x) for x in input().split()] print("your list is created as:",l) #to find the length of above list we use len function print("toral no. of items in the given list is...
839764c040251100e370a5b0f24b8c3e8044961f
dhitalsangharsha/GroupA-Baic
/question5.py
204
4.125
4
'''5) Take an arbitrary input string from user and print it 10 times.''' string=input("enter a string:") print("\nprinting {} 10 times ".format(string)) for i in range(1,11): print(str(i)+':',string)
fc46ee5a3d68857277ffca31aa3925943c139988
irffanasiff/100-days-of-python
/day5/range.py
382
4.1875
4
# for number in range(1, 10, 3): # print(number) # total = 0 # for number in range (1, 101): # total += number # print(total) #! sum of all the even numbers from 1 to 100 total =0 for number in range(0,101,2): total += number print(total) #? or total =0 for number in range (1,101): if number%2==0: ...
7da38f89ef9b81516f3afd520533f951e31d0d86
quick0831/QuickPython
/tkinter/Enter.py
490
3.703125
4
import tkinter as tk win=tk.Tk() win.title("Enter Something!") win.geometry("300x200") def insert_point(): var = u.get() t.insert('insert',var) def insert_end(): var = u.get() t.insert('end',var) b1 = tk.Button(win,text="insert point",width=15,height=2,command=insert_point) b1.pack() b2 = tk.Button(...
0d448884b93179fff70244f4096a18d8c52d43e7
quick0831/QuickPython
/Basic/array.py
241
4.09375
4
# List (so do tuple) a=[1,2,3,4,5] len(a) # 5 (The length of the list) a[3] # 4 a[0]=5 print(a[:3]) a[:3]=[] # delete[:3] print(a) # Use + to Merge List print("") data=[[3,4,5],[6,7,8]] print(data[0][1]) data[0][0:2]=[5,5,5] print(data[0])
34ea49406fdb07847f53afac521f8fe1cc49284c
Aden-Tao/LeetCode
/0140 Word Break II/solution.py
741
3.90625
4
#! python3 class Solution: def wordBreak(self, s, wordDict): """ :type s: str :type wordDict: List[str] :rtype: List[str] """ words = set(wordDict) mem = {} def wordBreak(s): if s in mem: return mem[s] res = [] ...
69d43fe81f41234ef26bf4b774b5ed3e10b2407f
Aden-Tao/LeetCode
/0049 Group Anagrams/solution.py
420
3.84375
4
#! python3 import collections class Solution: def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[str]] """ res = collections.defaultdict(list) for s in strs: res[tuple(sorted(s))].append(s) return list(res.values()) if __n...
7460a1c79f9f1564995ff410a9c868385f761a02
Aden-Tao/LeetCode
/0092 Reverse Linked List II/solution.py
1,335
3.703125
4
#! python3 class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseBetween(self, head, m, n): """ :type head: ListNode :type m: int :type n: int :rtype: ListNode """ dummy = ListNode(0) p, c...
68ceeb0a35ee5de2f89d64d842496f112689b9ed
florinbrd/PY--
/python developer zero to mastery/Practice Exercises - pynative.com/Basic Exercises/Exercise10.py
509
4.15625
4
# Question 10: Given a two list of ints create a third list such that should contain only odd numbers from the first list and even numbers from the second list def odd_list(list1, list2): list3 = [] for item1 in list1: if item1 % 2 == 0: list3.append(item1) for item2 in list2: ...
5d2ac7e730a592f9063af6ae5366608611060c67
florinbrd/PY--
/python developer zero to mastery/Practice Exercises - pynative.com/Basic Exercises/Exercise02.py
398
4.3125
4
# Question 3: Accept string from the user and display only those characters which are present at an even index def even_char(string_defined): print(f'Your original string is: {string_defined}') for item in range(0, len(string_defined)-1, 2): if item % 2 == 0: print("index[", item,"]", strin...
15391ac66439e953359235d920668a5b112f986a
alvarillo89/collaborative-filtering
/collfilter.py
6,599
3.6875
4
# -*- coding: utf-8 -*- import pandas as pd import numpy as np class CollaborativeFilter: """ This class includes methods for building a neighborhood and making recommendations to users based on collaborative filtering """ def __init__(self, user_ratings, items_info): """ Build an obj...
7fb6a8889558df9744d201dec90ce079a7a8f50c
kathhuynh94/python-challenge
/PyPoll/pypoll_hw.py
1,300
3.671875
4
import os import csv total_vote = 0 popular_vote = 0 winner = None # Set path for file path = "C:/Users/Admin/Documents/UofA-PHX-DATA-PT-11-2019-U-C/03-Python/Homework/Instructions/PyPoll/Resources" filename = "election_data.csv" csv_file_path = os.path.join(path, filename) with open(csv_file_path, 'r') as csv_file:...
2a3b907b3e51cc8372db5ef875f2717a221427e5
bing-zhao/springboard-capstone1-home-risk
/src/data/func_df_col_names_by_type.py
2,462
3.765625
4
# function to return and print the data types of columns within a dataframe def func_df_col_names_by_type(df, flag_print = False): """function to return and print the data types of columns within a dataframe Keyword arguments: df (dataframe), flag_print (default = False); Return: cols_dict (dictionary), cols_d...
f29dac2d9b32cf4edd286aacf0fad81435d73f28
bing-zhao/springboard-capstone1-home-risk
/src/visualization/func_eda_df_hist_by_label.py
1,218
3.5625
4
# function to plot the normalized probability density distribution colored by label def func_eda_df_hist_by_label(df_X, Y, normal=False, figsize=(8,6), prefix='', dir_png='../reports/figures/'): """function to plot the normalized probability density distribution colored by label Keyword arguments: df_X (feature...
77f65fd43bd51bc8ae2c59c8342d5798ab8513c0
rgion/Python-P6
/P6E1.py
394
4.25
4
#P6 E1 - rgion #Escribe un programa que te pida palabras y las guarde en una lista. #Para terminar de introducir palabras, simplemente pulsa Enter. #El programa termina escribiendo la lista de palabras. palabra=input("Escribe una palabra: ") lista=[] while (palabra!=""): lista.append(palabra) palabra=input("Esc...
8ba15361440b980c27bdc1ddd6c35a554af4f28e
rgion/Python-P6
/P6E11.py
923
4.21875
4
#P6 E11 - rgion #Escribir un programa para jugar a adivinar un número #(el ordenador "piensa" el número y el usuario lo ha de adivinar). #El programa empieza pidiendo entre qué números está el número #a adivinar, se "inventa" un número al azar y luego el usuario #va probando valores. El programa va decidiendo si son de...
b03bac6e4b054aa0e35e97bc01d36cf397bcd237
arizephyr123/Graphs
/projects/adventure/player.py
1,235
3.578125
4
class Player: def __init__(self, starting_room): self.current_room = starting_room def travel(self, direction, show_rooms = False): next_room = self.current_room.get_room_in_direction(direction) if next_room is not None: self.current_room = next_room if (show_room...
e5c854347cc72a335a437de78eaac2929dc94e45
lizzie483/cansat-rover
/navigation-control/robot.py
1,312
3.5625
4
import math class Robot(): def __init__(self, left_motor, right_motor, left_encoder, right_encoder): self.x = 0 self.y = 0 self.theta = 0 self.wheel_radius = 0.139 self.wheel_base_length = 0.212 self.max_left_wheel_speed = 7.48 self.max_right_wheel_speed = 7....
c55de30866091747d5fcac35734d4c38d0e8154b
khuang7/python3_thehardway
/ex18.py
413
4.125
4
def print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}. arg2: {arg2}") #*args is actually pointless we can just do def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2: {arg2}") # this just takes one argument def print_one(arg1): print(f"arg1: {arg1}") def print_none(): print("I got nothin") prin...
c34254a66bb829922bc38ff788160ddaf690865f
MajdVictor/pythonExamples
/bank.py
565
3.59375
4
class Account(): def __init__(self,owner,balance): self.owner = owner self.balance = balance def __str__(self): return f'Account Owner: {self.owner}\nAccount Balance: ${self.balance}' def deposit(self,amount): self.balance += amount print('Deposit Accepted!') ...
0b73de6e9b1a1fb071e77d6aebb416b46ea58809
mrforgotten/99internshipio
/q2.py
764
4.0625
4
import math def isPrime(number): if(number<=1): return False; elif(number ==2): return True sqr = int(number**(1/2))+1 pme = [True]*sqr for i in range(2,sqr,1): if(pme[i]): if(number % i==0): return False for j in range(i+i,sqr,i): ...
05b6e01143d86c81f7911cdbecb39aa324c8dec3
girdharkrs/PythonLearning
/HelloWorld01.py
342
4.03125
4
##import pygame print("Hello World, Hi My name is Arnav Sharma ") x = 2 y = 3 print("x = {}, y = {}".format(x,y)) name = input("Enter a name: ") print (name) x = int(input("What is x? : ")) print (x) y = float(input("Write a number : ")) print (y) a = 0 if a : print ("a's value") els...
0669fa9486066c0a53b54f782a5f9d4d0e816264
shashaank-shankar/OFS-Intern-2019
/Python Exercises/Condition Statements and Loops/Exercise 1.py
341
4.25
4
# Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between 1500 and 2700 (both included). input = int(input("Enter a number: ")) if input >= 1500 and input <= 2700: if input%7 == 0: if input%5 == 0: print(input + " is between 1500 and 2700. It is also div...
11f50308cb6450ee304af690d61f072c70924277
shashaank-shankar/OFS-Intern-2019
/Python Exercises/Condition Statements and Loops/Exercise 2.py
1,088
4.5
4
# Write a Python program to convert temperatures to and from celsius, fahrenheit. print("\nThis program converts Celsius and Farenheit temperatures.") def tempConvert (type): if type == "C": # convert to C new_temp = (temp_input - 32) * (5/9) new_temp = round(new_temp, 2) print("\n"...
69134976d1fff3e833b1011fc0cfdb1b2fa23422
BigSamu-Coding-Dojo-Python-Assignments/Insertion_Sort
/Insertion_Sort.py
506
3.8125
4
import time a = [2,3,5,6,8,1,4,7] b = [6,3,7,4,8,2,5,1] c = [8,2,5,7,1,4,3,6] def insertion_sort(someList): start_time = time.time() for i in range(1,len(someList),1): j=i-1 temp = someList[i] while temp < someList[j] and j>=0: someList[j+1]= someList[j] j ...
4d1fcba366716ab07a7e4f39bb15516e7ef25115
Susama91/Project
/W3Source/List_1/list6_1.py
485
3.984375
4
# Python code to sort the lists using the second element of sublists # Inplace way to sort, use of third variable def Sort(x): l = len(x) for i in range(0, l): for j in range(0, l-i-1): if (x[j][1] > x[j + 1][1]): tempo = x[j] #print(x[j]) ...
b5ce07c0e0ef26bcc3540aaafad2c0f07112f3b0
Susama91/Project
/Programs/Multithreading/thread.py
251
3.578125
4
import threading class x(threading.Thread): def run(self): for p in range(1,101): print(p) class y(threading.Thread): def run(self): for q in range(101,201): print(q) x1=x() x1.start() y1=y() y1.start()
a641608adf9d9bfb6eb5986e544874097f2584fd
Susama91/Project
/Programs/Oops/poly8.py
778
3.546875
4
class cust: """cust app""" cbname="sbi" def __init__(self,cname,cadd,cacno,cbal): self.cname=cname self.cadd=cadd self.cacno=cacno self.cbal=cbal def __str__(self): return self.cname+" "+self.cadd+" "+str(self.cacno)+" "+str(self.cbal)+" "+cust.cbname def deposit(self,damt): self.cbal...
1e5272ba8c6f60089eb41eb6b8070d69f6e499b3
Susama91/Project
/Programs/Interview/13.py
172
4.15625
4
x = True y = False z = False if not x or y: print (1) elif not x or not y and z: print (2) elif not x or y or not x and y: print (3) else: print (4)
af26e58cc7c38c8c80bc5223c3086d2e81d0853c
Susama91/Project
/W3Source/String/string1.py
100
3.71875
4
def length(n): count=0 for chr in n: count+=1 print(count) length('susmaa')
7ef82dc91ee930f513dea127a2d43f2fc8a2671d
Susama91/Project
/W3Source/String/string9.py
175
3.640625
4
def m1(str1,n): first=str1[:n] #print(first) last=str1[n+1:] #print(last) p=first+last print(p) m1('susama',2) m1('susama',0) m1('susama',5)
ddfad58b83454cf4ef3af2b374823f02183a31c9
Susama91/Project
/Programs/Interview/15.py
116
3.875
4
list=[1,5,10,15,20,25,30,35] for i in range(1,8): list[i-1]=list[i] for i in range(0,8): print(list[i], end=" ")
014a91fe3ae04dcc128333ef67d8ac9f34a381ea
Susama91/Project
/Programs/Function/factorial.py
191
4.125
4
def fact(x): if x==1: return 1 else: return(x*fact(x-1)) num=int(input("enter a positive no")) if num>=1: res=fact(num) print("factorial of a number is:",res)
0396703e40eaf2dc58cb4716e22c4d4a3facd698
Susama91/Project
/Programs/Sanfoundry/String/3.py
73
3.640625
4
i = 1 while True: if i%2 == 0: break print(i) i += 2
54518c4f1dcd313da6458e664f7f8c1fa2b95b5c
Susama91/Project
/W3Source/List/list10.py
273
4.21875
4
#Write a Python program to find the list of words that are longer than n #from a given list of words. def lword(str1,n): x=[] txt=str1.split() for i in txt: if len(i)>n: x.append(i) print(x) lword('python is a open',2)
cb9c543a61a385922fd0f9aeb2a8bb8919ecb61d
weejiaquan/cosc499-demo
/wordSort.py
105
3.5
4
#Word sort example def wordSort(param): word = param result = str(sorted(word)) return result
40f3264541bd19a6b68fc97e6f3de5c8d50691e5
HouzhiLi/ETL_study
/Python_Note/Pytion_笔记/three.py
4,327
4.4375
4
""" python中的自定义函数 语法 def 函数名(参数[:类型],参数,...): 函数体内容 [return 返回值] 函数可以有返回值,也可以没有返回值,有返回值时,在调用时,也可以不使用返回值 函数的调用: 函数名(参数,...); """ #定义一个简单的函数 def fn1(): print("Hello Python!") #调用函数 #fn1() #写一个函数计算一个数的阶乘 def fn2(n): res=1 for i in range(1,n+1): res=res*i # res*=i return r...
d1573d6ad748eaceb5747f80a42477914ece741b
ItsPepperpot/dice-simulator
/main.py
644
4.1875
4
# Dice rolling simulator. # Made by Oliver Bevan in July 2019. import random def roll_die(number_of_sides): return random.randint(1, number_of_sides) print("Welcome! How many dice would you like to roll?") number_of_dice = int(input()) # TODO: Add type checking. print("Okay, and how many sides would you like t...
c43483ea1d54c20c511d7ad5b1fa33acf4599a4d
enjoqy/PythonProjects
/PythonProjects/test/test01.py
397
3.625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # class A(): def __init__(self): if __name__ == '__main__': print('入口') self.b('1111') def a(self, ip): print(ip) def b(self, ip): self.a(ip) a = A() # class A(): # i = '123' # # def __init__(self): # ...
7e3539244fafcfe0eecb9b2b41a8e6038c36ab62
enjoqy/PythonProjects
/PythonProjects/crawl_work/thread_crawl_work06_51jop_ui_sub/test02.py
728
3.671875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- aa = '012345' print(aa[0:4]) print(aa[2:]) str1 = '1,2,3' arr = str1.split(',') print(arr) # str1 = ''.join(arr).find('2') # print(str1) # # degree_tmp = ['初中及以下', '高中', '中技', '中专', '大专', '本科', '硕士', '博士'] # str2 = ''.join(degree_tmp).find('中专') # print(str2 >= 0) aa ...
83352af1de7b8a457e2b2d5af14413cd80f8f016
dabini/lecture
/알고리즘강의/Linked List.py
2,868
4.0625
4
# class Node: # def __init__(self, d=0, n=None): # self.data = d # self.next = n # # class LinkedList: # def __init__(self): # self.head = None # self.size = 0 # self.tail = None # # # lst = LinkedList() # # def printList(lst): # if lst.head is None: # return ...
23638f6888929d89b118c66e872f5db8bded5645
dabini/lecture
/알고리즘강의/02_17_stack2.py
5,500
3.609375
4
# #연습문제 1 # # cal_num = input() # res = [] # stack = [] # # isp = [0] * 300 # isp[ord("(")] = 0 # isp[ord("*")] = 2 # isp[ord("/")] = 2 # isp[ord("+")] = 1 # isp[ord("-")] = 1 # # icp = [0] * 300 # icp[ord("(")] = 3 # icp[ord("*")] = 2 # icp[ord("/")] = 2 # icp[ord("+")] = 1 # icp[ord("-")] = 1 # # # for k in cal_num: ...
467538a70fe51346156c94ad7a5c157cb7b9efe3
dabini/lecture
/알고리즘강의/Quick_Sort.py
1,228
3.53125
4
def quick_sort(arr, left, right): #왼쪽 시작점과, 오른쪽 끝지점 #pivot 위치 결정(피봇을 기준으로 큰값은 오른쪽, 작은 값은 왼쪽으로 구분) #왼쪽 부분집합 정렬 #오른쪽 부분집합 정렬 if left < right: #피봇 구하기 pivot = hoare_partition(arr, left, right) #왼쪽부분집합 정렬 실행 quick_sort(arr, left, pivot-1) #오른쪽 부분집합 정렬 실행 quick...
68a6ef795ec7cf94211c453feaf1b1adfc6d2190
Evglit/python-project-lvl1
/brain_games/games/progression.py
820
3.796875
4
"""Arithmetic progression for brain-progression.""" from random import randint GAME_RULE = 'What number is missing in the progression?' def get_game_data(): """Returns an arithmetic progression and the missing number.""" random_number = randint(0, 100) difference_progression = randint(1, 10) size_p...