blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fd15e697fed400830cfdea8d4673561f00d3e18a
Zahra404/data-analytics-and-exploration
/ebookstore.py
3,123
4.3125
4
import sqlite3 import sys # import system so you can exit program db = sqlite3.connect("ebookstore") cursor = db.cursor() try: cursor.execute('''CREATE TABLE IF NOT EXISTS books (ID INTEGER PRIMARY KEY, Title TEXT, Author TEXT, QTY INTEGER)''') db.commit() except table_already_exists: pass ...
6e1ee2f87c96efc9e76413c11d0ef44a4508e891
z1dzot/python_styding
/lesson_5.3.py
778
4.09375
4
# Создать текстовый файл (не программно), построчно записать фамилии сотрудников и величину их окладов. # Определить, кто из сотрудников имеет оклад менее 20 тыс., вывести фамилии этих сотрудников. # Выполнить подсчет средней величины дохода сотрудников. from statistics import mean salaries = [] with open("test_3.txt...
dbeb9dc27f0f506d5f3868517033af96f93e5d63
kristinpeterson/project-euler
/euler_012.py
1,082
3.84375
4
""" The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,...
1d1fd05cb5e500af7a1ecc7c35602e3cf3582f97
kristinpeterson/project-euler
/euler_004.py
805
4.03125
4
""" Largest Palindrome Product A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ import time start_time = time.time() #####################################...
f3c1c0f8ece3f860af7979dbd6107eed06b7e9b6
kuchunbk/PythonBasic
/9_date_time/Sample/date-time_ex44.py
661
4.09375
4
'''Question: Write a Python program to display a calendar for a locale. ''' # Python code: import calendar cal = calendar.LocaleTextCalendar(locale='en_AU.utf8') print(cal.prmonth(2025, 9)) '''Output sample: September 2025 Mo Tu We Th Fr Sa Su ...
fe2d67b789f9b68fb905c7239221c4fae5a95da8
kuchunbk/PythonBasic
/5_tuple/Sample/tuple_ex20.py
231
4.375
4
'''Question: Write a Python program to print a tuple with string formatting. ''' # Python code: t = (100, 200, 300) print('This is a tuple {0}'.format(t)) '''Output sample: This is a tuple (100, 200, 300) '''
351786c29a6f5baa28f5118503edd884aeaeb626
kuchunbk/PythonBasic
/2_String/Sample/string_ex49.py
489
4.0625
4
'''Question: Write a Python program to count and display the vowels of a given text. ''' # Python code: def vowel(text): vowels = "aeiuoAEIOU" print(len([letter for letter in text if letter in vowels])) print([letter for letter in text if letter in vowels]) vowel('w3resource'); '''Ou...
f76b1074a631f495a253196d6097887af0860a04
kuchunbk/PythonBasic
/3_list/Sample/list_ex29.py
477
4.125
4
'''Question: Write a Python program to get unique values from a list. ''' # Python code: my_list = [10, 20, 30, 40, 20, 50, 60, 40] print("Original List : ",my_list) my_set = set(my_list) my_new_list = list(my_set) print("List of unique numbers : ",my_new_list) '''Output sample: Original List ...
53de8834d7b8dc8c5b8ae062e3dea670b5539855
kuchunbk/PythonBasic
/2_String/string/02.py
296
3.875
4
def frequency_char(str1): dict = {} for char in str1: keys = dict.keys() if char in keys: dict[char] += 1 else: dict[char]= 1 return dict if __name__ == "__main__": str1 = input('xin moi nhap chuoi') print(frequency_char(str1))
ae0c2f7a87d3d57dabf6f63cdb3966523da8c2bd
kuchunbk/PythonBasic
/11_math/Sample/math_ex9.py
1,191
4.0625
4
'''Question: Write a Python program to calculate the discriminant value. Note: The discriminant is the name given to the expression that appears under the square root (radical) sign in the quadratic formula. ''' # Python code: def discriminant(): x_value = float(input('The x value: ')) y_value = ...
202656c6afa83f28abd30992a1c79bcfe11055be
kuchunbk/PythonBasic
/2_String/string/10.py
177
3.875
4
def add_char(str1,str2,n): return str1[:n] + str2 + str1[n+1:] if __name__ == "__main__": str1 = "tran van luan" str2 = "hai duong" n = 3 print(add_char(str1,str2,n))
ea76a46e413361617271524b4eb84484ecb306e4
kuchunbk/PythonBasic
/2_String/Sample/string_ex23.py
434
3.984375
4
'''Question: Write a Python program to remove a newline in Python. ''' # Python code: str1='Python Exercises\n' print(str1) print(str1.rstrip()) '''Output sample: Python Exercises ...
0057561f244338cdf9193ed245680213ba3939d9
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex139.py
280
3.640625
4
'''Question: Write a Python program to valid a IP address. ''' # Python code: import socket addr = '127.0.0.2561' try: socket.inet_aton(addr) print("Valid IP") except socket.error: print("Invalid IP") '''Output sample: Invalid IP '''
efc82b0fc75760478f02894aed2061de5906f645
kuchunbk/PythonBasic
/2_String/Sample/string_ex1.py
282
4.28125
4
'''Question: Write a Python program to calculate the length of a string. ''' # Python code: def string_length(str1): count = 0 for char in str1: count += 1 return count print(string_length('w3resource.com')) '''Output sample: 14 '''
da3454ebd5cf80bf2447e88f704c7addfd215a93
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex40.py
309
3.9375
4
'''Question: Write a Python program to compute the distance between the points (x1, y1) and (x2, y2). ''' # Python code: import math p1 = [4, 0] p2 = [6, 6] distance = math.sqrt( ((p1[0]-p2[0])**2)+((p1[1]-p2[1])**2) ) print(distance) '''Output sample: 6.324555320336759 '''
a6b489d8f2570a6c7e068f1f23ea85e52314037e
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex88.py
219
3.9375
4
'''Question: Given variables x=30 and y=20, write a Python program to print "30+20=50". ''' # Python code: x = 30 y = 20 print("\n%d+%d=%d" % (x, y, x+y)) print() '''Output sample: 30+20=50 '''
766a8caa3b0d15ba9fb327f3bf94d64a8b302171
kuchunbk/PythonBasic
/5_tuple/Sample/tuple_ex7.py
692
4
4
'''Question: Write a Python program to get the 4th element and 4th element from last of a tuple. ''' # Python code: >>> #Get an item of the tuple >>> tuplex = ("w", 3, "r", "e", "s", "o", "u", "r", "c", "e") >>> print(tuplex) >>> #Get item (4th element)of the tuple by index >>> item = tuplex[3] >>> ...
4449855ad1d908a4445157e5a0752c9db135ff6e
kuchunbk/PythonBasic
/7_Conditional Statements and loops/Sample/conditional_ex41.py
1,263
3.953125
4
'''Question: Write a Python program to get next day of a given date. ''' # Python code: year = int(input("Input a year: ")) if (year % 400 == 0): leap_year = True elif (year % 100 == 0): leap_year = False elif (year % 4 == 0): leap_year = True else: leap_year = False mo...
3314298cce64e30ba3ee1fb18536bf7bca4e831e
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex50.py
206
4.15625
4
'''Question: Write a Python program to print without newline or space? ''' # Python code: for i in range(0, 10): print('*', end="") print("\n") '''Output sample: ********** '''
036c90c27ad291c077b467be837247756e9b287d
kuchunbk/PythonBasic
/1_Basic_I/Basic/40.py
438
3.796875
4
import math def calculate_distance(input_xa, input_ya, input_xb, input_yb): distance = math.sqrt((input_xa - input_xb) ** 2 + (input_ya - input_yb) ** 2) return distance if __name__ == "__main__": input_xa = float(input('xa')) input_ya = float(input('ya')) input_xb = float...
97d6b224581dfc51eaea1e0d78760cd9c2f57ed5
kuchunbk/PythonBasic
/6_Set/Sample/sets_ex11.py
260
4.1875
4
'''Question: Write a Python program to create a shallow copy of sets. ''' # Python code: setp = set(["Red", "Green"]) setq = set(["Green", "Red"]) #A shallow copy setr = setp.copy() print(setr) '''Output sample: {'Red', 'Green'} '''
a6352d0900af54056e5e81ff49513f1a67e8d521
kuchunbk/PythonBasic
/11_math/math/02.py
217
4.28125
4
import math def convert_radian_degree(radian): degree = radian * 180 / math.pi return degree if __name__=="__main__": radian = float(input('xin moi nhap radian')) print(convert_radian_degree(radian))
26c1bbee5092c5e29b40de4d0decc6fe6a9f0ea9
kuchunbk/PythonBasic
/3_list/Sample/list_ex67.py
407
4.09375
4
'''Question: Write a Python program to find all the values in a list are greater than a specified number. ''' # Python code: list1 = [220, 330, 500] list2 = [12, 17, 21] print(all(x >= 200 for x in list1)) print(all(x >= 25 for x in list2)) '''Output sample: True ...
8956f02a6e7c04d6f5ce1424a43b92dcec4410eb
kuchunbk/PythonBasic
/5_tuple/Sample/tuple_ex8.py
668
4.1875
4
'''Question: Write a Python program to create the colon of a tuple. ''' # Python code: >>> from copy import deepcopy >>> #create a tuple >>> tuplex = ("HELLO", 5, [], True) >>> print(tuplex) >>> #make a copy of a tuple using deepcopy() function >>> tuplex_clone = deepcopy(tuplex) >>> tuplex_clone...
79ab1b5ac995a60a0c8dde0dd0db74e9ffd8aaf2
kuchunbk/PythonBasic
/11_math/Sample/math_ex2.py
638
4.15625
4
'''Question: Write a Python program to convert radian to degree. Note: The radian is the standard unit of angular measure, used in many areas of mathematics. An angle's measurement in radians is numerically equal to the length of a corresponding arc of a unit circle; one radian is just under 57.3 degrees (when the a...
eceaf4a4c743e22119e68b3ddeff33b2c15ff360
kuchunbk/PythonBasic
/7_Conditional Statements and loops/Sample/conditional_ex37.py
1,066
3.921875
4
'''Question: Write a Python program that reads two integers representing a month and day and prints the season for that month and day. ''' # Python code: month = input("Input the month (e.g. January, February etc.): ") day = int(input("Input the day: ")) if month in ('January', 'February', 'March'): ...
6c7c34a8e4b47dd57f7c438fcd5836d6cf620297
kuchunbk/PythonBasic
/1_Basic_I/Basic/18.py
331
4.03125
4
def calculate_total(n1,n2,n3): if n1 == n2 and n2 == n3: return 3 *( n1+ n2+ n3) else: return n1+ n2+ n3 if __name__ == "__main__": n1= int(input('xin moi nhap so thu nhat')) n2= int(input('xin moi nhap so thu hai')) n3= int(input('xin moi nhap so thu ba')) print(calculate_total...
1c2e7c12c98a61d37fcf70a01262bff1bd44cc88
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex112.py
492
4.03125
4
'''Question: Write a Python program to remove the first item from a specified list. ''' # Python code: color = ["Red", "Black", "Green", "White", "Orange"] print("\nOriginal Color: ",color) del color[0] print("After removing the first color: ",color) print() '''Output sample: Original Color: ...
0bc158cff13302f1dc0169f96bc2b011d3a4d61b
kuchunbk/PythonBasic
/4_dictionary/Sample/dictionary_ex8.py
269
3.859375
4
'''Question: Write a Python script to merge two Python dictionaries. ''' # Python code: d1 = {'a': 100, 'b': 200} d2 = {'x': 300, 'y': 200} d = d1.copy() d.update(d2) print(d) '''Output sample: {'x': 300, 'y': 200, 'a': 100, 'b': 200} '''
70bed639b6743d31ba5992ed05facc333667e19c
kuchunbk/PythonBasic
/3_list/Sample/list_ex9.py
364
4.09375
4
'''Question: Write a Python program to clone or copy a list. ''' # Python code: original_list = [10, 22, 44, 23, 4] new_list = list(original_list) print(original_list) print(new_list) '''Output sample: [10, 22, 44, 23, 4] ...
bfdd72da782a986d5984b306770e272aae9289ba
kuchunbk/PythonBasic
/2_String/String_Sample/Sample/string_ex19.py
446
3.96875
4
'''Question: Write a Python program to get the last part of a string before a specified character. ''' # Python code: str1 = 'https://www.w3resource.com/python-exercises/string' print(str1.rsplit('/', 1)[0]) print(str1.rsplit('-', 1)[0]) '''Output sample: https://www.w3resource.com/python-exercise...
21b1f549cd98007f330f5b15e0a7c1b8bbf7960f
kuchunbk/PythonBasic
/7_Conditional Statements and loops/Sample/conditional_ex1.py
499
3.71875
4
'''Question: Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between 1500 and 2700 (both included). ''' # Python code: nl=[] for x in range(1500, 2700): if (x%7==0) and (x%5==0): nl.append(str(x)) print (','.join(nl)) '''Output sample: 1505,...
4059eb5b60a0c37c0b40a0bb4ae009ed47627c63
kuchunbk/PythonBasic
/3_list/Sample/list_ex39.py
403
4.21875
4
'''Question: Write a Python program to convert a list of multiple integers into a single integer. ''' # Python code: L = [11, 33, 50] print("Original List: ",L) x = int("".join(map(str, L))) print("Single Integer: ",x) '''Output sample: Original List: [11, 33, 50] ...
c13a616d8fc5df7446589f1915ce2bfee4e74b4e
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex14.py
276
4
4
'''Question: Write a Python program to calculate number of days between two dates. ''' # Python code: from datetime import date f_date = date(2014, 7, 2) l_date = date(2014, 7, 11) delta = l_date - f_date print(delta.days) '''Output sample: 9 '''
52decc1a7e84bd23add22bb1d31a6950b60a1a99
kuchunbk/PythonBasic
/6_Set/Sample/sets_ex13.py
725
4.375
4
'''Question: Write a Python program to use of frozensets. ''' # Python code: x = frozenset([1, 2, 3, 4, 5]) y = frozenset([3, 4, 5, 6, 7]) #use isdisjoint(). Return True if the set has no elements in common with other. print(x.isdisjoint(y)) #use difference(). Return a new set with elements in the se...
501af311088f0e5f7f4136ba8514588546e0c1e1
kuchunbk/PythonBasic
/9_date_time/Sample/date-time_ex10.py
384
3.65625
4
'''Question: Write a Python program to add 5 seconds with the current time. ''' # Python code: import datetime x= datetime.datetime.now() y = x + datetime.timedelta(0,5) print(x.time()) print(y.time()) '''Output sample: 12:37:43.350241 ...
d3bb13baa21534556159f08744723ad58fdbc33f
kuchunbk/PythonBasic
/2_String/string/04.py
237
3.859375
4
def change_char(str1): char = str1[0] length = len(str1) str1 = str1.replace(char, '$') str1 = char + str1[1:] return str1 if __name__ =="__main__": str1 = input('xin moi nhap chuoi') print(change_char(str1))
e0d9ec94dfe9964da57332363a788c8af96b3137
kuchunbk/PythonBasic
/5_tuple/Sample/tuple_ex3.py
424
4.5625
5
'''Question: Write a Python program to create a tuple with numbers and print one item. ''' # Python code: >>> #Create a tuple with numbers >>> tuplex = 5, 10, 15, 20, 25 >>> print(tuplex) >>> #Create a tuple of one item >>> tuplex = 5, >>> print(tuplex) '''Output sample: (5, 10, 15, 20, 25) ...
3b47ebde67c24169ffa0bf3460cd61f04a58bc33
kuchunbk/PythonBasic
/11_math/Sample/math_ex4.py
762
4.34375
4
'''Question: Write a Python program to calculate the area of a parallelogram. Note: A parallelogram is a quadrilateral with opposite sides parallel (and therefore opposite angles equal). A quadrilateral with equal sides is called a rhombus, and a parallelogram whose angles are all right angles is called a rectangle....
3419b8caae2e2eeae4836ee419513b9ed223b1b4
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex119.py
449
3.796875
4
'''Question: Write a Python program to display a floating number in specified numbers. ''' # Python code: order_amt = 212.374 print('\nThe total order amount comes to %f' % order_amt) print('The total order amount comes to %.2f' % order_amt) print() '''Output sample: The total order amount comes...
a988eb2821c6735a4ccc0007d8536591494a02ec
kuchunbk/PythonBasic
/1_Basic_I/Sample/basic_ex149.py
400
4.375
4
'''Question: Write a Python function that takes a positive integer and returns the sum of the cube of all the positive integers smaller than the specified number. ''' # Python code: def sum_of_cubes(n): n -= 1 total = 0 while n > 0: total += n * n * n n -= 1 return total print("S...
2d30a67a5c0d343eb327e8e42b0efd8ed2f9ffad
kuchunbk/PythonBasic
/7_Conditional Statements and loops/Sample/conditional_ex34.py
596
4.125
4
'''Question: Write a Python program to sum of two given integers. However, if the sum is between 15 to 20 it will return 20. ''' # Python code: def sum(x, y): sum = x + y if sum in range(15, 20): return 20 else: return sum print(sum(10, 6)) print(sum(10, 2)) prin...
8ed21ff631d3a73530acddc9fefcf78ce1d349f2
kuchunbk/PythonBasic
/9_date_time/Sample/date-time_ex35.py
318
4.03125
4
'''Question: Write a Python program to convert a date to Unix timestamp. ''' # Python code: import datetime import time dt = datetime.datetime(2016, 2, 25, 23, 23) print() print("Unix Timestamp: ",(time.mktime(dt.timetuple()))) print() '''Output sample: Unix Timestamp: 1456422780.0 '''
21e9e38a0a4e3ea7f03d480f331a93c158c04c94
kuchunbk/PythonBasic
/9_date_time/Sample/date-time_ex24.py
418
4.09375
4
'''Question: Write a Python program to count the number of Monday of the 1st day of the month from 2015 to 2016. ''' # Python code: import datetime from datetime import datetime monday1 = 0 months = range(1,13) for year in range(2015, 2017): for month in months: if datetime(year, month...
f0d08177b62f05bbf799e085d0f8bd71ef548fb3
kuchunbk/PythonBasic
/3_list/list/01.py
187
3.78125
4
def sum_list(items): sum_numbers = 0 for x in items: sum_numbers += x return sum_numbers if __name__ == "__main__": items = [1,3,4,5,6] print(sum_list(items))
5f65faa2f94650210f87437af7d5b474096624fd
kuchunbk/PythonBasic
/3_list/Sample/list_ex17.py
415
4.125
4
'''Question: Write a Python program to generate and print a list except for the first 5 elements, where the values are square of numbers between 1 and 30 (both included). ''' # Python code: def printValues(): l = list() for i in range(1,21): l.append(i**2) print(l[5:]) printValues() ''...
1ff12026ab6dc5e035e3fa72853a72c496911704
kuchunbk/PythonBasic
/4_dictionary/Sample/dictionary_ex33.py
583
4.03125
4
'''Question: Write a Python program to check multiple keys exists in a dictionary. ''' # Python code: student = { 'name': 'Alex', 'class': 'V', 'roll_id': '2' } print(student.keys() >= {'class', 'name'}) print(student.keys() >= {'name', 'Alex'}) print(student.keys() >= {'roll_id', 'name'})...
a20524eecf3f170d7303c21cdfe9b65342e92d7f
kuchunbk/PythonBasic
/3_list/Sample/list_ex15.py
312
4.21875
4
'''Question: Write a Python program to shuffle and print a specified list. ''' # Python code: from random import shuffle color = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow'] shuffle(color) print(color) '''Output sample: ['Yellow', 'Pink', 'Green', 'Red', 'Black', 'White'] '''
9f21f5d7457f3c268af92d8d09d606cc5dc30b8b
Archer4499/functions
/menu.py
1,731
4.28125
4
#!/usr/bin/env python3 __author__ = 'Derek King' def validate_input(str_input, int_min=float("-inf"), int_max=float("inf")): # Converts a string to an int within a given range # or prints an error message and returns None try: int_input = int(str_input) except ValueError: # ...
9a987ceb8dc0ce6129a99855a2bd7a35be5872ae
mengjiaoliwang/practice
/day01/pc/pcone.py
263
3.921875
4
#要求:从键盘输入刀子的长度,如果刀子长度没有超过10cm,则 # 允许上火车,否则不允许上火车 length=input("请输入刀子的长度") if int(length)>=10: print("刀子过长,不能上车") else: print("可以上车")
d3196e3102ade442fbb412ac764bd65430c130a3
Peti504/dolgozat1
/szavak.py
217
3.90625
4
'''' 2. Írjon programot szavak.py néven! A program kérjen be két szót a felhasználótól, majd írja ki, hogy melyik a hosszabb! ''''' i = input() x = input() if len(i) < len(x): print(i) else: print(x)
c631fae6eda8b6c19125aa03eca659a79b385656
lockleac7655/cti110
/P2T1_SalesPrediction_LocklearCalah.py
652
3.6875
4
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> #Get the projected total sales. >>> #06/15/2020 >>> #CTI-110 P2T1 -Sales Prediction >>> #Calah Locklear >>> total_sales = float(input('Enter t...
4f331551d7a4a6fb83fdeb78ad515256be8cadf1
GeraldHaxhillari/ProjectEuler
/009.py
696
4.28125
4
""" Special Pythagorean triplet Problem 9 A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ import numpy as np def find_triplet(): ...
017f90ad479a0e3a315c0c5f0f62c87f52d3f7c1
chenyi229/Data-Structure
/chenyi_08_手动输入一个列表.py
598
3.53125
4
ar = list(map(str, input().rstrip().split())) print(ar) # 输入一个矩阵的方法 # def matrix(n): # _matrix=[] # for i in range(n): # _matrix.append(list(map(int,input().rstrip().split()))) # return _matrix # # if __name__=="__main__": # n=int(input()) # print(matrix(n)) #求非素数 # list2 = [] ...
e1ade24a9272660d7080b0a68ec254fa38d1a755
chenyi229/Data-Structure
/chenyi_10_单向循环链表.py
3,481
3.96875
4
class Node(object): def __init__(self,elem): self.elem=elem class singleCycleLinkList(object): def __init__(self): self.__head=None def is_empty(self): """判断链表是否为空链表""" return self.__head is None def length(self): """计算单向循环链表的长度""" if self.is_em...
1be614a281885237c64c98e56ac9c25fa4e71405
Rmahesh7/Python-Beginner-practice
/Python-Chapter 3-cost.py
546
4.5
4
# cost.py # A program that computes the cost per square inch of a circular pizza given its diameter and price. Illustrates use of the math library. import math # Makes the math library available. def cost(): print ("This program computes the cost per square inch of a circular pizza.") print() price =...
b4ee8e1bab92c62461f3aadb2663361509256e6e
Rmahesh7/Python-Beginner-practice
/Python-Chapter 6-futval_graph3.py
1,217
4.40625
4
# futval_graph3.py from graphics import* def drawBar(window,year, height): # Draw a bar in window starting at year with given height bar = Rectangle(Point(year,0),Point(year+1, height)) bar.setFill("purple") bar.setWidth(2) bar.draw(window) def futval_graph3(): # Introduction print("This ...
c3e324c4df29b31f659ad9b3476622e82e8b4b0d
Rmahesh7/Python-Beginner-practice
/Python-Chapter 2-avg3.py
277
4.0625
4
def avg(): print("This program computes the average of three exam scores.") score1, score2, score3 = eval(input("Enter three scores separated by a comma: ")) average = (score1 + score2 + score3) / 3 print("The average of the three scores is:", average) avg()
c6c90f0d86ffd43a61e8b23828cfbbf863a5e455
Rmahesh7/Python-Beginner-practice
/Python-Chapter 3-volume.py
500
4.4375
4
# volume.py # A program that computes the volume and surface area of a sphere from its radius. Illustrates use of the math library. import math # Makes the math library available. def volume(): print ("This program computes the volume and surface area of a sphere.") print() r = float(input("Enter rad...
a19329a9ce2d509480490011d338a4292f8377d0
Rmahesh7/Python-Beginner-practice
/InputDialog.py
1,698
3.890625
4
class InputDialog: """ A custom window for getting simulation values (angle, velocity, and height) from the user.""" def __init__(self, angle, vel, height): """ Build and display the input window.""" self.win = win = GraphWin("Initial Values", 200, 300) win.setCoords(0,4....
47fc485ef65afff8e11c1c905318b5f03c499b32
tonythetaylor/trap-n-match
/scripts/scrape_raps.py
922
3.6875
4
# import libraries from urllib.request import urlopen as uReq from urllib.request import Request, urlopen from bs4 import BeautifulSoup as soup headers={ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36' } req = Request('https:/...
ec87f05e8031f6bb3af55158ea3b191f8d2f6b35
salutonl/leetcode
/python_code/word_break.py
345
3.609375
4
class Solution: def wordBreak(self, s, wordDict): start = 0 while s: for wb in wordDict: length = len(wb) if wb == s[start: start + length]: start += length s = s[start - 1:] break return ...
c1b81548e186392bc1993fdbf9ded59db85c7075
rdavis22/BINF-7310
/Programs/Advanced_Programming_Module/acetaminophen2.py
2,960
4.125
4
#Last semester you wrote a Python program to determine whether a medication order for acetaminophen was appropriate. #..,In this assignment, you'll need to modify that program to include the following: #-(done) A function that accepts a patient's age, dose, frequency, and weight (or None by default) and returns true if...
b796e88e8ab5982489a4b726601480fda7512679
tonystarkss/Python-Notes
/app.py
9,747
4.28125
4
character_name = "John" character_age = 50 is_male = True print("There once was a man named " + character_name + ", ") print("he was" + character_age + "years old. ") # Variable labeled name and age with a print statement and a boolean statement character_name = "Mike" print("He really liked the name " + cha...
e60f70cef6eb5f190c553b8e081385394adc2301
trevorwolf1996/SSA-telescope
/solar_radiation_pressure.py
5,811
3.578125
4
# -*- coding: utf-8 -*- """ This function calculates the solar radiation pressure that the spacecraft of interest is experiencing at any given time. This function considers occulation effects from the Earth and the Moon. The occulations can be total, partial or none. One must know the parameters of the spacecraft of ...
1be6c8afd0a633c8048521016bc9f2ff5a72d305
nlns3444/python-dl
/icps/icp6/kmeans.py
1,691
4.03125
4
import pandas#importing the dataset in csv format import pylab as pl#pylab is the graphing library from sklearn.cluster import KMeans#sklearn is used to devise the clustering algorithm. from sklearn.decomposition import PCA variables = pandas.read_csv(r'/Users/nlns/Downloads/Python_Lesson6/sample_stocks.csv')#stores th...
913e8181dbd5f233088234c17ebe4356e65d2622
nlns3444/python-dl
/icps/icp3/count vowels.py
348
4.03125
4
user_input = input("enter a sentence:-")#takes input from the user list_1 = list(user_input)# takes the input into the list1 print(list_1) set_1 ={'a', 'e', 'i', 'o', 'u', 'A', 'e', 'i', 'o', 'u'} count = 0 for i in list_1:# counnts the number of vowels in the list1 and counts them in the set if i in set_1: ...
6ce1c222e332eb8f7ac258cbc767e79fce8a7a2e
cechlauren/final
/NNfxns/train.py
12,382
3.578125
4
""" Training the neural net What can be used: autoencoder testme <splits> <sampling> test Arguments: autoencoder Run ze autoencoder testme Do the rap1 learning task including cross-validation test Classify test data and output to tsv file type <split...
040b32a505d8f97b132274275ee2cea74cd24500
Thebomblopez/playground
/person.py
1,365
3.796875
4
# Make Person Class class Person: def __init__(self, name, chips): self.name = name self.chips = chips self.hand = [] self.bet_amount = int self.playing = True # String Representation def __repr__(self): return self.name # Print Out def __str__(self)...
8cbe81c421d251ef4dd66f23b99778edcf2ca4c1
dc-avasilev/Python-1
/multiprocessing/multiprocessing1.py
301
3.796875
4
from multiprocessing import Pool def f(n): return n**2 Array = [1,2,3,4,5] p = Pool() result = p.map(f,Array) print result # using single core """ def f(n): return n**2 if __name__=="__main__": Array = [1,2,3,4,5] result = [] for n in Array: result.append(f(n)) print result """
da9132eeccf94f4a15ad9a21e11b1e13f7249ae0
dc-avasilev/Python-1
/class/t.py
568
4.125
4
"""class Multiplication(object): first=None second=None result=None def firstNo(self): self.first=input("enter the first number: ") pass def secondNo(self): self.second=input("enter the second number: ") def result(self): self.firstNo() self.secondNo() result= self.first * self.second print "re...
379d1bcf760f43bc54c141cf9a2bf0dc16ce0ee0
AndresNamm/Adversarial
/multiAgents.py
14,534
4.09375
4
import math from util import manhattanDistance from game import Directions import random, util from game import Agent import pdb import sys import math class ReflexAgent(Agent): """ A reflex agent chooses an action at each choice point by examining its alternatives via a state evaluation function. ...
40741e39d7a3b679a14ec745d26bf88987f767cc
Basantloay/NLP_Word_Segmentation
/WordSegmentation.py
3,480
3.796875
4
import math import functools # ############################################################## # all numbers and constants taken from http://norvig.com/ngrams/ch14.pdf # ############################ Unigram ##################################### """ File count_1w.txt is taken from http://norvig.com/ngrams/count_1w.txt...
5fa6827ab3c9d557f6561f067460e184656d4fcd
RezaFirouzii/TicTacToe-AI-minimax
/Tic Tac Toe - AI/pygame_utils.py
2,393
3.6875
4
# bunch of usefull GUI clesses # and functions made with pygame import pygame # blits a text on screen def messageToScreen(screen, message, color, vertical_space=0): x, y = screen.get_width() // 2 - len(message) * 6, screen.get_height() // 5 + vertical_space font = pygame.font.SysFont('arial', 30, 0, 0) ...
0d2bab06a7c6557f952712dfe19d750f7b657c8f
daldunin/Checking-Consistency-of-CS-Curriculum
/acyclicity.py
2,027
4.03125
4
# Uses python3 # Problem: Checking Consistency of CS Curriculum # Problem Introduction # A Computer Science curriculum specifies the prerequisites for each course as a list of courses that should be # taken before taking this course. You would like to perform a consistency check of the curriculum, that is, # to check ...
d3d3c465a0715c845eaae76f1f23b8d62e2b4b3d
Linsi6280/classwork
/Loops 2.py
245
3.984375
4
# 1 for i in range(10): #f or i in " " * 10: print("hello") # 2 for i in range(0, 101, 3): print(i) for num in range(101): if num % 3 == 0: print(num) # 3 total = 0 for num in range(1, 11): total += num print(total)
aee189b8179ed0637eecc1bc8c697514f225c341
gopukrish100/gopz
/PycharmProjects/Mysql/venv/five.py
208
3.96875
4
def fibonacci(n): ini=0 sec=1 print(ini) print(sec) for i in range(0,n-2): nex=ini+sec print(nex) ini=sec sec=nex n=int(input('eneter length')) fibonacci(n)
eade3baa30c708a4cd78b829b241b91e49ed6834
gopukrish100/gopz
/PycharmProjects/class/samples/constructor.py
317
3.609375
4
class Student: schoolname='luminar' def __init__(self,name,rol): self.name=name self.rol=rol def display(self): print('name=',self.name) print('roll no',self.rol) def __str__(self): return self.name+str(self.rol) obj=Student('anj',12) obj.display() print(obj)
c50c14001e3a7efee71a83b10ba394964eed2e18
gopukrish100/gopz
/PycharmProjects/class/samples/cls.py
1,674
3.5
4
# class person: # def welcome(self): # # print('welcome user') # obj=person() # print(type(obj)) # # obj.welcome() # class student: # def displayvalues(self,name,roll,college): # self.roll=roll # self.name=name # self.college=college # print('name=',self.name) # ...
619d90153e96d12e51efb78d318a5b801c12f842
beingnishas/projecteuler
/005_Smallest_multiple.py
353
3.828125
4
''' 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? ''' lower_limit=int(input("Enter lower limit of range: ")) upper_limit=int(input("Enter upper limit of range: ...
046a8e41b1c1490323a044412863949551e1a536
antkowiakn/Python_Challenge
/PyPoll/Main.py
2,919
3.9375
4
#allowance to create file paths across operating systems import os #import module for reading CSV Files and give path import csv poll_csvpath = os.path.join('Resources','election_data.csv' ) #define variables #total number of votes for all candidates total_votes=0 #a unique list of candidates candidate_list_unique=[] ...
386c8e8be61372fb87c93e20075fdda66e296fa3
Osvclua/UCA
/Python-C++/Cifras/frequen.py
612
3.71875
4
# acumula la ocurrencia de los caracteres en un dict import sys def acumula(linea,res): for letras in linea: res[letras] = res.get(letras, 0) + 1 return if len(sys.argv) <2: print("Uso: ", sys.argv[0]," <archivo>") exit(1) #n_arch=input('Archivo? ') n_arch=sys.argv[1] archin=open(n_arch,'r') res...
de292209e14ade391a3b936408a690f1ba149205
juancramos/ComputationalPhysicsUniandes
/hands_on/python/lists.py
320
3.9375
4
# definition of a list with 4 items my_list = ["Apple", 3.40, 1, "Hello world"] # print them one by one print my_list[0] print my_list[1] print my_list[2] print my_list[3] #print the first three print my_list[0:3] #iterate and do something with each item for item in list: new_item = 2 * item print new_item
271c519b4703abc487d8e64d9ad98ed60c2fe3a1
ibmresilient/resilient-community-apps
/fn_twilio/fn_twilio/lib/common.py
2,178
4.1875
4
# -*- coding: utf-8 -*- # pragma pylint: disable=unused-argument, no-self-use # (c) Copyright IBM Corp. 2010, 2020. All Rights Reserved. import re import calendar SECONDS_IN_MINUTE = 60 SECONDS_IN_HOUR = SECONDS_IN_MINUTE*60 SECONDS_IN_DAY = SECONDS_IN_HOUR*24 SECONDS_IN_WEEK = SECONDS_IN_DAY*7 def get_interval(time...
70e57365aad7ccc0a2886990ea124d3d52cc3b06
ibmresilient/resilient-community-apps
/fn_machine_learning/fn_machine_learning/lib/multi_id_binarizer.py
3,871
3.53125
4
# -*- coding: utf-8 -*- # pragma pylint: disable=unused-argument, no-self-use # # (c) Copyright IBM Corp. 2010, 2018. All Rights Reserved. # """ MultiIdBinarizer ---------------- This is an extension of MultiLabelBinarizer. It can take a list of string like ["[1,2,3]", "[2]", "[5,6,7]"] directly from ...
78d7eade2b8cf6f5ea1da22bfb97453363b86ab7
hiredd/ECG_NN
/main.py
1,749
3.640625
4
import numpy as np #def dw_update() class mlp: #n debe ser un vector con el primero elemento la cantidad de entradas a la red, y las restantes la cantidad de #neuronas en cada capa, la idea es manejar backpropagation solo para una red de etapas multiples generica def __init__(self, n): self.n = n ...
816f8f5ac9113356ab1f60017a00872f642cfb53
ChintalaNavaneeth/python-programming-mycaptain
/task4.py
178
4.09375
4
user_input = input("Enter any string: ") print("The entered string in capital letters ", user_input.upper()) print("The entered string in small letters ", user_input.lower())
b2902e63988a67e8e6c5df867f053df48da0ac94
boppreh/poly
/tests.py
1,580
3.578125
4
import unittest from random import randint from reference import Polynomial from poly import * class Tests(unittest.TestCase): def test_generate(self): for degree in range(2, 5): for i in range(100): poly = Polynomial.random(degree) points = poly.points(*range(de...
a596160e7df371d00371201fec89223c139e07bb
hexec8/rolling_dice
/main.py
420
3.859375
4
import random dice = [1, 2, 3, 4, 5, 6] user = input("Would you like to roll the dice? (y/n) ").lower() if user == 'y': die_count = int(input("One (1) die?; or two (2)? ")) if die_count == 1: print(random.choice(dice)) elif die_count == 2: print((random.choice(dice)) + (rando...
e7ad9030177fec26374355a6265a3977f986d15c
Darshan1917/matplotlib_basics
/stack_demo2.py
979
3.953125
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 9 20:11:41 2018 @author: dumapath """ # Stack plot are used to show Size of use or the relative percentage in a whole # This is used to convey a holistic number and in that full number sections that comprise the holistic number import matplotlib.pyplot as plt days ...
23371f0378048141717c294f54d033f6cfdec806
BatzorigShinebayar/ModernSoftwareDevelopment
/HelloWorld/Python.py
71
3.78125
4
Str1 = "Hello" Str2 = "World" Str3 = Str1 + " New " + Str2 print(Str3)
1d5d41790fd6880cf3691bc76e4932b36fd930a6
AlexisWolfWaisman/CodeFights-spanish
/arcade/intro/LacostaDelOceano/adjacentElementsProduct.py
771
3.96875
4
""" Traduccion del problema: Producto de elementos adyacentes Traducccion del enunciado: Dado un arreglo de enteros, encontrar el par de elementos adyacentes que tenga el producto mas grande devolver ese producto Enfoque (approach): 1) Tomamos de a dos elementos desde el primer elemento del array (lista ,e...
05add3c7bb2c2dd94e142236430e5c8b60d04dad
DaeGyeongYi/00.Basic_step
/20210714 Datastructure & Algorithm/선형리스트/Code03-04.py
1,221
3.640625
4
##함수 선언부(클래스 선언부) def add_data(friend): katok.append(None) kLen = len(katok) katok[kLen - 1] = friend def insert_data(position, friend): katok.append(None) # 배열의 길이를 하나 늘림 kLen = len(katok) for i in range(kLen - 1, position, -1): katok[i] = katok[i - 1] katok[i - 1] = None ...
6e2a812ef7cee342499f89f5037894b5eaad9db3
foeveryoung/Pyhton_practice
/pachong/jianshu.py
998
3.5625
4
import requests #lxml是Python语言中处理XML和HTML功能最丰富,最易于使用的库 from lxml import etree urls=['http://www.jianshu.com/users/54b5900965ea/followers?page={}'.format(str(i)) for i in range(1,6)] print(urls) for url in urls: print('11') html=requests.get(url) selector=etree.HTML(html.text) infos=s...
41c5524ebcb84c0dac7aa8cdc7651a3ccd07d2b7
xMakerx/cio-src
/extras/tests/FileWordReplacer.py
976
3.78125
4
# Filename: FileWordReplacer.py # Created by: blach (21Apr15) BASE_PATH = raw_input("Base path (where all the folders to look in are): ") FOLDER_NAMES = raw_input("Folders to look in (separate with semicolon): ") FILE_WORD = raw_input("Word to replace: ") FILE_WORD_2_REPLACE_WITH = raw_input("Word to replace with: ")...
13ef943602f7beb15accf8e7c320651f27779e1f
User9000/python_own
/classes.py
434
3.5625
4
###Clases ....objects class Animal(): name = 'amy' noise = "Grunt" size = "large" color = "brown" hair = "Covers body" def get_color(self): return self.color def make_noise(self): return self.noise class Dog(Animal): name = 'Jon' # color = 'brown' # def get_colo...
115bbe1a0b0b59ae28e5a8de2d91f39653697ca9
waveman68/MIT6001x_Intro2CS_and_Python
/L12_problem5.py
1,353
3.921875
4
__author__ = 'Sam Broderick' # my solution # def genPrimes(): # global n # n = 0 # iterator of list of primes # l_primes = [2] # initialize list of primes # prime_not_found = True # initialize boolean # is_prime = True # while True: # next = l_primes[n] # ...
81db36dfac207fd29397dbac8ddad448d496c77e
dvan3/CMSC201
/projects/proj2/proj2.py
14,734
3.890625
4
#Filename: design2.txt #Author: Dave Van #Date: 5/6/10 #Email: dvan3@umbc.edu #Section: 06 #Description: #This program will use recursive functions to draw a koch snowflake, a #C-Curve, an animated koch snowflake, and a dragon curve. It will also #use a user defined turtle class to draw the snowflakes and cur...
b9c4a4d1ebbf9a1e22b329fc705c911e87c84735
dvan3/CMSC201
/labs/lab2/errors.py
389
3.53125
4
# File: errors.py # Written by: Patti Ordonez # Date: 5/?/09 # Section: All # Email: ordopa1@umbc.edu # Description: This program contains some buggy code for you to correct. print "This program finds the average of two integers." num1, num2 = input("Enter two numbers separated by a comma: ")...
383bd2e0418da45c5847bfffa58c6988eb80eb79
dvan3/CMSC201
/homeworks/hw7/hw7.py
8,839
4.65625
5
#Filename: hw7.py #Written by: Dave Van #Date: 4/8/10 #Seciton: 06 #Email: dvan3@umbc.edu #Description: #Using the hailstone sequence, the user will enter a number and if the number #is even divide it in half, if the number is odd, multiply it by three and add #one to it. It will also use a menu. T...