blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
e90cd7248d87c13aef456d11b1df96d868a8352b | VarahaMaithreya/LinkedIn-Automatic-JobApply | /main.py | 462 | 3.625 | 4 | import gui
from tkinter import *
if __name__ == "__main__":
root = Tk()
####Centers Window####
w = root.winfo_reqwidth()
h = root.winfo_reqheight()
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = (ws / 2) - (w / 2)
y = (hs / 2) - (h / 2)
root.geometry('+%d+%d' % (x... |
cc7b73dfe866bd9d8da9e1c7283faf33d62fb2d6 | computingForSocialScience/cfss-homework-AlyssaBlack | /Assignment5/barChart.py | 2,640 | 3.703125 | 4 | import unicodecsv as csv
import matplotlib.pyplot as plt
def getBarChartData():
#Open csv files for artists and albums
f_artists = open('artists.csv')
f_albums = open('albums.csv')
#Breaks down each csv file by row using reader() method.
artists_rows = csv.reader(f_artists)
albums_rows = csv.reader(f_... |
505edae6fba1f403cfda272249c6f760b5c4d7c9 | valerie-kim/100daysofcode | /06-22/Day27/args_kwargs/main.py | 277 | 3.796875 | 4 | def add(*args): # arg is tuple
sum = 0
for n in args:
sum += n
return sum
print(add(2,6,34,2,376,2,8,76,1,0))
def calculate(n, **kwargs): # kwargs is dict
n += kwargs["add"]
n *= kwargs["multiply"]
print(n)
calculate(2, add=3, multiply=5) |
dbe80e5820eb10ed8a6372cb0cc459f37ae30d7d | nramkissoon/Kanjidicparser | /kanjidicparser.py | 5,393 | 3.953125 | 4 |
""" This is a script for parsing data from the KANJIDIC project (http://www.edrdg.org/wiki/index.php/KANJIDIC_Project)
Script opens kanjidic2.xml and reads the data into the variable "all_lines".
Data is then filtered for relevant information for each kanji character. "Relevant information" refers to the elements
of ... |
07d45436b24b2ecc8843f08e963a6f1040c96ded | cdslug/GoogleFoobar_Python | /GoogleFoobar/googleProblem3ESolution2.py | 1,516 | 3.6875 | 4 | import timeit
# import math
def memoize(func):
memo = {}
def helper(input1,input2):
if (input1,input2) not in memo:
memo[(input1,input2)] = func(input1,input2)
return memo[(input1,input2)]
return helper
def answer(n):
largestSquare = getSquareList(n)[-1]
return searchLeastItems(n,largestSquare)
def getS... |
ea4963537aae219daa04b89701659296ba18b5c9 | cdslug/GoogleFoobar_Python | /GoogleFoobar/googleProblem3CSolution.py | 4,021 | 3.796875 | 4 | import timeit
def answer(words):
pairedLetters = splitByHeirarchy(words)
letterDict = pairsToDict(pairedLetters)
return determineOrder(letterDict)
def splitByHeirarchy(words):
### Input:
### list of words sorted alphabetically according to the desired language
### Output:
### For all words, pair up each letter w... |
84bf3d0c2102c5cb6dc6a3a0f677777cc6037e6c | Can-Yaman/Python-Assignments | /assignment_4.py | 430 | 4.3125 | 4 | divider_num = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
num = int(input("Please input a number to check if it's a prime number or not: "))
result = False
if num in divider_num:
if num in [2, 3, 5, 7, 11]:
result = False
else:
result = True
else:
for i in divider_num:
result = result or (not (... |
b2e629743cdca45715ae1031ce6f63362d3e8f6c | brimmann/linked-list-python | /linked_list.py | 2,039 | 4.09375 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def push(self, new_data):
new_node = Node(new_data)
new_node.next = self.head
self.head = new_node
... |
b7975aef6d4c5301b242434d30e0eebf853ccdd5 | sumantasunny/TensorFlowB2E | /TFMedium/Named/Classification.py | 2,454 | 3.671875 | 4 | """
Know more, visit my Python tutorial page: https://morvanzhou.github.io/tutorials/
My Youtube Channel: https://www.youtube.com/user/MorvanZhou
"""
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
tf.set_random_seed(100)
np.random.seed(100)
# fake data
n_data = np.ones((1000, 2... |
940bf093fab02c3d6cc9ae9f11d63d8f33ea205f | Oceania2018/TensorFlow2.0-Examples | /1-Introduction/basic_operations.py | 2,325 | 3.59375 | 4 | #! /usr/bin/env python
# coding=utf-8
#================================================================
# Copyright (C) 2019 * Ltd. All rights reserved.
#
# Editor : VIM
# File name : basic_operations.py
# Author : YunYang1994
# Created date: 2019-03-08 14:32:57
# Description :
#
#==============... |
28662b95d5e8a6c2031a36825ebc61f1cb53314d | felixmanugara/Python-Dasar | /tipedata_dictionary.py | 873 | 3.71875 | 4 | # adalah sebuah tipe data asosiatif menggunakan mapping
# {key:value}
anggota1 = { "NIM":989808997,
"Nama": "Felix",
"Pekerjaan": "Pelajar",
"Status": "manusia"
}
print(anggota1)
print(anggota1["NIM"]) # digunakan untuk memanggil data berdasarkan key
print(anggota1["Nama"... |
ec5efd96e4c25f7818a7f00dd25e5afa2c8df0de | felixmanugara/Python-Dasar | /while_loop.py | 465 | 3.90625 | 4 | # while loop sama dengan for loop yang
# merupakan syntax perulangan cuma bedanya
# while loop sifatnya infinite (tidak akan berhenti)
num = 0 # nilai awal
while num < 5: # kondisi yang akan dicek ketika looping
print('nilai saat ini', num)
num +=1 # nilai akan bertambah 1 pada setiap iterasi
# saa... |
81005a557d16a667a92b5cdc37353948fc131354 | felixmanugara/Python-Dasar | /input_output_file.py | 748 | 3.78125 | 4 | # input output file
# input output command
# w = write mode / mode untuk menulis atau menghapus file lama, jika file belum dibuat maka akan dibuat baru
# r = read only mode
# a = appending mode / menambahkan data pada akhir baris
# r+ = write and read mode
# membuat file text
file = open("data.txt",'w')
file.write... |
801e7f97b5a4ebe729d6a5498c3305b2a177b334 | nikibobi/advent-of-code-2017 | /day01.py | 451 | 3.5625 | 4 | def day01(digits, step=1):
n = len(digits)
s = 0
for i in range(n):
j = (i + step) % n
if digits[i] == digits[j]:
s += int(digits[i])
return s
def main():
with open("inputs/day01.txt") as file:
digits = file.readline().rstrip()
result = day01(digits, 1)
... |
54fc2c4c6b7c7573874a5f837f6990c58339a5e8 | juneja2/Python-repo | /function_hw.py | 2,790 | 3.890625 | 4 | import math
import string
def vol(rad):
return 4 * math.pi * (rad ** 3)/3
print(vol(2))
def ran_check(num, low, high):
if num in range(low, high + 1):
print(f'{num} is in the range between {low} and {high}')
def ran_bool(num, low, high):
return num in range(low, high + 1)
ran_che... |
057ab6cff8cd2107b07c77a473faab9402378bf5 | chhwu/-If-pratice---grades | /'If' practice-grades.py | 327 | 4.15625 | 4 | grade = int(input('Please enter you grade: '))
if grade >= 95:
print('EXCELLENT, you get an A+ !')
elif 90 <= grade < 100:
print('Well done, you get an A.')
elif 80 <= grade < 90:
print('Nice, you get a B.')
elif 70 <= grade < 80:
print('C.')
elif 60 <= grade < 70:
print('D.')
else:
print('You f... |
28a06c17d471aa67e820b46f2cc6ef0958e09ff0 | battyone/CapstoneThesis | /bank.py | 1,414 | 4.09375 | 4 | """Bank.py
Defines the bank class.
"""
import math
from balance import BalanceSheet
from settings import *
from statistics import Statistics
class Bank(object):
"""
Defines a bank.
bank_size specifies the balance sheet size of the bank in dollars.
"""
def __init__(self, bank_size):
self.b... |
c31fa2150634325d34372b02e1dea8acef9a417f | NtateLephadi/csc1015f_assignment_8 | /pairs.py | 376 | 3.96875 | 4 | def pairs(sentence):
if sentence == "":
return 0
elif len(sentence) == 1:
return 0
elif sentence[0] == sentence[1]:
return 1 + pairs(sentence[2:])
else:
return pairs(sentence[1:])
def main():
sentence = input("Enter a message:\n")
print("Number of pairs: " + str(... |
9de69823807d85f2d3d0158cb9b6233948c30634 | annie2010/santafe-dev-node_app | /speakeasy/4.py | 1,023 | 3.578125 | 4 | #!/usr/bin/env python
import base64
my_key="This is interesting What is going on Need a long sentence carry on and take more"
secret = base64.b32encode(my_key)
print secret
from otpauth import OtpAuth
def otpauth_totp(f_key):
print "\n1.b test totp"
auth = OtpAuth(f_key) # default step=30
code = auth.totp()
... |
78342740a661458711dd3af237b26f5df82cef09 | watadarkstar/school-works | /assignments/2008-2012/universityOfWaterloo/cs116/a9/a9q5.py | 565 | 3.703125 | 4 | ## *****************************************************
##
## CS 116 Assignment 9, Question 5
## Darren Poon
## (read_cipher)
##
## *****************************************************
## Conctract: read_cipher: string -> dictionary
## Purpose: the function that consumes a string and produces a dictio... |
2da83b0b21aa3c98cc8cac845070d3ce1e57625f | watadarkstar/school-works | /assignments/2008-2012/universityOfWaterloo/cs116/a9/a9q4.py | 641 | 3.75 | 4 | ## *****************************************************
##
## CS 116 Assignment 9, Question 6
## Darren Poon
## (make_cipher)
##
## *****************************************************
## Contract: make_chiper: integer string -> file
## Purpose: the function which consumes an integer amount to shift, ... |
7edaf661887f9821e0d363ed2ce761e8cc6eeaa0 | watadarkstar/school-works | /assignments/2008-2012/universityOfWaterloo/cs116/a8/a8q3.py | 949 | 4.1875 | 4 | ## *****************************************************
##
## CS 116 Assignment 8, Question 3
## Darren Poon
## (rotate_suits)
##
## *****************************************************
## Contract: (listof card) => (union None or (listof card))
## Purpose: a function rotate_suits that consumes a non_... |
d31bf58c6944e38b5201f6d5f6a34df769419825 | MaxMeiY/leetcode | /construct_string_from_binary_tree.py | 1,689 | 3.984375 | 4 | '''
This is correct. just for coding and testing.
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def has_left(self):
return self.left != None
def has_right(self):
return self.right != None
def has_child(self):
re... |
10ff1e710efda3df1c3ef652b7e0d9cce94ef029 | MaxMeiY/leetcode | /guess_number.py | 594 | 3.734375 | 4 | # The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
# def guess(num):
class Solution(object):
def guessNumber(self, n):
"""
:type n: int
:rtype: int
"""
start = 1
end = ... |
0d531d8f520edb1d7546f223c44e68a76ca9b9c1 | MaxMeiY/leetcode | /binary_tree_level_order.py | 780 | 3.78125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def levelOrderBottom(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
... |
c271fe0168647aba5fa0a50ec7d4415f23d5f2a5 | poebus0102/JINWOO | /9.세트집합.py | 683 | 3.78125 | 4 | # 집합 (set)
# 중복 안됨 , 순서없음
my_set = {1,2,3,3,3,3,3}
print(my_set)
java = {'유재석','김태호','양세형'}
python = set(["유재석","박명수"])
#교집합 (java 와 python 모두 출력)
print(java & python)
print(java.intersection(python))
#합집합 (java 할 수 있거나 python 할 수 있는 개발자)
print(java|python)
print(java.union(python))
#차집합 (java 할 ... |
179f1133bb033bd1ef2d34b7ec33ab63680d8925 | hrushikeshrv/instagram-data-analysis | /instagram_utils.py | 16,166 | 3.546875 | 4 | import seaborn as sns
import matplotlib.pyplot as plt
import string
import re
#----------------------------------------------------------------------------------------------------------------------------#
def print_conversation(person, my_username, dms, return_photos = False):
"""
Takes in a username... |
7e56a6301fb41bc93073cc09f087312c76c084c6 | CheeShyan96/atbs2-projects | /Chapter_04/commaCode.py | 938 | 4.53125 | 5 | '''
Chapter 4 Lists
Comma Code
Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function that takes a list value as an argument and returns
a string with all the items separated by a comma and a space, with and
inserted before the last item. For example, passing the previo... |
0add98610291f196b6ad3c12d72f24cf78e2ec96 | CheeShyan96/atbs2-projects | /Chapter_10/deletingUnneededFiles.py | 2,138 | 4.125 | 4 | '''
Chapter 10 Organizing Files
Deleting Unneeded Files
It’s not uncommon for a few unneeded but humongous files or folders to
take up the bulk of the space on your hard drive. If you’re trying to free up
room on your computer, you’ll get the most bang for your buck by deleting
the most massive of the unwanted files.... |
064caf55a0a6bb628cfdb692b690eb88ecd2cb4e | tomastorralba/TrabajosPython | /py5_matplotlib/plot_list.py | 295 | 4.03125 | 4 | import matplotlib.pyplot as plot
lista =[]
numero = int(input('ingrese el numero a evaluar :'))
lista.append(numero)
while numero != 1:
if (numero % 2)== 0:
numero=numero // 2
else:
numero = numero * 3 + 1
lista.append(numero)
print("la lista de numero es :" , lista)
|
f0c2e7acc3a0e1ea9ea8f647bfb4de3a91365167 | wangweiqi999/redis_protocol_parser | /parser.py | 2,905 | 3.796875 | 4 | class ProtocolList:
"""
用于保存将字符串解析为一个 list 后的数据
"""
def __init__(self, input_string):
self.list = input_string.split('\r\n')
self.index = 0
self.length = len(self.list)
def read_line(self):
self.index += 1
return self.list[self.index-1]
def read_line_pre... |
75d063cbdbbaa61a6389a83d52edc6e204ac16fe | benbauer14/snake_game_high_score | /snake.py | 2,074 | 3.640625 | 4 | from turtle import Turtle,Screen, setheading
STARTING_POSITIONS = [(0,0), (-10, 0), (-20, 0)]
MOVE_DISTANCE = 10
class Snake:
def __init__(self):
self.segments = []
self.createSnake()
def createSnake(self):
for position in STARTING_POSITIONS:
new_segment = Turtle("square")
... |
c22fa4bbb882b49d7375bc095ed661a66799cee3 | HollenLuo/lerantest | /11_20/ex_19.py | 815 | 4 | 4 | # -*- coding:utf8 -*-
def cheese_and_crackers(cheese_count, boxes_of_crackers):
print("You have %d cheeses!" % cheese_count)
print("You have %d boxes of crackers!" % boxes_of_crackers)
print("Man that's enough for a party!")
print("Get a blanket.\n")
print("We can just give the function numbers direct... |
2e3375d9143154015b5f3ea13b002a87471cd634 | lloydy500/python_practice | /tower_builder.py | 366 | 3.78125 | 4 | def tower_builder(n_floors):
#for each floor, f, in range 0..n
#print "*" f + (f-1) times
#add f - (f-1) spaces to each side
#append it to the tower array
#return the tower array
a = []
for f in range(1, n_floors + 1):
a.append((((" ") * (n_floors - f)) + (("*" * f) + ("*" * (f-1)))) + ((" ") * (n_flo... |
de9c58112271cac9e80b1bc7a092d0ae986c4251 | lloydy500/python_practice | /motives.py | 220 | 3.625 | 4 | def delete_nth(order,max_e):
new_a = []
for i in order:
print(i)
if new_a.count(i) >= max_e:
else:
new_a.append(i)
return new_a
delete_nth([20, 37, 20, 21], 1)
|
45cfcb16869c07cde427465f81fa6ad001849835 | yasui4645/CSVReader | /CSVReader.py | 228 | 3.734375 | 4 | import csv
csv_file = open('./test.csv', 'r', newline='', encoding="UTF-8")
reader = csv.reader(csv_file)
for row in reader:
print('----------------------------')
for cell in row:
print(cell)
csv_file.close()
|
138b77609b3787a98205bc78592d7cfa3143fcec | harverywxu/algorithm_python | /00_python_basic/01lang/args_kws.py | 462 | 3.53125 | 4 | """
(1, 2, 3, 4)
{}
{}
fun
()
{'y': 2, 'x': 1}
{}
fun
(1, 2)
{'y': 'y', 'x': 'x'}
{}
fun
('a', 1, None)
{'y': 'y', 'x': 'x'}
{}
fun
"""
def fun(*args, **kwargs):
print args
print kwargs
print fun.__dict__
print fun.__name__
pass
def fun_test():
# args
fun(1, 2, 3, 4)
# kws
fun(x=... |
38319c89c2ba84b66e554c52c2a58830ae08312e | harverywxu/algorithm_python | /02_list/03reorder_list/143.ReorderList.py | 1,225 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You may not modify the values in the list's nodes, only nodes itself may be changed.
Example 1:
Given 1->2->3->4, reorder it to 1->4->2->3.
Example 2:
Given 1->2->3->4->5, reorder... |
29aeebab233bf8f383da2bf60c98a93152ee7d13 | harverywxu/algorithm_python | /01_string/07多个不覆盖的子数组和最大值/689. MaximumSumof 3Non-OverlappingSubarrays.py | 2,618 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.
Each subarray will be of size k, and we want to maximize the sum of all 3*k entries.
Return the result as a list of indices representing the starting position of each int... |
9b1078a82e55647db9a2a140f062f574832d5070 | harverywxu/algorithm_python | /01_string/03动荡子序列/978. 最长动荡子数组.py | 2,280 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
978. Longest Turbulent Subarray
A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if:
For i <= k < j, A[k] > A[k+1] when k is odd, and A[k] < A[k+1] when k is even;
OR, for i <= k < j, A[k] > A[k+1] when k is even, and A[k] < A[k+1] when k is... |
9a9776013dc5fe280c73f603e9c514495ac482fa | harverywxu/algorithm_python | /02_list/02remove_duplicates_in_sorted_list/82.RemoveDuplicatesfromSortedListII.py | 1,661 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
Example 1:
Input: 1->2->3->3->4->4->5
Output: 1->2->5
Example 2:
Input: 1->1->1->2->3
Output: 2->3
"""
# Definition for singly-linked lis... |
51fd24008610323a9711b82b9e49a745e527d040 | harverywxu/algorithm_python | /05_sort/quickSort.py | 1,650 | 3.53125 | 4 | import unittest
def partition_sort(list_int, start, end):
if list_int is None:
return
if start == end:
return start
little_right = start
for index in range(start+1, end+1):
if list_int[index] < list_int[start]:
little_right += 1
if index != little_right:... |
5c714719f42e311ea3518c2c4115f3b365238c92 | harverywxu/algorithm_python | /01_string/06所有可能组合/115. DistinctSubsequences.py | 1,487 | 3.875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Given a string S and a string T, count the number of distinct subsequences of S which equals T.
A subsequence of a string is a new string which is formed from the original string
by deleting some (can be none) of the characters without disturbing the relative
positio... |
38f8e79725273d84fcc25ebf25f13e73d3bb03f2 | harverywxu/algorithm_python | /01_string/02longest_substr/395. LongestSubstringwithAtLeastKRepeatingCharacters.py | 2,065 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times.
Example 1:
Input:
s = "aaabb", k = 3
Output:
3
The longest substring is "aaa", as 'a' is repeated 3 times.... |
763f01c3f6e41bed8c88d72977b213482becda8c | harverywxu/algorithm_python | /01_string/02longest_substr/1044.最长重复子串.py | 3,917 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
1044. Longest Duplicate Substring
Given a string S, consider all duplicated substrings: (contiguous) substrings of S that occur 2 or more times. (The occurrences may overlap.)
Return any duplicated substring that has the longest possible length. (If S does not have... |
ed66b33838f05661386093a99a1420ed3874935f | jjmoonisboss/Harvard-Summer-Coding | /caesar.py | 716 | 4.3125 | 4 | key=int(input("key:"))
plaintxt=input("insert text:")
ciphertxt=""
for i in plaintxt:
if i == " ":
print(i,end="")
# ciphertxt += " "
#this is to add on a space to your code.
elif i.isupper():
# ciphertxt +=chr(ord(i) + key)
ciphertxt=(ord(i)-65 + key)% 26 + 65
... |
d87d834a14039b29c09cb71f827ce55d5eacb316 | jjmoonisboss/Harvard-Summer-Coding | /guess.py | 255 | 3.828125 | 4 | #try to create a guessinng game
import random
x = random.randint(0,10)
from cs50 import get_int
guess = get_int("Guess a number, any number:")
if guess > x:
print("Too low!")
elif guess < x:
print("Too high!")
else:
print("You've got it!")
|
c491e88d2b8382863779b63b037c4887be9b66a0 | jjmoonisboss/Harvard-Summer-Coding | /reverse.py | 107 | 3.90625 | 4 | myString=input("phrase:")
for i in range(len(myString)-1, -1, -1):
print(myString[i], end="")
print()
|
08de204b90a632267568a92404ab46714a0889f2 | jjmoonisboss/Harvard-Summer-Coding | /weather.py | 306 | 4.1875 | 4 | from cs50 import get_int
temp = get_int("What temperature is it today ")
if temp >= 80:
print("Wear a t-shirt")
#else if is elif in python
elif temp <= 60:
print("Wear a sweater")
elif temp <=50:
print("Wear a jacket")
elif temp <= 40:
print("Wear a coat")
|
22029bcdf46b2e4143af4d84516b1d1c4883f44a | FrankYuDang/Python-Cookbook | /UnpackingElement.py | 1,837 | 4.1875 | 4 | # Unpacking elements from iterables of Arbitrary Lenth
# Sep, 16, 2019
# Star expression can be used to unpack N elements from an iterable.
def drop_first_last(grades):
first, *middle, last = grades
return avg(middle)
user_record = ('Dave', 'dave@example.com','773-555-12112', '847-555-1212')
name, email, *ph... |
3735d12801c725c55bfbb9381333b450353c341b | elebonel/testrepo | /names.py | 146 | 3.96875 | 4 | names = ['Ele', 'Edo', 'Gianni', 'Morandi', 'Bruno']
awesome = [name + ' is awesome ' for name in names]
for phrase in awesome:
print(phrase)
|
a95e1c032b9c566359594cb8d8cefd1d8652b623 | elebonel/testrepo | /Lang.py | 393 | 4.1875 | 4 | #write a function that takes two arguments, name of country and a major language spoken there
#call it three times, using a mix of positional and keyword arguments
def languages(country, language):
print("country: %s, language: %s" %(country, language))
languages("Germany", "Germans")
languages(language = "Spanish",... |
371fb79d49b91db3ae020f063afaa68fc4a45b44 | LAPIZDIGITALSERVICES/PYTHON | /Set Combination/Set Combination.py | 1,073 | 4.125 | 4 | #!/usr/bin/env python
import itertools
# L1=['apple', 'banana', 'pear']
# L2=['car', 'truck']
# L3=['zambia', 'malawi', 'kenya']
# print [[a,b,c] for a in L1 for b in L2 for c in L3]
def user_input(value):
if isinstance(value, tuple):
return list(value)
else:
user_list = value.split(',')
... |
4d26d4000add978e533291cbc43581310fedc96e | andrei-ardelean/Programming-Tutor | /data/3/test.py | 4,083 | 3.578125 | 4 | import unittest
class Test(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
"""Funcția ta nu returnează nimic."""
def test01(self):
a, s = 0, 0
self.assertIsNot(sumaCifrelor(a), None)
def test02(self):
a, s = 1, 1
self.assertIsN... |
61197a8e8f35b2fee308a4b535efd500efd3f1aa | andrei-ardelean/Programming-Tutor | /data/2/i2.py | 209 | 3.6875 | 4 | def concat(x, y):
z = []
while x != [] and y != []:
if x[0] < y[0]:
z.append(x[0])
x = x[1:]
else:
z.append(y[0])
y = y[1:]
return z
|
b469db0db9a6feee4a74b316e219f0cefc30adce | flowkater/deep-learning-basic | /lab2/Lab-2-linear-regression.py | 1,037 | 3.578125 | 4 |
# coding: utf-8
# In[1]:
import tensorflow as tf
# In[2]:
x_data = [1, 2, 3]
y_data = [1, 2, 3]
# In[5]:
# Try to find values for W and b that compute y_data = W * x_data + b
# (We know that W should be 1 and b 0, but Tensorflow will
# figure that out for us.)
W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))... |
68ae09fc6859ab9b0ab601e255c6dddefcfd6397 | mohammad1238/gego12 | /3/2-2.py | 245 | 3.78125 | 4 | list1 = [6, 4, -5, 3.5]
list1.sort(reverse=True)
print(list1)
list2 = ["ha", "hi", 'B', '7']
list2.sort()
print(list2)
###
monarchs = [("George", 5), ("Elizabeth", 2), ("George", 6), ("Elizabeth", 1)]
monarchs.sort()
print(monarchs)
|
834c312772f591a38388fa114530e7b35c86e6f6 | EfrainHSeg/semana6python | /problema(5).py | 227 | 4.03125 | 4 | temp = int (input("ingrese temperatura "))
if temp <10 :
print("el clima es frio")
elif temp<16:
print("el clima es templado")
elif temp<24:
print("el clima es calido")
else:
print("el clima es tropical")
|
8a332b4e9abd1952f85ad8b8d9479f2a76a3217b | Aghallen/kNN_Project | /my_classifier.py | 1,936 | 3.625 | 4 | import math
from statistics import mode
from dataclasses import dataclass
@dataclass
class TrainingData:
features: list # Features of a training sample
label: str # Label of a training sample
distance: float # Distance between a test sample and this trainings sample
@dataclass
class Pre... |
d193f850902ff4a8699415e22ee2472b2bc5359c | saidali77/day3 | /task4.py | 292 | 3.546875 | 4 | # -*- coding: utf-8 -*-
guests = ['Saidali', 'Abdulla', 'Imran']
a = guests.pop()
print(a)
guests.insert(2, 'Aibek')
print('Я приглашаю на обед ' + guests[0])
print('Я приглашаю на обед ' + guests[1])
print('Я приглашаю на обед ' + guests[2]) |
e0cca9c6a9ad1a54190d32ef4f52bd631a223ef3 | zlbingo/algorithms-python-3.7 | /bubblesort.py | 1,207 | 3.921875 | 4 | # -*- coding:utf-8 -*-
"""函数说明:冒泡排序(升序)
Parameters:
input_list - 待排序列表
Returns:
sorted_list - 升序排序好的列表
"""
def bubblesort(arr):
if len(arr) == 0:
return []
sorted_list = arr
for i in range(len(sorted_list)-1):
bchange = False
print('第%d次排序' % (i+1))
... |
756dc54400e81177f55cb98e9e4e7da7859d4872 | TahaKhan8899/Python_101_2021 | /variableScope/scope.py | 124 | 3.515625 | 4 | # GLOBAL variable
x = 30
def doSomething():
# this is a LOCAL variable
x = 10
print(x)
# doSomething()
print(x) |
b1a6e080807a07b9c2e6a4988c58a65e3c5d8e4c | TahaKhan8899/Python_101_2021 | /variables/arithmetic.py | 81 | 3.53125 | 4 | a = 20
b = 5
a = a * b
# this a short way of writing a = a * b
# a *= b
print(a) |
fe8e4ebe1526c3da4a44c50f0b76b8d0dcfc14dd | Valdas1975/kursas | /masyvas.py | 185 | 3.765625 | 4 | cars = ["Ford", "Volvo", "BMW", "zaz", "kraz" ]
x = cars[0]# pirmas masyvas skaitosi nulis
y = cars[1]
h = cars[2]
s = cars[3]
f = cars[4]
print(x)
print(y)
print(h)
print(s)
print(f) |
d551a7e27bbd78cf2861c9aef0582c6b6c2f0e97 | PablitoMoribe/pythontraining | /training/c17_numpy/e15-speed.py | 447 | 3.578125 | 4 | import numpy as np
# pip install numpy
import time
size = 10_000_000
lista1 = range(size)
lista2 = range(size)
array1 = np.arange(size)
array2 = np.arange(size)
# Python List
begin = time.time()
result = [(x + y) for x, y in zip(lista1, lista2)]
end = time.time()
print("Python list took:", (end - begin) * 1000)
... |
7116282b6d748b3c0df2694b7396d86c44f3866a | Alan-Menchaca-M/AlgoritmosSistemas | /ago-dic-2020/Fco. Alan Menchaca Merino/practica4/recursividad_practica4.py | 465 | 3.984375 | 4 | # reco n ocer
# r - econoce - r
# e - conoc - e
# c - ono - c
# o - n - o
def es_palindroma(palabra):
if len(palabra) < 1:
return True
else:
if palabra[0] == palabra[-1]:
return es_palindroma(palabra[1:-1])
else:
return False
palabra = input("Ingresa una oració... |
e5c07f4dc51ce8526122f30504255da192337ae9 | Alan-Menchaca-M/AlgoritmosSistemas | /ago-dic-2020/Fco. Alan Menchaca Merino/Practica3/pokemones_practica3.py | 327 | 4 | 4 | from algoritmos.insertion_sort import InsertionSort
pokemon_cplist = input("Ingresa el poder de cada pokemon (CP): ").split()
pokemon_list = [int(cp) for cp in pokemon_cplist]
InsertionSort.reverse_sort(pokemon_list)
print('Ordenados de mayor a menor: ', end="")
asd = [print(pokemon, end=", ") for pokemon in pokemon... |
fdfb5065e92feb9776beac5bf30e725f50f033cf | Zbara/ZbaraLabs | /Z_lab_4/Z_4_2.py | 441 | 3.828125 | 4 | # Задание 2 лабораторная 4
# Вариант 1
# Збаразский С.С
n = int(input("Введите количетсво: "))
result = ""
result += str(n) + " "
if n == 1:
result += "негритенок"
result += " пошел"
else:
if n >= 2 and n <= 4:
result += "негритенка"
if n >= 5 and n <= 10:
result += "негритят"
resul... |
9c03f503826dd324b4b5e40f099035d363de21b7 | Zbara/ZbaraLabs | /Z_lab_5/Z_5_3.py | 340 | 3.96875 | 4 | # Задание 3 лабораторная 5
# Вариант 1
# Збаразский С.С
import numpy as np
a = np.array([i for i in range(1, 100+1, 1)], int)
print("Массив:")
print(str(a))
a = a * a
print("Квадратный массив:")
print(str(a))
a = a.reshape((10, 10))
print("Матрица 10x10:")
print(str(a))
|
630a9b63e4e61abcb367ac67c612d0ec7128fbcd | Zbara/ZbaraLabs | /Z_lab_3/Z_3_1.py | 370 | 3.734375 | 4 | # Задание 1 лабораторная 3
# Вариант 1
# Збаразский С.С
import random
count = 0
random_list = [random.randint(-10, 50) for i in range(10)]
print(random_list)
for i in range(10):
if abs(random_list[i]) < 2:
print(random_list[i], "\n", "*")
count += 1
else:
print(random_list[i])
print("... |
3b603c4ceacc8a16b85b166d84484b1f0d9f5458 | Zbara/ZbaraLabs | /Z_lab_4/Z_4_5.py | 362 | 3.671875 | 4 | # Задание 5 лабораторная 4
# Вариант 1
# Збаразский С.С
words = list()
print("Задайте строки:")
for i in range(1, 6):
words.append(input('s%s. ' % i))
concat_str = words[0] + ' '
if words[3] != words[4]:
concat_str += words[2]
else:
concat_str += words[1]
print("Результат:", concat_str)
|
40d221e88b23f5283bee543437d80f9babd3e9db | vin1tunes/FibonacciPrime | /testEstagio/prime.py | 351 | 3.828125 | 4 | def prime_number(n):
# Verifica se um número é primo.
counter = 0
for i in range(1, n + 1):
if n % i == 0:
counter += 1
return counter == 2
def prime_sequence(n):
if isinstance(n, int) and n > 1: # Verifica se n é um inteiro e maior que um.
return [n for n in range(1,... |
97e1e40fdad69986d2c7a1bf6ec33a5c8d5e1dfa | H-Carter/Python-Chat | /relay.py | 1,372 | 3.5 | 4 | import threading
import connections
import sys, os
class Relay( threading.Thread ):
def __init__(self, socket, addr, name):
threading.Thread.__init__(self)
self.socket = socket
self.addr = addr
self.name = name
def run(self):
while True:
# Read bytes from socket
try:
msg_bytes = self.socket.... |
ac484ed12b64d55dd60260e23fb8206375244a36 | ravikr126/Data-Structures-And-Algorithms-Hacktoberfest18 | /python/ds/n_aryTree_dfs.py | 485 | 3.578125 | 4 | #bfs
from n_aryTree import *
# make tree for testing
p = Node(5)
c1 = Node(6)
c2 = Node(7)
p.add_child(c1)
p.add_child(c2)
c11 = Node(8)
c12 = Node(9)
c21 = Node(10)
c22 = Node(11)
c1.add_child(c11)
c1.add_child(c12)
c2.add_child(c21)
c2.add_child(c22)
def dfs(n):
if (len(n.children)==0):
pri... |
0a0b82d534a071fbe117f979f0693a4466ea8f56 | ravikr126/Data-Structures-And-Algorithms-Hacktoberfest18 | /python/algorithms/SlowSort.py | 603 | 4.125 | 4 | from math import floor
def slow_sort(array, i, j):
"""
a really slow sorting algorithm based on multiply and surrender
---------------------------------
array: list
list of items
i : int
index of the first item array
j: int
index of the last item in array
"""
if... |
efc3ef467df8a3c347a6882e03572525b2807238 | ravikr126/Data-Structures-And-Algorithms-Hacktoberfest18 | /python/algorithms/PerfectGcd.py | 185 | 3.5 | 4 | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
def gcd_list(numbers):
return reduce(math.gcd, numbers)
print(gcd(x, y, z, ...))
|
65e86e4e79b803ec0307ac2c6a537d04d2327685 | ravikr126/Data-Structures-And-Algorithms-Hacktoberfest18 | /python/algorithms/heapsort.py | 1,200 | 4.375 | 4 | # How does heapsort works: https://en.wikipedia.org/wiki/Heapsort
def heapsort(list_of_elements):
list_size = len(list_of_elements) - 1
least_parent = int(list_size / 2)
for i in range(least_parent, -1, -1):
move_down(list_of_elements, i, list_size)
for i in range(list_size, 0, -1):
if... |
bdc540e7e4b0a04cd66ae18ef214a6875350d52e | arrrr110/aorick | /ex43_classes.py | 6,399 | 3.828125 | 4 | from sys import exit
from random import randint
import random
import time
class Scene(object):
def enter(self):
print("Walking with a long time,get in enter().")
exit(1)
class Engine(object):
def __init__(self, scene_map):
self.scene_map = scene_map
def play(self):
curre... |
901bc773aa7f5d892b5da6cefb5704ebd2ed04ed | theJenix/class-planner | /simple_plan.py | 4,696 | 3.625 | 4 | #!/usr/bin/env python
class ConstraintSatisfactionProblem(object):
def __init__(self, variables, domainFn):
"""
Construct a constraint satisfaction problem with an array of
variables and a domain function. The domain function allows
for arbitrary complex "preselection" ... |
eed80483619ff195f9a3102eeb3e990d8d3968eb | nikosgalanis/KakuroSolver | /src/kakuro.py | 7,927 | 3.5 | 4 | import csp
import sys
from functions import *
import time
class kakuro(csp.CSP):
def __init__(self, data_list):
#create a list of lists of tuples, to keep our data
self.grid = []
#find out how many rows and how many columns we have in the file
self.n_rows = int(data_list[0])
... |
f7d7186e62a0516336aea5fffdd2fc19763757f2 | bgmogyorosi/python | /add.py | 344 | 3.96875 | 4 | def add(a, b):
return a + b
def get_number():
while True:
try:
a = int(input('Please give an integer: '))
return a
except ValueError:
print('Invalid input!')
continue
def main():
a = get_number()
b = get_number()
result = add(a, b)
... |
badd30bee79b05b47eb61eeba1c22d99bd5fd455 | kostyantynHrytsyuk/fake-detection | /model.py | 2,108 | 3.5 | 4 | import numpy as np
import matplotlib.pyplot as plt
import keras.layers
import keras.optimizers
import keras.models
class DFModel:
def __init__():
self.model = self._configure_model()
def _configure_model(self):
# Input layer
# Height, Width, # of channels
X = Input(shape = (720... |
e7a294a58439492f3b15a1cd7c6786a523e83cd8 | arleyvelascoo/nand2tetris | /project11/JackTokenizer.py | 5,172 | 3.5625 | 4 | from JackToken import JackToken
class JackTokenizer():
COMMENT_OPERATORS = ["/", "*"]
STRING_CONST_DELIMITER = '"'
"""
pasa por un archivo de entrada .jack y produce una secuencia de tokens
ignora todos los espacios en blanco y comentarios
"""
def __init__(self, input_file):
self... |
deb6ad9af57d1eda9bf6ec98c690a986a2040548 | alextodireanu/data_structures_exercises | /linked_list.py | 2,112 | 4.65625 | 5 | # implementation of simple linked list
class Node:
"""Class representing a node"""
def __init__(self, data):
"""Node initialization"""
self.data = data
self.next = None # pointing to None at init
class LinkedList:
"""Class used to represent a linked list structure"""
def __in... |
5cfde59c6ad3d1375128286a80408d9a9d324e72 | kschlough/interview-prep | /branch_sums.py | 814 | 3.984375 | 4 | class BinaryTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def branchSums(root):
return calcSum(root, sum = 0)
def calcSum(root, sum, return_val = []):
if root == None:
return_val.append(sum)
return return_val
else:
sum += root.value
r... |
1f866efe7c75ecf1ba8ef72500e306c464d1e5ca | kschlough/interview-prep | /implement_list.py | 2,099 | 4.4375 | 4 | # implement list Brian Faure YT tutorial
array = [1, 2, 3]
# iterate over the elements in the list
for a in array:
print(a)
# if you don't want any value stored when iterating, like just # of times or length:
count = 0
for _ in array:
count += 1
print(count)
# another way to iterate is using indices
for i i... |
7f29f679675f4165544f28193a5802065d96803e | kschlough/interview-prep | /traverse_adjacency_matrix.py | 1,743 | 3.859375 | 4 | # find path between nodes in adjacency matrix - path of 1s
# keep visiting nodes connected to current one being inspected - track back once no new nodes to visit
# use stack to keep track of path traveled to current node
# complexity: lookup can be done in O(1) constant time, but space taken up is O(v^2) where v = ver... |
b10b34dc965f60a982b8f4fd1f5bcaeda13f9286 | kschlough/interview-prep | /count_valleys.py | 2,712 | 4.65625 | 5 | # hackerrank problem
# An avid hiker keeps meticulous records of their hikes. During the last hike that took exactly steps, for every step it was noted if it was an uphill, , or a downhill, step. Hikes always start and end at sea level, and each step up or down represents a unit change in altitude. We define the fo... |
610709b2d2f7826cb80c0275f1e22b6d7104d35c | kschlough/interview-prep | /linked_lists.py | 2,011 | 4.40625 | 4 | # bare minimum linked list: only has a class for node
class ListNode:
def __init__(self, value, next=None):
self.value = value
self.next = next
# linked list class keeps track of head, then ListNode tells us where to find the next node
class LinkedList:
def __init__(self, head_node):
se... |
25fbbab322e8b6b58b8105872473b39dd24d1ba5 | ashish-2409/Machine-Learning- | /feature_selection.py | 1,768 | 3.625 | 4 | # -*- coding: utf-8 -*-
# Commented out IPython magic to ensure Python compatibility.
# %cd /content/drive/MyDrive
import pandas as pd
data=pd.read_csv('diabetes.csv')
X=data.iloc[:,[0,1,2,3,4,5,6,7]]
Y=data.iloc[:,8]
from sklearn.feature_selection import mutual_info_classif
imp=mutual_info_classif(X,Y)
imp #import... |
79c37cf294d76da81843edf3a0abcf61f5bf97a2 | lin08230823/Data-Structures-and-Algorithms-in-Python | /section2.py | 2,465 | 3.5625 | 4 | import datetime
class PersonTypeError(TypeError):
pass
class PersonValueError(ValueError):
pass
#公共人员类的实现
class Person(object):
"""docstring for Person"""
_num = 0
def __init__(self, name, sex, birthday, ident):
if not (isinstance(name, str) and
sex in ('男', '女')):
raise PersonValueError(name, sex)
... |
ea84d4f1208f089a0a4da51feb984909cb34fc34 | lincoken/euler-method | /Dr.Hart_project2.py | 2,105 | 3.59375 | 4 | import matplotlib.pyplot as plt
import numpy as np
# import time
# fixed radio active decay problem, approximate the function given relation between derivative and function
tau = float(input("Enter a value for Tau (time constant for decay):\n"))
N_0 = float(input("Enter the initial number of uranium nuclei present wh... |
88998b0f572d4f1aa7c1e2983c2828652e3c4972 | JamesWeatherbee/IS211_Assignment7 | /Assignment7.py | 3,971 | 3.90625 | 4 | import random
class Player:
def __init__(self, name, score, turn, current_roll):
self.name = name
self.score = score
self.turn = turn
self.current_roll = current_roll
class Die:
random.seed(0)
def __init__(self, num_sides=6):
self.num_sides = num_sides
se... |
6c36c41d226849c39623dc0051c0103dfd8aa983 | yoo-s/LearnPython | /ex11.py | 311 | 3.671875 | 4 | print "What\'s your favorite fruit?",
fruit = raw_input()
print "What\'s your favorite ice cream flavor?",
flavor = raw_input()
print "What sport do you like?",
sport = raw_input()
print "So, you love %ss, %s ice cream and do %s." % (fruit, flavor, sport)
if flavor == "strawberry":
print "Really?? So do I!" |
ed51b5624eb771acb73ec976ad53c59a3e4a0706 | mariusmhm/ElectionSystem | /src/server/db/StateMapper.py | 3,209 | 3.53125 | 4 | import mysql.connector
from server.State import State
from server.db.Mapper import Mapper
class StateMapper (Mapper):
"""This is a mapper-class, which represents state objects into
a relational database. For this reason you can find some methods,
which help to find, insert, modify, and delete objects. The... |
46f057f2fa6ff30ccf0d3b77dc11160bbe6a22bc | ADSA-UIUC/VisualizingEducationalDisparityFA18 | /main.py | 1,934 | 3.765625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def format_data(data,year,threshold):
'''
This function returns a dataset with countries as rows, and
indicators (e.g population, attendance rate, etc) as columns.
The year parameter specifies which year that information comes from.
(I notic... |
d70c6812bd612eccd49e75910223c40d080c713c | drawAgirl/PAT | /Python3/1123.py | 5,232 | 3.734375 | 4 | #模版是网上找的 就直接改了下抄了
class Node:
def __init__(self, num):
self.key = num
self.right = None
self.left = None
self.p = None
self.height = 0
self.factor = 0
self._find_height()
def _find_height(self):
#print("_update: {} ({}, {})".format(self.key, self.... |
d1fbd57b738c37f058bcf7a39b97858e8ae4268e | liljdd/pythonProjectsTest1 | /primaryDateType.py | 4,326 | 3.59375 | 4 | # Number数据类型
print('# Number数据类型')
a,b,c,d=2,2.2,True,4+3j
print(type(a),type(b),type(c),type(d))
print(isinstance(a,int),isinstance(b,float),isinstance(c,bool),isinstance(d,complex))
## bool类型可以和数字相加
print(a+c)
del a,b,c,d
print()
# String 数据类型
print('#String 数据类型')
a='abcde'
print('ab' in a) # True
print('ad' in ... |
48af169634b95b704cfc8fa3d7dd6fb3e69f44b5 | talathussain/assignment | /assignment_2/parameter.py | 240 | 3.78125 | 4 | class ClassA:
num = 10
def __init__(self, num):
self.n = 12
print ("Class Variable",ClassA.num)
ClassA.num= 15
print ("Class Variable Changed Here",ClassA.num)
obj = ClassA(5)
print ("This Is an Instance Variable",obj.n)
|
a0ef6e625fef79abf2d65f67d30edc93412bed4f | hallamlab/data_wrangling | /data_wrangling_oct30_2014/examples/python/basic_script.py | 333 | 3.75 | 4 | #!/usr/bin/python
# import python packages
import sys
# pull filename from the command-line arguments
filename = sys.argv[1]
# open the file
fh = open(filename, "r")
# read lines from file
lines = fh.readlines()
# iterate through each line and print out content
for line in lines:
print line
# close the file
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.