blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f4befdfd16d850beca3bcc8d6c70f65b9c8ade27
ask4physics/python-ICDL
/Sample Test/workfiles/If_Statement.py
280
4.1875
4
# Insert code below which uses an 'If...Else' statement to check if a students grade is # greater than or equal to 75, or less than 75 myGrade = int(input("Please enter your grade:")) print("This is a passing grade") print("Sorry, this is not a passing grade")
cdd878ca1efaf7cc84a96027b329bfde1f0413c6
gordonmannen/The-Tech-Academy-Course-Work
/Python/Tkinter GUI Development Tutorial - Py3.5.1/Chap5WidgetDialogs.py
713
3.5625
4
from tkinter import messagebox messagebox.showinfo(title = "A Friendly Message", message = 'Hello, Tkinter!') print(messagebox.askyesno(title = 'Hungry?', message = 'Do you want SPAM?')) # Messagebox Types: Informational # showinfo(), showwarning(), showerror() # Messagebox Types: Questions # askyesno(), askokcance...
1c612bb382d650d9929b218c15051f52d295e350
vidyasagarr7/DataStructures-Algos
/GeeksForGeeks/Arrays/TripletSum.py
1,241
4.28125
4
""" Find a triplet that sum to a given value Given an array and a value, find if there is a triplet in array whose sum is equal to the given value. If there is such a triplet present in array, then print the triplet and return true. Else return false. For example, if the given array is {12, 3, 4, 1, 6, 9} and given s...
f98ad8ade9b7402a08826d1390a7fcab521f96ec
Gruffalo123/Codewars
/6kyu/Who likes it/Who likes it.py
562
3.921875
4
def likes(names): string = " likes this" mul_str = " like this" if len(names) == 0: return 'no one'+string elif len(names) == 1: return names[0] + string elif len(names) == 2: return names[0] + ' and ' + names[1] + mul_str elif len(names) == 3: return ', '.join(na...
0dcc92a11819e0935cb071970485449e0cb30776
goog/Algorithms
/sort/qsort.py
656
3.796875
4
#!/usr/bin/python def partition(a,low,high): ## set the pivot p = a[low] while(low < high): while(low < high and a[high] >= p): high-=1 a[low] = a[high] while(low < high and a[low] <= p): low+=1 a[high] = a[low] high-=1 a[low] = p ## set...
d711617354a394af5d290a96786d8cd7b6b1978a
masonmei/studing-python
/com/igitras/algorithm/libs.py
1,142
3.828125
4
# coding=utf-8 __author__ = 'mason' from random import Random # 交换数组中的两个元素 def swap_element(elements_list, from_index, to_index): length = len(elements_list) if length < from_index or length < to_index: raise Exception("invalid swap element index.") tmp = elements_list[from_index] elements_l...
e9242cc241145ff63021af30bc941337c282e19e
akgnitd/programs
/python/string_replace.py
237
4.09375
4
def str_replace(string,old_sub_string,new_sub_string): print "New String: ",string.replace(old_sub_string,new_sub_string) str_replace(raw_input('Enter String: '),raw_input('Substring to be replaced: '),raw_input('New Substring: '))
ba2ec3f8cf2d960d6139b62618deffcfc8a52ee8
online-ml/river
/river/stream/iter_csv.py
6,583
3.53125
4
from __future__ import annotations import csv import datetime as dt import random from .. import base from . import utils __all__ = ["iter_csv"] class DictReader(csv.DictReader): """Overlay on top of `csv.DictReader` which allows sampling.""" def __init__(self, fraction, rng, *args, **kwargs): sup...
a513d51c972812976809c75ed5ed5641ce9d28c7
bendudson/pybout
/pybout/fieldexpr.py
3,620
3.640625
4
""" Define the base class which represents values and expressions FieldExpr Base class - Field Field3D object, calculated in C++ code - KnownScalar Scalar value (int/float) known at compile time makeField(value) :: value -> FieldExpr A function to turn a value into a FieldExpr "...
f94bf5a4e3d715810d1e9ad404ef1ca7f659a6e7
OndrejPech/blackjack
/BJ.py
16,417
3.8125
4
import random import time def print_ver(card): return str(card[0])+card[1] def print_res(res): if res == 'l': print('You lost.') elif res == 't': print('It is a tie.') elif res == 'w': print('You won.') elif res == 'bj': print('You won 3 to 2.') elif res == 'ins...
4c612a5aed4879d01b41839b9d2ede8960cf2deb
AriyanBinLayek/Python-Programs-1
/Algorithms/Sorting Algorithms/insertion_sort.py
345
3.921875
4
#Python program for implementing insertion sort def insertion_sort(a): for i in range(1,len(a)): j = i-1; key = a[i]; print(j); while a[j] > key and j >= 0: a[j + 1] = a[j] a[j] = key; j = j - 1; print(alist); alist = [14, 11, 13, 5, 6...
e7bff0a421ab8c6e48366add759bf99e8f2bfce3
lixit/python
/5structuredTypesMutabilityAndHigherOrderFunctions/list.py
291
3.609375
4
# singleton lists are written without that comma before the closing bracket. L = ['I did it all', 4, 'love'] M = [] for i in range(len(L)): print(L[i]) print(type(M)) # square brackets are used for literals of type list, indexing into lists, and slicing lists print([1,2,3,4][1:3][1])
e93e6dfdfd10bb338f41e2b2cd9ffcb95f8aa49d
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_118/2863.py
677
3.53125
4
from math import sqrt import string, sys input_file = open('C-small-attempt1.in') output_file = open('output.txt','r+') def is_square_palindome(x): y = sqrt(x) if y%1==0: yrev = str(int(y)) else: yrev = str(y) if x<10: return y%1==0 else: xrev = str(int(x...
ee42a9baba70c625e9cfd1b5acbcc137b032aa4d
thomasid/PythonTraining
/Data_Labeling.py
637
3.71875
4
import numpy as np from sklearn import preprocessing input_labels = ['red','black','red','green','black','yellow','white'] # creating label encoder encoder = preprocessing.LabelEncoder() encoder.fit(input_labels) print(list(encoder.classes_)) # encoding set of labels - no text in preprocessed data test_la...
0cd624aeb8d5ae75b5bec182befabeddf24f7a78
LeeSuBin-khu/DataStructure
/20210915/UnsortedType.py
2,236
3.65625
4
from enum import Enum MAX_ITEMS = 100 class Compare(Enum): LESS = 0 GREATER = 1 EQUAL = 2 class ItemType: """ Item Type """ def __init__(self, val): self.value = val def compared_to(self, otherItem): if self.value < otherItem.value: return Compare.LESS el...
107afc9b242b1d7264d7683c0776aab8d5f1797e
ro6ley/MyPy
/challenges/random/tower_of_hanoi.py
710
4.28125
4
def move_tower(height, original, final, intermediate): """ Tower of Hanoi algorithm: 1. Move tower of height-1 to intermediate using the final pole 2. Move remaining disc to final pole 3. Move tower of height-1 to final using the original pole """ # count = 1 if height >= 1: move_tow...
52f49b66ab6aafac94d89ce56d5b6e7a1138a695
micullen/learn
/PythonCourse/ListsRangesTuples/IteratorsRanges.py
1,674
4.03125
4
string = "1234567890" #for char in string: # print(char) # my_iterator = iter(string) # print(my_iterator) # print(next(my_iterator)) # print(next(my_iterator)) # print(next(my_iterator)) # print(next(my_iterator)) # print(next(my_iterator)) # print(next(my_iterator)) # print(next(my_iterator)) # print(next(my_iter...
ba2e03c34c031565ea5522432b37cf91baa46fbf
aigooitzj0e/DojoAssignments
/Python/Python OOP/hospital.py
1,308
3.625
4
import random class Patient(object): def __init__(self,unID,name, allergies): self.unID = unID self.name = name self.allergies = allergies self.bedNumber = 0 def display(self): print 'ID:',self.unID print 'Name:',self.name print 'Allergies:',self.allergies print 'Bed number:',self.bedNumber Joe = Pat...
8f9b20ea229a8a9aec741c013a0e661cd552a585
gideonseedboy/Python-Programming-with-Data-Science-and-AI
/Exercise folder/ex58.py
177
3.71875
4
user = input("Enter username: ") password = input("Enter password: ") if user=="giddy" and password=="2h2h2h": print("login successful") else: print("login failed")
96ad5f7360091c79642315a597a5e21b98c8eaff
usmanchaudhri/azeeri
/cache/doubly_linked_list.py
6,549
4.125
4
class Node: def __init__(self, data): self.item = data self.nextRef = None self.previousRef = None class DoublyLinkedList: def __init__(self): self.start_node = None def insert_in_empty_list(self, data): if self.start_node is None: new_node = Node(data)...
8dec0a8b3459782623d8dbbde0f09fa98aa1cc2a
lschr9610/rps
/Rock-Paper-Scissors.py
2,108
4.09375
4
def rpsgame(): """returns winner message based on choices""" run = True count = 0 while(run == True): var = "" choice1 = "" choice2 = "" choice1 = raw_input("Choose RPS: ") choice2 = raw_input("Choose RPS: ") if choice1 == choice2: var = "Tie!"...
3dec17a71ebfc3bf2b87bae8b261985fdb3fd297
QuinnStraubUAG/cspp10
/unit 5/mp_swap.py
304
3.703125
4
def swap(original, index1, index2): for x in range(len(original)): if original[x] == index1: original[x] = index2 elif original[x] == index2: original[x] = index1 original = [1,2,1,3,5,1,99,8008,99,720,1,0,99] swap(original,1,99) print (original)
a2bfb5e824c45c95a1ef66c48071d533982da3af
j2towers/exercism.io-python
/leap/leap.py
211
3.515625
4
def is_leap_year(inputyear): leaptrue = False if inputyear % 4 == 0 and inputyear % 100 != 0: leaptrue = True elif inputyear % 400 == 0: leaptrue = True return(leaptrue) pass
fa0f2298f2b0e6879ded945b99ce324290c45646
komotunde/DATA602
/Homework 6 (NumPy).py
3,685
4.34375
4
#------------------------------------------------------------------------------- # Name: IS 602 Homework 6 # Purpose: Sort and Search with NumPy # # Author: OluwakemiOmotunde # # Created: 05/02/2017 # Copyright: (c) OluwakemiOmotunde 2017 # Licence: <your licence> #----------------------------...
70f6a53ae532a9d3e14ca1093b005a99c5d5901b
RoksYz/GTx---CS1301xIV
/SongArtist.py
552
3.609375
4
class Artist: def __init__(self, name, label): self.name = name self.label = label class Song: def __init__(self, name, album, year, artist): self.name = name self.album = album self.year = year self.artist = artist taylor = Artist("Taylor Swift","Bi...
ff8149134ad10c7a2a63ae48347a2a29c426c220
lulumengyi/Algorithm-Studying-For-The-Interview
/week_1_array/02_Add_Two_Numbers.py
1,830
3.734375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: i = 0 num1 = 0 while l1 != None: num1 += l1.val * (1...
5931b4fd31717df77ae190c93f7a539789bae3fd
issashu/Code-Academy
/Python/20210505/Exercise4.py
619
4.28125
4
class Triangle: number_of_sides = 3 def __init__(self,angle1, angle2, angle3): self.angle1 = angle1 self.angle2 = angle2 self.angle3 = angle3 def check_angles(self): angle_sum = self.angle1+self.angle2+self.angle3 if angle_sum == 180: re...
44c722679986c910c0e0e80cdafc9153e47409a0
dtybnrj/myminipythonprojects
/spiral_traverse.py
962
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 14 12:15:31 2019 @author: adity """ def spiral(m,n,a): k=0 l=0 ''' where k is starting row index and l is starting colum index ''' while(k<m and l<n): #for +ce of colum index for i in range(l,n): ...
808e0639e1f7376fcb1b2409a9faf21714f7fecf
joonluvschipotle/baekjoon
/2446.py
132
3.765625
4
a = int(input()) for i in range(0,a): print(" "*i + "*"*((a-i)*2-1)) for i in range(1,a): print (" "*(a-i-1) + "*"*(i*2+1))
872dba08d1d16cc3bab712ef515eb41f3ca013a3
kiwhy/pythonProject
/main.py
132
3.578125
4
print("문자열입력") first = input(str()) j = len(first) last = [] for i in range(1, j+1): last += first[j-i] print(last)
ba1b5719fb7c1065e2541e3d18d298bd8d479db7
lilimonroy/CrashCourseOnPython-Loops
/q4Loop.py
928
4.375
4
#5. Question 5 #The multiplication_table function prints the results of a number passed to it multiplied by 1 through 5. #An additional requirement is that the result is not to exceed 25, which is done with the break statement. #Fill in the blanks to complete the function to satisfy these conditions. def multiplica...
33e2dd900469d69863c5239da39f9bf57572a1bb
AKASHDKR170901/dbpython
/186note.py
680
3.5625
4
import cx_Oracle try: con=cx_Oracle.connect('scott/tiger@localhost') cursor=con.cursor() query="select * from employees" cursor.execute(query) n=int(input('Enter no. of required rows:')) data=cursor.fetchmany() f=open('dbresults.txt','w') f.write(str(data)) for row in data: ...
22537dd7b32390de1dfce2d41e9b6ebb136c2353
llanoxdewa/python
/python class dan instance variabel/main.py
795
3.75
4
class hero : # class variabel / static variabel jumlah = 0 def __init__(self, inama, idarah, iattack, imovement): # instance variabel self.name = inama self.health = idarah self.attack = iattack self.movement = imovement hero.jumlah += 1 print("me...
cf809f4ce885b57140397d5b0234eff99c70c41b
md-redwanul-haque/oop-in-python-
/class_obj_practice.py
350
3.6875
4
class triangle: def __init__(self,base,height): self.base=base self.height=height def calculation(self): area= 0.5 * self.base * self.height print("Area = ",area) first= triangle(10,20) first.calculation() second= triangl...
7ea8847cb2ab33cc7371ba961e626bc0b7e9eb22
05anushka/If-else
/leap yr.py
258
4
4
if year%4==0: print("leap year hai") if year%100==0: if year%400==0: print("leap year hai") else: print("leap year nhi hai") else: print("leap year nhi hai") else: print("leap year nhi hai")
7a56107416db361ef8abb2ed03f3e07a05c76d46
szsctt/AOC_2020
/D3/trees.py
707
3.6875
4
#!/usr/bin/env python3 import math def main(): grid = [] height = 0 with open("input", 'r') as handle: for line in handle: grid.append(line.strip()) height += 1 trees = [] trees.append(count_trees(grid, 1, 1)) trees.append(count_trees(grid, 3, 1)) trees.append(count_trees(grid, 5, 1)) trees.append(...
912e363fb3de4e48726c7d7c28be17b8ba0fc751
realpython/materials
/python-311/kalkulator.py
729
3.5625
4
import operator import parse OPERATIONS = { "pluss": operator.add, # Addition "minus": operator.sub, # Subtraction "ganger": operator.mul, # Multiplication "delt på": operator.truediv, # Division } EXPRESSION = parse.compile("{operand1:g} {operation} {operand2:g}") def calculate(text): if (o...
955957ff1961b46925b667cb1e7273042bcc6bcb
jpalaskas/Distributed-Systems-Assignments
/Part 1 - Bank Database Implementation/db1.py
9,618
4.09375
4
import sqlite3 import datetime ''' Users Table consists of the following(as show in the query in the main): id, name, entry_date, balance, withdrawal_limit (per day), last_withdraw_date ---------------------------------------------------------------------- The user can choose between Deposition, Withdrawal and ch...
bed31670ef863639fe00d25839fc98d6921d6578
miro-lp/SoftUni
/Fundamentals/FundamentalExercises/SchoolLibrary.py
818
3.75
4
books = input().split("&") line = input() while line != "Done": command = line.split(" | ")[0] book = line.split(" | ")[1] if command == "Add Book": if book not in books: books.insert(0, book) elif command == "Take Book": if book in books: books.remove(book) ...
9499341d04a78464495bf09241d6d3bdd1768375
purive/Final-Project-2048
/Final_Project_2048.pyde
10,435
3.65625
4
#This is the code for the final project: Game 2048 # For the final project, I developed the code for the game 2048. #The code used processing program and no other external files or programs were used to create the code. #Therefore, there is no need to download anything but just run the code on processing. import ...
fe0a98e6fed530bf5297ebf6c12c7f06679cf0f0
surajsvcs1231/SurajProject
/python_overloading.py
623
3.890625
4
class student: def __init__(self,m1,m2): self.m1=m1 self.m2=m2 def __add__(self, other): f1=self.m1+other.m1 f2=self.m2+other.m2 return f1+f2 def __gt__(self, other): m1=self.m1+self.m2 m2=other.m1+other.m2 if m1>m2: return True ...
22b51b10ad22c62d4e42e6097dc0d1146b6df9ce
XinheLIU/Coding-Interview
/Python/Data Structure/Linear List/Array/K Sum/3Sum(with target).py
1,143
3.9375
4
""" Determine if there exists three elements in a given array that sum to the given target number. Return all the triple of values that sums to target. Assumptions The given array is not null and has length of at least 3 No duplicate triples should be returned, order of the values in the tuple does not matter Example...
e72a2778a489c124ea94f75a3c49cd79e5a23017
matn7/data-structures-algorithms-python
/section5/bisection_recur.py
584
3.59375
4
def bisection_recur(n, arr, start, stop): if start > stop: return f"{n} not found" else: mid = (start + stop) // 2 if n == arr[mid]: return f"{n} found at index: {mid}" elif n > arr[mid]: return bisection_recur(n, arr, mid + 1, stop) else: ...
1a79e46e1db12456e58351cebd02621e6ba7b322
plegrone/Exercise-9.2
/Exercise 9.2.py
441
3.59375
4
fin = open('words.txt') count_no_e = 0 count = 0 forbidden = 'e' for line in fin: word = line.strip() count = count + 1 if forbidden not in word: print(word) count_no_e = count_no_e + 1 print('Of the ', count, ' words evaluated') print('I found ', count_no_e, ' words with no e...
0a9afc6f0464cad6883c11630cb221d3e9adcb6c
ckd1618/Algorithms
/algtest.py
242
3.515625
4
class myclass: def __init__(self, var1): self.var1 = var1 def fun1(self): a = self.var1 def innerFun1(var): return var return innerFun1(a) myclass1 = myclass(5) print(myclass1.fun1())
b423205da0a7263df3c26c7308e781f2eb68b360
mishazakharov/DL-library
/DL/optimizer.py
918
3.65625
4
import numpy as np class SGD(object): """ This class realizes stochastic gradient descent The only difference between a simple gradient descent is that this one uses only one sample for each iteration Args: layer(object): this objects stands for a layer we optimizing learning_rate(fl...
85bf115f87e5891518e33da5e6e9c5e6999332a0
lkeude96/OSSU
/Introduction to Computer Science/(MIT6.00.1x) Introduction to Computer Science and Programming Using Python/Week 2/pset1/pset1_counting_bobs.py
554
4.125
4
# Anything below here are for testing purpose only s = 'azcbobobegghakl' # End of testing stuff def countbobs(given_str): """ Counts the number of times 'bob' occurs in a given string :param given_str: string to count 'bob' from :return: number of times 'bob' occurs in given_str """ number_o...
e393b7c41ac1147be6f59c0ef48f517a8c8cbfa3
chris-peng-1244/python-quiz
/two_sum.py
947
3.65625
4
class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def two_sum(root, K): seen = {} for node in iter_tree(root): if K - node.val in seen: return (node, seen[K - node.val]) seen[node.val]...
4ea974471b533f8c6e2b62cb39d537c2a8fe439e
P4B5/Microbit
/crono2.py
2,675
3.609375
4
from microbit import* zero = "99999:99999" one = "00000:99999" two = "90999:99909" three = "90909:99999" four = "99900:09999" five = "99909:90999" six = "99999:90999" seven = "90900:99999" eight = "99099:99099" nine = "99900:99999" fonts = (zero, one, two, three, four, five, six, seven, eight, nine) minutes = 59 ...
082eaae567a0715bfd6a071029849fe9ea48267b
Danilo-Xaxa/python_curso_em_video
/Testes com dicionários.py
648
3.90625
4
dados = {'nome': 'Danilo', 'idade': '17'} print(dados['nome']) print('') SW = {'título': 'Star Wars', 'ano': '1977', 'diretor': 'George Lucas'} for key, value in SW.items(): print(f'O {key} é {value}') print('') muse = {'guitarrista': 'Matt', 'baixista': 'Chris', 'bateirista': 'Dom'} print(muse.items()) print(m...
6119bdc6b2f56e22805112f2b1c707fc291a764f
joseph-mutu/Codes-of-Algorithms-and-Data-Structure
/Leetcode/[面试题 08.07]. 无重复字符串的排列组合.py
675
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2020-03-26 06:47:35 # @Author : mutudeh (josephmathone@gmail.com) # @Link : ${link} # @Version : $Id$ import os class Solution(object): def __init__(self): self.results = [] def permutation(self, S): S = list(S) self.search...
978db8526b21b8787be065e76f8de322739deb06
priyakrisv/priyakv
/set49.py
166
4.25
4
m=[] p=int(input("Enter number of elements:")) for i in range(1,p+1): l=int(input("Enter element:")) m.append(l) m.sort() print("Largest element is:",m[p-1])
02bf5644592d78faa972a470909ab7459e93bdb5
kongziqing/Python-2lever
/基础篇/第9章继承与多态/9.2多态/对象多态性.py
1,446
3.625
4
""" 在继承结构中,子类可以根据需要来选择是否要覆写父类中的指定方法,而方法覆写的主要目的在于可以让子类和父类中的方法名称统一, 这样在进行传递时不管子类实例还是父类实例,就都可以使用相同的方法名称进行操作,例如:现在有一个消息发送通道Channel类, 在此类中需要进行消息的发送,而现在的消息分为普通消息,数据库消息,网络消息 """ # coding : utf-8 class Message: # 定义Message父类 def get_info(self): # 定义方法 return "【Message】www.yootk.com" # 返回信息 class DatabaseM...
46f6d8b17a83a6c22271cd79c55ef999da072b61
jinglv/python-example
/sort-example/BubbleSort.py
295
4.03125
4
def bubble_sort(arr): # 获取数组的长度 l = len(arr) for i in range(l): for j in range(l - i - 1): if (j + 1) > j: arr[j + 1], arr[j] = arr[j], arr[j + 1] return arr arr = [2, 1, 7, 9, 5, 8] sort_arr = bubble_sort(arr) print(sort_arr)
6bd57127b50a5a221573c2c27b03c3303b42c4ce
gsg62/Basic-Python-Programs
/gameShow.py
5,185
3.625
4
# Greg Geary # User can play a sports themed game show from random import shuffle scores = {} questions = [{"question": "What color jersey is worn by the winners of each " # entering questions into a list of dictionaries "stage of the Tour De France?", ...
5c0a68f2f5ffd6b73390156cc1f51d0084778fbd
suryandpl/UberPreparationPrograms
/alok-tripathi-workplace/set3/p6.py
446
3.90625
4
''' # First Non Repeating char # Storing value and order of the char ''' def firstNonRepeatingChar(str1): char_order = [] counts = {} for c in str1: if c in counts: counts[c] += 1 print(counts) else: counts[c] = 1 char_order.append(c) for...
8cec4330bc7fec746082b7f4f5644e545e85d17e
AleByron/AleByron-The-Python-Workbook-second-edition
/Chap-2/ex55.py
335
4.03125
4
w = float(input('Insert a wavelength:')) if 380 <= w <=450: c = 'violet' elif 450 <= w <=495: c = 'blue' elif 495 <= w <=570: c = 'green' elif 570 <= w <= 590: c = 'yellow' elif 590 <= w <= 620: c = 'orange' elif 620 <= w <= 750: c = 'red' else: c='This wavelength is not visibl...
d1e029934fa0bbb24c78cd341294e149b3c721fa
wyj19940/Pygame_00
/main.py
1,263
3.546875
4
import pygame import sys from pygame.locals import * pygame.init() size = width, height = 1000, 665 speed = [-15, 10] screen = pygame.display.set_mode(size) pygame.display.set_caption("游戏设计") turtle = pygame.image.load("snake.png") background = pygame.image.load("background.jpg") position = turtle.get_rect() l_...
8637b463d1c7c94da465c54543e6245176987469
sunrisejade/DataCamp
/Manipulating DataFrames with pandas/2.Advanced indexing.py
1,439
4.75
5
---Changing index of a DataFrame # Create the list of new indexes: new_idx new_idx = [i.upper() for i in sales.index] # Assign new_idx to sales.index sales.index = new_idx # Print the sales DataFrame print(sales) ----Building an index, then a DataFrame # Generate the list of months: months months = ['J...
e23a61dc3fbd65ab864d781ae45ddd923f3c0284
CosmicCosmos/SPOJ-1
/LENGFACT/LENGFACT.py
199
3.515625
4
from math import floor, log, pi, e t = int(raw_input()) while t: t-=1 n = int(raw_input()) if n == 0 or n == 1:print "1" else:print int(floor((log(2*pi*n, e)/2 + n*(log(n, e)-1))/log(10, e))+1)
8672612ccb14159ec362d409ebb4879570e696cd
lucmichea/leetcode
/Challenge_May_30_days_leetcoding_challenge/day05.py
426
3.765625
4
""" First Unique Character in a String Problem: Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contain ...
b3c488dd2056fa86b6e37557d400a42f7de892af
RezoApio/WDUTechies
/python/longrepeat.py
630
3.6875
4
def long_repeat(line): """ length the longest substring that consists of the same char """ import re # your code here sol = 0 for i in range(len(line)): sol=max(sol,len(max(re.findall(line[i]+"+",line),key=len))) return sol if __name__ == '__main__': #These "as...
e28f277daa8001a1230b75fa368a24832640e10e
William-Zhan-bot/2021_Python_Class
/6.17練習題 參考解答/費波納西數列.py
387
3.734375
4
# 費波納西數列 # 建立一個可計算數列值的程式 # 輸入為一字串 # 輸出為一整數 fib = [0,1] num = int(input())-1 if num == 1: print(fib[0]) elif num == 2: print(fib[1]) else: init = 0 answer = 0 for k in range(num): answer = fib[init] + fib[init+1] fib.append(answer) init += 1 print(fib[...
06eaa09f2153cc4789b4376305daf80f84498321
karenddi/Python-CODE-ME
/04/homework4/zad6_dictionary.py
328
3.515625
4
#Utwórz listę zawierającą wartości poniższego słownika, bez duplikatów. days = {'Jan': 31, 'Feb': 28, 'Mar': 31, 'Apr': 30, 'May': 31, 'Jun': 30, 'Jul': 31, 'Aug': 31, 'Sept': 30} days_keys_s = (set(days.keys())) days_values_s =(set(days.values())) daysfinal = list(days_keys_s) + list(days_values_s) print(daysfinal)
8835b31a6cdaf33a6d98f079946a46fae4b0aea7
npoet/336-Data-Essays
/essay1/336_data_essay1.py
5,783
3.53125
4
# 336_data_essay1.py # analysis of GDP per Capita, Electricity use per Capita, and Democratic Level for # all nations (data permitting). Most recent aggregate data from 2014. # Data Sources: # - GDP per Capita: World Bank Economic Indicators API (2014 Nominal GDP per cap. in USD) # - Electricity use per...
09619f28f1b18127cf2dcfed97eb871beb984ffd
takuzuka/UnitedConspects
/onemoreclient.py
1,042
3.640625
4
#!/usr/bin/env python3 # client.py import socket # create a socket object s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # get local machine name # local host IP '127.0.0.1' ##host = socket.gethostname() host = "127.0.0.1" # Define the port on which you want to connect port = 9999 # c...
8c0bb6b04790da0b0302ae43a48e4af396db3735
Anzanrai/AlgorithmicToolbox
/week5_solution/edit_distance.py
905
3.6875
4
# Uses python3 def edit_distance(s, t): #write your code here distance_mat = [[0]*(len(t)+1) for i in range(len(s)+1)] for i in range(1, len(s)+1): distance_mat[i][0] = i for j in range(1, len(t)+1): distance_mat[0][j] = j for i in range(1, len(s)+1): for j in range(1, l...
3651713792c92aea35a301bfc8841fb2a4c02d07
aliensmart/week2_day3
/Intro_Tests/app/animal.py
1,272
4.21875
4
#!/usr/bin/env python3 #Create a Class Animal class Animal: #instance attribute: # species = None # name def __init__(self, name): self.name = name self.species = None def make_noise(self): print() # animal = Animal("Test") # animal.name == "Test" class Tiger(A...
5ba2707a777c557236f73bb966e5d04895386e28
njuywy/CMS_for_SE_b
/dao.py
2,861
3.5
4
""" An operator for operate database """ import sqlite3 class DaoBase(): """docstring for DaoBase""" def __init__(self, arg): super(DaoBase, self).__init__() self.db_name = arg self.conn = sqlite3.connect(self.db_name) # self.conn.row_factory = sqlite3.Row self.cur = s...
d5d4e78e312b76aa8c0c20421826c75407d4e6fd
Vitality999/HSE_1
/Task_3.py
1,115
4.0625
4
# 3. (2 балла) # Электронные часы показывают время в формате hh:mm:ss, то есть сначала записывается обязательно двузначное количество часов, # потом обязательно двузначное количество минут, затем обязательно двузначное количество секунд. # # С начала суток прошло N секунд. Выведите, что покажут часы. В N точно меньше 2...
9546dfcf114445a4ebd42cc344a64fb8f8a205dc
LinhTangTD/Cracking-The-Coding-Interview
/Chap1-Arrays-and-Strings/02_checkPermutation.py
1,321
4.40625
4
def checkPermutation(str1, str2): """ Checks if str1 is a permutation of str2 and vice versa. Args: str1: String str2: String Returns: boolean: True or False Assumption: Empty strings are permutations of each other. Complexity Analysis: Time Complexity: O(N) Space Complexity: O(N) """ sig1 = ge...
8ef38ddd3b149126219bf068b30ba5eb799fa9b2
AiratValiullin/alg_les3
/les3-3.py
504
4.03125
4
# 3. В массиве случайных целых чисел поменять местами минимальный и максимальный элементы. import random min_ = 100 max_ = 0 list1 = [random.randint(0, 10) for i in range(5)] print(list1) for j in list1: if j > max_: max_ = j elif j < min_: min_ = int(j) min_index = list1.index(min_) max_ind...
d373d3ecec4b57423e8b8c2e0310da54a309c229
alby-beep/Date-program
/answer_1.py
1,119
3.78125
4
def server_cost(d1, m1, y1, d2, m2, y2): int cost #condition for checking the server is deleted on the same day it is created if d1==d2 & m1==m2 & y1==y2: cost=20 #conditions for checking the server is deleted after a day but still within a month elif d1==d2-1 & m1==m2 & y1==y2: c...
77e881da8bbada6a290feff78a2921dcecf1dee8
u101022119/NTHU10220PHYS290000
/student/101022216/h4/MYTIME
1,155
4
4
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> class Time(object): def __cmp__(self,other): if self.hour > other.hour: print 'Time1 is ahead Time2' return 1 elif self.hou...
eca9a512c96d18d74a424de13d6025d0ff6a1a41
YanZhu1105/LeetCode-Algorithm-Practice
/Week_02/[239]Sliding Window Maximum.py
1,533
3.625
4
# Given an array nums, there is a sliding window of size k which is moving from # the very left of the array to the very right. You can only see the k numbers in # the window. Each time the sliding window moves right by one position. Return the # max sliding window. # # Follow up: # Could you solve it in linear ...
2348ec0789b7fde1f4aab966ac12e2d5ed0ad7f0
makubex01/python_lesson
/ch3/while-inch_to_cm-break.py
188
3.796875
4
while True: print(" --- ") s = input("インチは?") if s == "":break #空行なら脱出 inch = float(s) cm = inch * 2.54 print(str(cm) + "センチです")
898a3b52db9441204bba93588d90d1d3ade92a53
shanester85/Murach-Python-Programming
/ch03/test_scores.py
2,288
4.46875
4
#!/usr/bin/env python3 # display a welcome message print("The Test Scores program") print() another_tests = "y" #initialize variable outside of outer while loop for the loop to work while another_tests.lower() == "y": #Beginning of outer while loop that continues on as long as the user enters 'y' or 'Y'. ...
24d4b8699e7bcc1208e026e406397dd708add70e
achoudh5/PythonBasics
/Q9.py
766
3.84375
4
#Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized. #Q: first method problem !! Class A class A: def q9(self,a): b="" g=a.split() for i in g: print i if ord(i) not in range(65,91): ...
7c14f0d644d9690db66b16dc5c20356bbfda2e2a
maelys/banking
/db_manager.py
934
3.59375
4
#!/usr/bin/env python import sqlite3 class DatabaseManager: CREATE_TABLE = "CREATE TABLE IF NOT EXISTS boi (id integer PRIMARY KEY AUTOINCREMENT, amount float, time_stamp text);" INSERT_QUERY = "INSERT INTO boi (amount, time_stamp) VALUES (?, ?);" conn = '' c= '' def connect(self): ...
fb4ef6b4232dae58bb973f5dc54f881ed4e330d4
valeriacavalcanti/IP-2019.2
/Gabarito/Exercícios/Lista08/questao02.py
382
3.875
4
letra_minuscula = 0 letra_maiuscula = 0 numero = 0 especial = 0 frase = input() for letra in frase: if (letra >= 'a') and (letra <= 'z'): letra_minuscula += 1 elif (letra >= 'A') and (letra <= 'Z'): letra_maiuscula += 1 elif (letra >= '0') and (letra <= '9'): numero += 1 else: especial += 1 print(letra_m...
cf1133f29fb1db23a965dc80b7acacc5c983dd0b
Lahaduzzaman/CSE-402L
/thresholdfunction.py
517
3.53125
4
# import numpy library import numpy as np # define inputs x=np.array([0.2,0.4,0.7]) # weight values w=np.array([0.4,-0.1,0.6]) print("Inputs:") print(x) print("Weights:") print(w) # transpose the weight matrix w_t=np.transpose(w) print("Weight matrix transposed") print(w_t) # assigning bias b=-1.0 print("Bias:") prin...
f416b526690f672aca64556ca91a40fb06973272
halimeroglu/timer_tk
/timerTk.py
1,480
3.734375
4
import time from tkinter import * from tkinter import messagebox root = Tk() root.title('Timer') root.config(bg='#16a085') root.geometry('300x300') #crate the variables hour = StringVar() minute = StringVar() second = StringVar() #default values hour.set("00") minute.set("00") second.set("00") #define function def...
29b838c619289a23e873109cd58b1ecd18bfb063
Andchenn/python
/com/link.py
210
4.0625
4
# 创建一个链表 if __name__ == '__main__': par = [] for i in range(5): num = int(input('please input a number:\n')) par.append(num) print(par) par.reverse() print(par)
26fbb02c954a8d1b7b947502cf96effd57eb36b9
SinghChinmay/multiple-file-rename-python-script
/MultiRename.py
1,471
4.625
5
# Python3 Code to rename multiple files in a directory # Author: Studboo Senapi from Studboo.com import os import sys def main(): directory = input("Enter the destination folder location : ") directory = os.path.normpath(directory) + os.sep # Normalize path and add separator if not os.path.isdir(directo...
7906ee122f2b61e3fc9c6f1cc42be5e42ea33a0f
KremenenkoAlex/Python
/lesson3/exp2.py
497
4
4
name = str(input("Введите имя: ")) surename = str(input("Введите фамилию: ")) year_born = int(input("Введите год рождения: ")) town_born = str(input("Введите город рождения: ")) email = str(input("Введите email: ")) tel = int(input("Введите телефон: ")) def user (*arg): print("Данных о пользователе: {}, {}, {}, {}...
7467c7af2bbe884e33332a6c65debf86fbd890cc
Ben-Lapuhapo/ICS3U-Assignment-2-Python
/sphere_volume_calculator.py
407
4.6875
5
#!/usr/bin/env python3 # Created by: Ben Lapuhapo # Created on: September 18 2019 # This program calculates volume of a circumference. # from user input import math def main(): print("") radius = int(input("Enter the Circumference's Radius(mm): ")) # output volume = (4/3*math.pi*radius**3) pri...
be92d0bcb55eae5ca86eb86027e46d1d68fd1464
pjh9362/PyProject
/1102_02_listAndTuple.py
221
3.65625
4
a = [10, 20, 30] print(a.pop()) print(a) a = [10, 20, 30] print(a.pop(1)) print(a) a = [10, 20, 30] del a[1] print(a) a = [10, 20, 30] print(a.remove(20)) print(a) a = [10, 20, 30, 20] print(a.remove(20)) print(a)
e2c71f3a48d14e225e582f1b44ea4f968e1e6327
fllamasramon/python
/Practica 6/E5P6.py
569
4.25
4
"""Escribe un programa que te pida números cada vez más grandes y que se guarden en una lista. Para acabar de escribir los números, escribe un número que no sea mayor que el anterior. El programa termina escribiendo la lista de números:""" #Francisco Llamas lista=[] entrada=int(input("introduzca un numero")) entrada2=i...
bd76ab1462f6593279d2cd2343ca0a20347e2064
Skydler/blockpy
/src/instructor/instructor_iteration.py
5,001
3.75
4
from instructor import * def iteration_group(): list_initialization_misplaced() wrong_target_is_list() wrong_list_repeated_in_for() missing_iterator_initialization() list_not_initialized_on_run() wrong_iterator_not_list() missing_target_slot_empty() missing_for_slot_empty() wrong_tar...
6463fc2b67700b7fc68e0ed53539a8990c55542d
ocipap/algorithm
/baekjoon/10156.py
110
3.578125
4
a, num, money = map(int, input().split()) if a * num < money : print(0) else : print(a * num - money)
38cd11db6e0371857a6423b10d15231637b5b6cf
Firaasss/CS-1026
/LABS/lesson3/task3/task.py
327
4.15625
4
# Add statements to complete the program. from datetime import datetime hour = datetime.now().hour if hour < 12: timeOfDay = "morning" elif (hour > 12) and (hour < 18): timeOfDay = "afternoon" elif hour > 6: timeOfDay = "evening" # Place your code here print("Good {}, world".format(timeOf...
4b57e0aabbf6d7236a7299080e49e5cd351b67bf
sharnangat/MyLearnings
/BBA_IIISem/c5.py
522
3.859375
4
class A: number1=0 number2=0 def __init__(self,n1,n2): print("Constructor in Base class called") self.number1=n1 self.number2=n2 class B(A): number3=0 number4=0 def __init__(self,n3,n4): print("Constructor in Derived class called") self.number3=n3 ...
143b645041ee513d901804f1409cc65eed430e6f
shovan99/dietChartMaker
/helloWorld.py
1,314
3.609375
4
print("Press 1 for you , Press 2 for mom and Press 3 for dad") def getDate(): import datetime return datetime.datetime.now() try: firstInput=int(input()) if firstInput==1: print("Write here about your diat plans!!") f=open('you.txt','a') shovanInput=input() ...
d0fc503675b012eff93c0a17b683c026bae96d3a
bensonchi/CIS2348Sum2020
/zyLab10-11.py
1,295
4
4
# Name:Baichuan Chi # PSID:1938207 class FoodItem: # Define class to contain nutrition information about a food def __init__(self, name='None', fat=0.0, carbs=0.0, protein=0.0, serving=0.0): self.name = name self.fat = fat self.carbs = carbs self.protein = protein self.se...
1f6f5267ed83b1579cdebb5e8fc1f5b6e688b325
sawood14012/lab-progs
/quicksort.py
339
3.828125
4
import random def quicksort(x): if len(x)<2: return x else: pivot = x[0] less = [i for i in x[1:]if i <= pivot] greater = [i for i in x[1:]if i > pivot] return quicksort(less)+[pivot]+quicksort(greater) alist =[random.randint(0,100)for i in range(20)] print(alist) print...
4a39bd77119169f0e8a73033a1777a52a3047790
erjan/coding_exercises
/replace_non_coprime_numbers_in_array.py
1,882
4.15625
4
''' You are given an array of integers nums. Perform the following steps: Find any two adjacent numbers in nums that are non-coprime. If no such numbers are found, stop the process. Otherwise, delete the two numbers and replace them with their LCM (Least Common Multiple). Repeat this process as long as you keep findin...
bfe14fb59204a6fd93b6d2ab8afd0c7dbad1a845
sonht113/PythonExercise
/HoTrongSon_50150_chapter5/Chapter5/Exercise_page_158/Exercise_01_page_158.py
901
4.34375
4
""" Author: Ho Trong Son Date: 18/08/2021 Program: Exercise_01_page_158.py Problem: 1. Give three examples of real-world objects that behave like a dictionary. Solution: Result: Date: 2020-02-18 Close price: 200.0 Date: 2020-02-19 Close price: 201.0 Date:...
17aa6a103a759f1c7ee72b8ac3c5662b83056442
christine2623/Mao
/Data Manipulation With Pandas.py
5,312
4.25
4
# Import the Pandas library. import pandas # Read food_info.csv into a DataFrame object named food_info food_info = pandas.read_csv("food_info.csv") # Use the columns attribute followed by the tolist() method to return a list containing just the column names. cols = food_info.columns.tolist() print(cols) # Display the ...
48b56fb5f09b5f0cbcb0cb65660d7421c7edc8b2
mwbelyea/Dictionary
/ScrapeFlatbook.py
880
3.84375
4
# #taken from altitudelabs.com # #import libraries # import urllib2 # from bs4 import BeautifulSoup # #specify the url # quote_page = 'https://www.flatbook.co/' # #Then, make use of the Python urllib2 to get the HTML page of the url declared. # #query the website and return the html to the variable 'page' # page = u...
53ca95148003713bd459cacc91d18d3b586defb3
cladzperida/basic
/Pi_DigitCount_Visualizer.py
3,265
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 28 02:40:39 2021 @author: user """ # Pi Digit Counter (w/ visuals) import matplotlib.pyplot as plt import pandas as pd import time digit = ['0','1','2','3','4','5','6','7','8','9'] tot_count = 0 print("Welcome to Pi Digit Counter Visualizer!") time.sl...