blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0b9176f78627950116865fb300d1afd9b4cce96d
tommymag/CodeGuild
/python/case_con.py
709
4.46875
4
# # Lab: Case Conversion # Write a program that prompts the user for a word. # Print out either `snake_case` or `CamelCase` depending case convention it is!. # ##### Instructions # Use substring membership with the `in` operator # 1. [PEP8](https://www.python.org/dev/peps/pep-0008/) # 1. [Stack Overflow](http://st...
b21b15a431e19cf02d91426257c67a5e2b01710c
seanybaggins/MatrixAlgebra
/book/sources/15-Diagonalization_in-class-assignment.py
14,234
3.796875
4
# --- # jupyter: # jupytext: # text_representation: # extension: .py # format_name: light # format_version: '1.5' # jupytext_version: 1.10.3 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # # # # # 15 In-Class Assignment: Diagonalization # ...
b8f16b221e2b4ae36c45ebf244e44fd11f0becdd
bgoldstone/Computer_Science_I
/Labs/9_movingCircle.py
4,975
3.90625
4
# 9_movingCircle.py - for CSI-102 Lab 9: More practice with Pygame # Adds colors and user interaction # # Name: Ben Goldstone # Date: 10/20/2020 #INITIALIZE: import pygame pygame.init() # Constants WIDTH = 800 HEIGHT = 600 BOX_SIZE = 100 HALF_BOX = BOX_SIZE // 2 SPEED = 5 # Color Constants RED = (255, 0, 0) GREEN =...
6ea8200cd3d4cbb6003578e2dc0ffa8504e03a86
Jollyhrothgar/insight_interview_prep_2016a
/sql/data_sets/autos_regression/create_database.py
5,908
3.59375
4
#!/usr/bin/env python # This allows us to create a database engine, which is the layer # which talks to the database from sqlalchemy import create_engine # These tools let us check if a database exists, given an engine, or # create a database if no database exists, given an engine from sqlalchemy_utils import databa...
6f2aa5b377fda5306fb6105d6c1430a615fd243c
NetSecLife/Random-Code
/abc-news-scraper.py
1,333
3.71875
4
from bs4 import BeautifulSoup import urllib.request def scrape_headlines(soup): #Constrains to the headline section headlines = soup.find("ol") #For loop through headlines for heading in headlines: #Get rid of whitespace, then collect the data if heading == "\n": continue ...
ddc6a5e89b4af2f7557b18037549cdf56b4bf979
reashiny/python.
/Python_hunter/Employees.py
1,823
3.921875
4
import time import sys #f name #l name #age #emp id #mail id em_list = [] class employee: def __init__(self,f_name,l_name,age,Emp_id): self.Attendance = True self.First_name = f_name self.Last_name = l_name self.Name = self.First_name + self.Last_name self.Age = age ...
7dfdde783072cdfc64ebb9b5bfe13549e43e0dc7
esracelik/openstack-review-dashboard
/reviewSearcher/nonalnumops/convertHex.py
879
3.578125
4
def convertNonAlNumtoHex(line): cline = "" if not line.isalnum(): i = 0 while i < len(line): c = line[i] cp = line[i-1] if i > 0 else None if not c.isalnum(): if c == ' ': # SPACE cline += "+" elif c.encode...
616f9c7c30e32b71a963efaf84552fd835f707f1
nikhilbansal064/pyvengers
/word_counter.py
1,620
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 3 22:13:45 2018 @author: Nikhil Bansal Here we are going to create a word counter. * steps - 1. We are gointn to screap a web page to get words. """ import requests from bs4 import BeautifulSoup import re import operator # This method is going to give...
f90400793c2c502a8cd21c2dc90a3cce8c8d3dd3
Frankiee/leetcode
/dp/2d/562_longest_line_of_consecutive_one_in_matrix.py
1,676
3.6875
4
# [2D-DP] # https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix/ # 562. Longest Line of Consecutive One in Matrix # History: # Google # 1. # Mar 26, 2020 # Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be # horizontal, vertical, diagonal or anti-diagon...
03b1881a6b2d6b3cc9bf0ef654d1895ef4fee0a5
FlackoJodye1/thvisa
/py_learning/demo_oo_with_context_interhited.py
1,971
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 13 18:34:45 2019 @author: thomas why context managers? see https://jeffknupp.com/blog/2016/03/07/python-with-context-managers/ TL;DR: "Essentially, any object that needs to have close called on it after use is (or should be) a context mana...
c24ffd63f9670686ee8441f960f0761d8b329d9d
MartinaLima/Python
/exercicios_python_brasil/estrutura_repeticao/40_acidentes_transito.py
1,824
3.828125
4
print('\033[1m * ACIDENTES DE TRÂNSITO - 1999 *\033[m') tot_cidades = 0 soma_acidentes = 0 cidades_peq = 0 soma_veiculos = 0 for tot_cidades in range(5): tot_cidades += 1 codigo = int(input(f'Código cidade {tot_cidades}: ')) while codigo <= 0: print('CÓDIGO INVÁLIDO!!!') codigo = i...
038b8f3cfa851a2b081b3573be0a345acdab5f49
padalor/ReadAndWrite
/debugReadWriteDrillsV1.py
2,066
4.15625
4
''' The following functions have problems that keep them from completing the task that they have to do. All the problems are either Logical or Syntactical errors with READ/WRITE. Focus on the reading and writing and find the problems with the READ/WRITE. The number of errors are as follows: readSingle: 3 rea...
65cb2cd10efe8959462e1e86361584d060147c3d
bhupendrabhoir/PYTHON-3
/12. GUI/CALCULATOR.py
997
3.6875
4
from tkinter import * def add(): num1=int(e1.get()) num2=int(e2.get()) result=num1+num2 l3["text"]=result def sub(): num1=int(e1.get()) num2=int(e2.get()) result=num1-num2 l3["text"]=result def mul(): num1=int(e1.get()) num2=int(e2.get()) result=num1*num2 ...
e79fadf2e7e56e7bacefcdf582aaad4e019a495e
liulxin/python3-demos
/micr/14.func.py
334
4.125
4
first_name = input('enter your first name: ') last_name = input('enter your last name: ') def initial_name(name, force_uppercase = True): if force_uppercase: initial = name[0:1].upper() else: initial = name[0:1] return initial print(f'Your initials are: {initial_name(first_name)} {initial_name...
4a6c0462f88a7e6bc558b269bca1950babbcabf7
Harsh2705/bankaccount
/bank1.py
780
4
4
def account(): print("Details of user") print('Name:','Harsh Rana') print('Account_Number:','300084176114566') print('Aaadhar_Number:','78480884777') print('Phone_Number:','9027097675') print('Category:','General') def total_amount(): balance=17000 print("The total balance of your accou...
b15c3f65c3226546ccfa75c7a518d00a0a04e2ba
jameswmccarty/CryptoToyUtils
/HMAC_Timing_Attack_Client.py
1,977
3.53125
4
#!/usr/bin/python import urllib import time """ There is a server with a timing leak. We want to submit a valid input (filename, signature), but we don't know the signature. i.e. http://localhost:8080/?filename=foo&signature=46b4ec586117154dacd49d664e5d63fdc88efb51 Goal: Determine a valid signature for a given fil...
3e0412bffb30e428b954a6598f0af58af461f7af
Maltimore/Reinforcement_Learning_BCCN
/testfuncs.py
2,696
3.640625
4
import matplotlib.pyplot as plt import numpy as np def is_between(a, b, c): a[0], a[1] = round(a[0], 3), round(a[1], 3) b[0], b[1] = round(b[0], 3), round(b[1], 3) c[0], c[1] = round(c[0], 3), round(c[1], 3) print("the three dots given to is_between are: ") print(a) print(b) print(c) ...
0be210aba3242187e9406502697423d95edb1051
epmskorenkyi/python-training
/lesson04/task06.py
472
3.53125
4
""" Task06 Module ============= Updates a current date and time in a file's first line (stored in the first 50 characters). A file shall be specified as a first argument. Other file content than first 50 characters shall not be modified. """ import time, sys from time import strftime if len(sys.argv) > 1: file ...
1b16df03bfb5d515c31ae62ddfa3e7184190e3a3
lminervino18/HangmanGame
/Hangman Game/player.py
1,612
3.609375
4
from constants import LIVES, WINNING_POINTS class Player: def __init__(self, name): self.name = name self.rounds_won = 0 self.letters_tried = 0 self.lives = LIVES self.actual_word = [] self.points = 0 def get_points(self): #Return the actual po...
36bf0194b5201de3fe38630cef4d2f3f860e8c59
prueba-entreeinement/hola-mundo
/sqlZAAU.py
1,512
3.59375
4
import sqlite3 as sq #trigger clausula when. #condiciona la aparicion del trigger, sin necesidad del uso de select case. conexion = sq.connect("bd.db") cur = conexion.cursor() cur.executescript(""" drop table if exists usuarios; drop table if exists clavesanteriores; create table usuarios( nombre text primary key,...
72c6bc9ad791e405d19e2e04d356055e5313051d
ccnelson/Python
/tkinter/clock_tick.py
647
3.578125
4
## this calls itself recursivly ## that is BAD import tkinter as tk import time root = tk.Tk() time1 = '' clock = tk.Label(root, font=('times', 20, 'bold'), bg='green') clock.pack(fill=tk.BOTH, expand=1) def tick(): global time1 # get the current local time from the PC time2 = time.strftime('%H...
20edf597c6271bc125ac27ef5d0d947f3472a5d5
noorulameenkm/DataStructuresAlgorithms
/LeetCode/30-day-challenge/June/june 8th - june 14th/isSubSequence.py
421
3.609375
4
class Solution: def isSubsequence(self, s, t): if len(s) > len(t): return False if len(s) == 0: return True if s[0] == t[0]: return self.isSubsequence(s[1:], t[1:]) return self.isSubsequence(s, t[1:]) print(f'Is subsequence {Solution().isSubseq...
42dee6c19e990ee77a6622c17fc73d647983fadc
alexei89/Python3
/ex12_remove_selected elemetns_list.py
388
3.921875
4
#23 feb 2017 #Write a Python program to print a specified list after removing the # 0th, 2nd, 4th and 5th elements. lista = ['red', 'green', 'white', 'black', 'pink', 'yellow'] def remove_elements(mylist): editedlist = [] for i in range(0,len(mylist)-1): if i not in (0,4,5): editedlist.app...
9a2c67938efba1d4ab0c353577d4bc15b91bcc5f
niphadkarneha/SummerCamp
/Python Scripts/Intro to prob.py
1,386
3.875
4
# import numpy as np total_tosses = 30 num_heads = 24 prob_head = 0.5 #0 is tail. 1 is heads. Generate one experiment experiment = np.random.randint(0,2,total_tosses) print ("Data of the Experiment:", experiment) #Find the number of heads print ("Heads in the Experiment:", experiment[experiment==1]) ...
0bd9c0926157bd1de0eeed5f15a31883ddf69f90
jmetzz/algorithms-challenges-lab-python
/src/challenges/problems/dynamic_prog/checkerboard.py
3,899
4.15625
4
"""Consider a checkerboard with n × n squares and a cost function c(i, j) which returns a cost associated with square (i,j) (i being the row, j being the column). Let us say there was a checker that could start at any square on the first rank (i.e., row) and you wanted to know the shortest path (the sum of the minimum ...
01ea26b9e1f850687fb06a01bc661ed19f9d2a55
juandp333/mi_primer_programa
/Calculadora.py
903
4.25
4
# Calculadora debe preguntar al usuario que operacion deseas realizar y dos numeros a calcular primer_numero = int(input("Hola, ¿Cual es el primer numero a calcular?")) print("ok sera {}".format(primer_numero)) operacion_realizar = input("¿Que operacion deseas ralizar? (Sumar, Restar, Multiplicacion o Dividir)").uppe...
c911884fdb9f42cc9ce379c01b4999a62c5b8691
Sean-McGinty/ECS_32A
/HW2/divide.py
456
4.375
4
#divide.py #ECS32A # #Integer Division Calculator Dividend=int(input("Enter a number:")) #User inputs Dividend and Saves as a Variable Divisor=int(input("Enter a number to divide that by:")) #User inputs Divisor and Saves as a Variable quotient=Dividend//Divisor #Performs Floored Division of Dividend/Divisor remainder=...
d0be52bef7506093b0d0d08b7dc9837a8a1d6793
yadubhushanreddy/Python-Programs
/second_largest_number.py
572
4.15625
4
no_of_elements = int(input("Enter no of elements : ")) input_list = [] max_number, second_max_number = 0, 0 for number in range(no_of_elements): input_list.append(int(input("Enter any number : "))) for element in range(0, len(input_list)): #12 3 24 32 25 if max_number < input_list[element]: second_max...
e13baf963e3501d402f7280514b8a4b7e8203224
xueyc1f/kube
/utils/utils.py
737
3.546875
4
def check_key(key, data, default=None): """ 验证data.keys()是否包含key,如果是则返回data[key],否则返回None or default :param key: string or int ... :param data: dict or list ... :param default: mixed :return: mixed """ if isinstance(data, dict): if key in data.keys(): return data[key...
d940d4a29914cd32c891e187186aa9f12aa8caac
BishwasWagle/PythonAdvanced
/RegEX/regexp.py
418
3.765625
4
import re import argparse def Main(): line = "Regular expressions are awesome!!" matchResult = re.match('are', line , re.R|re.I) if matchResult: print("Match found:" +matchresult.group()) else: print("No match found") searchResult = re.search('are', line , re.R|re.I) if searchResult: print("Search found...
01cb3ae6e2604579121af2ec3852917a51fc9339
jskim1124kr/Gradient_Descents
/GradientDescent.py
1,009
3.59375
4
from numpy import * from matplotlib import pyplot as plt data = genfromtxt('data.csv',delimiter=',') m = len(data) def load_data(data): x_data = [] y_data = [] for i in range(m): x = data[i,0] y = data[i,1] x_data.append(x) y_data.append(y) return x_data, y_data de...
616a02a9bdb9df8642ab057e6e2865a9926f2dd1
pandyakavi/Algorithms
/MergeSort.py
484
3.875
4
def MergeSort(arr): if len(arr) > 1: mid = len(arr)//2 left = arr[:mid] right = arr[mid:] MergeSort(left) MergeSort(right) i=0;j=0;k=0 while i < len(left) and j < len(right): if left[i] < right[j]: arr[k] = left[i] i+=1 else: arr[k] = right[j] j+=1 k+=1 while i < len(left)...
a2faef46e4eb487b70ad4bb5e1c7ead5331eecc6
Nebual/rimsky
/combat.py
2,671
4.0625
4
import random, actor def populate(encounterList): """ Gets an encounter from a list of possible encounters and creates up to 3 monster objects. """ selection = encounterList[random.randint(0, len(encounterList)-1)] monsters = [] for name in selection: monsters.append(actor.Monster(name)) #append a monster ob...
b44ee0a7e0992cfa971ab27f0c9f50170ea49df1
signalwolf/Leetcode_by_type
/MS Leetcode喜提/37. Sudoku Solver.py
1,286
3.546875
4
class Solution(object): def validation(self, board, x, y): base = board[x][y] for i in xrange(9): if i == x: continue if board[i][y] == base: return False for j in xrange(9): if j == y: continue if board[x][j] == base: ...
2fc5c7dab35b1be37b178cb23afa27a93827f2d6
VladimirRudenko/-Python
/1.py
525
3.890625
4
s = 25 print("this is integer ->" ,s) lst = [7, "f", "ds", "ds"] print ("this is list ->" + str(lst) ) print ("this is String -> string") r1 = {'model': '4451', 'ios': '15.4'} print("this is dictinary-> " + str(r1)) set = (11, 22, 44, 33) print("this is set -> " + str(set)) tuple1 = ("bla", "bla2", "bla3") print (...
d7afc2217de549b36dd4a1e721fcd686ce43fe5b
CallumShepherd/ICTPRG-Python
/W9/Resources/files4.py
837
3.65625
4
with open ( 'data.txt', 'w') as f1: while True: product_id=input('Product ID: ') if product_id == '': break print(product_id) name = input ('Item Name: ') print(name) price = input('Price: ') print(f'${price.strip("$")}') f1.write(product_i...
8829a2ab67570fd830e8cf75127d80dde81f7a05
glouno/Courseworks
/PRP Programming Practice/PRPweek2.py
308
3.921875
4
stack=[] stack.append('apple') stack.extend(['pear', 'banana', 'tomato']) print (stack) print(stack.pop(1)) letters = ['a', 'b', 'c', 'd'] new_list_1 = letters new_list_2 = letters[:] letters[2] = 'e' print(new_list_1) print(new_list_2) x = [1, 2] y = [1, 2] print(x == y) print(x is y) x=y print(x is y)
9d3c7959a1a2fc133242046bc23499deaf2de513
Payne3/Voting-Financial-Analysis
/PyPoll/Resources/main.py
2,173
3.75
4
import os # Module for reading CSV files import csv csvpath = os.path.join('..', 'Resources', 'election_data.csv') total_votes = 0 kahn_votes =[] correy_votes = [] otooley_votes = [] Li_votes = [] K_percentage = 0 O_percentage = 0 L_percentage = 0 C_percentage = 0 with open(csvpath) as csvfile: # CSV reader spe...
6a55530de5c6f8c8716ca503e83b53f04eccef89
M10309105/pythonProject
/lesson/7/7.1.py
1,616
4.21875
4
#/usr/bin/python3 # #output print("=" * 100) print("7.1 output") print("=" * 100) year = 2021 month = '07' v = 3.1415926 #(formatted string literals) #https://docs.python.org/zh-tw/3/tutorial/inputoutput.html#tut-f-strings print(f'This is format output {year:-10d}, {month:10}, v={v:.3f}') #'!a' 會套用 ascii(),'!s' 會套用 st...
c695246f9306955bc1e25523aff02b27fe4dffd0
nirajandata/iwbootcamp_assignments
/asg_22.py
91
3.78125
4
x=[1,2,3,12,3,4,1] dup=set() for i in x: if i not in dup: dup.add(i) print(dup)
24da18d6078b6ba76a9513062a019bd8d4648b22
thippeswamydm/python
/3 - Types/3.3 - InbuiltTypes-DictionarySetArray/11-dictions-methods-setdefault-usage.py
364
4.21875
4
# Describes the assigning, working, and method usages of dictionaries # String variable message = 'It was a bright cold day in April, and the clocks were striking thirteen.' # Creating a empty diction obj = {} # Adding default keys and values for keyitem in message: obj.setdefault(keyitem, 0) obj[keyitem] = ...
020e2a249ffdc957adbdb253e198741d8fc1d7dc
grglzrv/python_exercises_and_exams
/exam_july/05. Fan Shop.py
614
3.75
4
budget = int(input()) n = int(input()) total_amount = 0 for item in range(0, n): input_item = input() if input_item == 'hoodie': total_amount += 30 elif input_item == 'keychain': total_amount += 4 elif input_item == 'T-shirt': total_amount += 20 elif input_item...
deb9cf8794fb1560ce400ce18f839fcceb7b0954
kitarvind01/PythonProgram
/FileHandlingProject/AddOfMultipleNumber.py
177
3.84375
4
import sys def sum(a,*b): c=a for i in b: c=c+b[i] print(c) a=int(input("Enter the first number")) b= input("ENter the second number") sum(a,tuple(list(b)))
abe0dc856b388305674987238eb0bca0cd859aa8
ActonMartin/leetcode
/414.第三大的数.py
2,224
3.6875
4
# # @lc app=leetcode.cn id=414 lang=python3 # # [414] 第三大的数 # # https://leetcode-cn.com/problems/third-maximum-number/description/ # # algorithms # Easy (35.28%) # Likes: 155 # Dislikes: 0 # Total Accepted: 32.6K # Total Submissions: 92.2K # Testcase Example: '[3,2,1]' # # 给定一个非空数组,返回此数组中第三大的数。如果不存在,则返回数组中最大的数。要...
eec2e6f547891512718f7c5e26d325672b6f6384
mabbott2011/PythonCrash
/stringFunctions.py
875
4.375
4
# String Functions myStr='Hello World' print(myStr.capitalize()) #Swap case print(myStr.swapcase()) # Length print(len(myStr)) # Replace print(myStr.replace('World', 'Everyone')) # Number of occurances within String, case sensative sub = 'H' print(myStr.count(sub)) # l -> 3 # h -> 0 # H -> 1 # Starts with or end...
edf86e5dad03cc284d4aa803f170b7c7168282db
cbragg3136/python-challenge
/PyBank/main.py
4,832
4.03125
4
# import modules for os and for reading csv file import os # module for reading csv file and path for reading csv file & writing text file import csv budget_data_csv = os.path.join('Resources', 'budget_data.csv') budget_data_text = os.path.join('analysis', 'results.txt') # defined a function to read the file into a ...
107e05b90a0664f3eabc5d84a6918745f62f01e3
wjj800712/python-11
/chengxiangzheng/week5/Q1.py
145
3.5625
4
#打乱一个排好序的列表alist,random模块中的shuffle(洗牌函数) import random alist=[1,2,3,4,5] random.shuffle(alist) print(alist)
19ad83907513a8ce36fb6f3b42c80bce6febc3ca
kyuchung-max/pyworks
/ch07/inherit_class/upcalculator.py
320
3.8125
4
from ch07.myclass.calculator import Calculator class MoreCalculator(Calculator): def pow(self): return self.x ** self.y def div(self): if self.y==0: return 0 else: return self.x/self.y cal=MoreCalculator(3,0) print(cal.add()) print(cal.div()) print( cal.pow())
ec87ac378d8a4b782b63dd4b1096f3c59c281d9e
quanhuynh/DailyProgrammer
/easy/172-pbm-image/172-pbm-image.py
1,419
4
4
""" [7/21/2014] Challenge #172 [Easy] ■■□□□▦■□ https://www.reddit.com/r/dailyprogrammer/comments/2ba3g3/7212014_challenge_172_easy/ Given a string, output a pbm format that displays the string through 0s and 1s (or any characters desired) *Only supports all-caps text. Lowercase text can be added, but I'm lazy. """ imp...
0236e9f3fd9b2a80f4ebf1f189e8135fc0035d5d
JShad30/practice-python-scripts
/juicy.py
1,232
4.15625
4
fruits = ["an apple", "a banana", "a strawberry", "broccoli", "cabbage", "grapes", "pomegranite", "an avocado", "pineapple", "melon", "grapefruit", "watermelon", "Dragon Fruit", "lettuce", "a pepper", "a kiwi fruit", "some summer fruits", "mango", "an orange", "a tangerine", "a tomato"] def fruit_and_veg(): score ...
fc0717e4d8c71d8a3163cf37709f205a76309cc4
gmdmgithub/python_patterns
/json_csv.py
3,068
3.515625
4
import json from urllib.request import urlopen import sys def main_first(): #prints a list of arguments - may be used later on argument_list = sys.argv for arg in argument_list: print(arg) with urlopen("https://free.currencyconverterapi.com/api/v6/currencies") as response: source = re...
1b70051b09fa932abc8a02071366e48879901488
fitifit/pythonintask
/src/task_2_0.py
667
3.5
4
# Задача 2. Вариант 0. # Напишите программу, которая будет выводить на экран наиболее понравившееся вам высказывание, автором которого является Ф.М.Достоевский. Не забудьте о том, что автор должен быть упомянут на отдельной строке. # Krasnikov A. S. # 01.02.2016 print("Жизнь, везде жизнь, жизнь в нас самих, а н...
153c421222777aa5dce27b0d9e2242dd78616bdd
riccardosirchia/unit_testing_python
/test_name_function.py
543
3.625
4
import unittest from name_functions import get_formated_name class NameTestClass (unittest.TestCase): '''tests for name_function.py''' def test_first_last_name(self): '''test for just a firs and last name ''' formatted_name = get_formated_name('jannis', 'botha') self.assertEqual(formatted_name, 'Jannis Botha'...
a97fc3788ee7bdf573236ae12ba54089bcafb188
borisbarath/registermachinecoding
/num_coding.py
1,881
3.5
4
def enc_pair(x, y): # Encode <<x, y>> return (2 ** x * (2 * y + 1)) def dec_pair(code): # Decode <<x, y>> x = 0 y = 0 if code % 2 == 1: x = 1 else: while code % 2 == 0: code = code // 2 x += 1 y = (code - 1) / 2 return(x, y) def enc_pair_alt(x, y): # Encode <x, y> return (2 ** x * (2 * y + 1) - 1)...
6c366d78ab924cb8d62771cba554fabf70a892cf
sunsgneckq/CS-88
/Lab/lab03/lab03.py
6,464
4.34375
4
## Data Abstraction ## def make_city(name, lat, lon): """ >>> city = make_city('Berkeley', 0, 1) >>> get_name(city) 'Berkeley' >>> get_lat(city) 0 >>> get_lon(city) 1 """ return [name, lat, lon] def get_name(city): """ >>> city = make_city('Berkeley', 0, 1) >>> get_...
f1b63d9bb0032381b9ee5409be7f80efa9d021e8
metacall/core
/source/scripts/python/ducktype/source/ducktype.py
947
3.890625
4
#!/usr/bin/env python3 def multiply(left, right): result = left * right print(left, ' * ', right, ' = ', result) return result def divide(left, right): if right != 0.0: result = left / right print(left, ' / ', right, ' = ', result) else: print('Invalid right operand: ', right) return result def sum(left,...
e494631d46fec3683464912a26d5aed0108598fe
oumaymabg/holbertonschool-higher_level_programming
/0x03-python-data_structures/6-print_matrix_integer.py
325
4.15625
4
#!/usr/bin/python3 def print_matrix_integer(matrix=[[]]): for n in range(len(matrix)): for i in range(len(matrix[n])): if i < len(matrix[n]) - 1: print("{:d}".format(matrix[n][i]), end=" ") else: print("{:d}".format(matrix[n][i]), end="") print...
d3fc1b46afd57391a08a295202ac325fe460da3f
alexandradev/brain-workout
/palindrometest.py
208
3.921875
4
word = input("Write a word:") a = len(word) error = 0 for i in range(a//2): if word[i] != word[-1 - i]: error = 1 break if error == 1: print("It's not a palindrome") else: print("It's a palindrome") print()
2adc4c2dfae910028616fcb235f7a9a77cd7e6c1
maha2620/testrepo
/pyif.py
287
3.75
4
x=10 if x % 2 == 0: print(x, " is even number") else: print(x, " is odd number") print(type(x)) print(id(x)) print(x) a=1000 b=34.56 c=3+4j d=True e='python' print(type(a)) print(a) print(type(b)) print(b) print(type(c)) print(c) print(type(d)) print(d) print(type(e)) print(e)
1840eee571b09a5da4b169ae828720141662602e
sumaneshm/Code
/Python/Pluralsight/PythonFundamentals/Previous/Collections/ListCollection.py
1,575
4.15625
4
# list can be created by calling split as well theList = "This is a very cool feature of Python".split() print(theList) # or initialized using square brackets theList = [0, 1, 2, 3, 4, 5] print(theList) # two ways to access elements by index # positive => lef to right print(theList[0]) # negative => right to left p...
88426134d90b41e58f5005a68ef6d1fa5b5f25bf
VettiEbinyjar/py-learning
/1-basics/4-format-str.py
824
4.09375
4
age = 25 print('My age is ' + str(age) + ' years') # replacement filed print('My age is {0} years'.format(age)) print('There are {0} days in {1}, {2}'.format(31, 'Jan', 'Mar')) # reusing data print('''Jan:{2}, Feb:{0}, Mar:{2}, Apr:{1}'''.format(28, 30, 31)) print() print('My age is %d years' % age) print('My age is...
ecf9b7dd7e7b01d6313dbd1aa41e56f1a989d919
nathrichCSUF/Connect4AI
/slot.py
932
3.75
4
""" FALL 2019 CPSC 481 Artificial Intelligence Project File Description: slot.py Class representing a slot in the Connect Four Game Grid Authors: Nathaniel Richards Yash Bhambani Matthew Camarena Dustin Vuong """ import pygame class Slot: def __init__(self, screen): self.screen = sc...
df86e18aa118aa33e47a8f31b0c501946df0c58d
febimudiyanto/mysql-python
/connection.py
2,086
3.5625
4
# IP address dari server ''' untuk terkoneksi dengan mysql secara remote, bisa digunakan command berikut: mysql -u python-user -h <ip> -P <port> -p > masukkan passwordnya * insert INSERT INTO table_name VALUES (column1_value, column2_value, column3_value, ...); INSERT INTO logins(username, password) VALUES('admini...
caadf640706febc1f913cef4cf1c926a3caacd56
dmitryzykovArtis/education
/44.py
890
3.546875
4
"""Топологическая сортировка""" n, m = map(int, input().split(" ")) G = [[] for i in range(n)] for i in range(m): k, v = map(int, input().split(" ")) G[k].append(v) def dfs(G, start, path, circle_check): neibours_count = len(G[start]) circle_check.append(start) for i in range(neibours_count): ...
8e8605216fefcc40be79259a007eca21a3ee554c
bazunaka/geekbrains_python
/python_start/homework1/2. time.py
306
4.15625
4
#Просим ввести количество секунд seconds = int(input("Введите количество секунд: ")) #Приводим вывод input к int hours = seconds//3600 minutes = seconds%3600//60 second = seconds%3600%60 print("{0}:{1}:{2}".format(hours, minutes, second))
f7645df887992fbffd4838e2ce6765c8e0d50ba4
AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges
/Challenges/capacityToShipWithInDDays.py
3,103
4.1875
4
""" A conveyor belt has packages that must be shipped from one port to another within D days. The i-th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of...
751c56ef12ace6d4012ff9928863a8b14aa1af82
johnnystefan/personalProject
/prueba2.py
3,908
3.734375
4
import os import time import collections def clean(): """ Funcion para limpiar pantalla """ os.system('cls') def sumNode(i): """ Funcion para determinar la Sumatoria por cada nodo """ global groupColor value = 0 view = {i} # deque >>> es un contenedor de elemnetos # c...
8b349b785e182f6453c0999b41377988273e8244
deadstrobe5/IA-Project
/IA1920Proj2alunosv01/ruagomesfreiregame2sol.py
3,063
3.515625
4
# Afonso Ribeiro 89400 ; Guilherme Palma 89438 ; Grupo 23 import random import numpy DISCOUNT = 0.9 L_RATE = 0.9 EXPLORE = 0.1 # LearningAgent to implement # no knowledeg about the environment can be used # the code should work even with another environment class LearningAgent: # init # nS maximum ...
971c1279ac8068ea8b458cfcfd176da9b059a9b2
inno-asiimwe/primes
/test_primes.py
1,842
4.28125
4
import unittest from primes import list_primes, is_int, is_greater_than_two class PrimeNumberTest(unittest.TestCase): """Test for the list_primes function""" def setUp(self): self.primes = list_primes(100) def test_is_int_interger(self): """Testing whether is_int returns true wit...
24b384a4c5a59f6d2b4e54cd6a5077ab2c31f9cb
yosifnandrov/softuni-stuff
/list,advanced/Moving Target.py
949
3.65625
4
targets = input().split() targets = [int(i) for i in targets] command = input() while not command == "End": action, index, value = command.split() index = int(index) value = int(value) if action == "Shoot": if 0 <= index < len(targets): targets[index] -= value else: ...
25a474b01ea6066fe345abc117d7407972ba217f
1218muskan/MarchCode
/Day 22/day22.py
216
3.84375
4
# "To Find the maximum and minimum number in an array" n = list(map(int,input().split())) max = max(n) min = min(n) print(f"The minimum no. in the array is {min}") print(f"The maximum no. in the array is {max}")
801d3a0f6252cc20fe7977520f5b99dfe42a8005
BlueBookBar/SchoolProjects
/Projects/PythonProjects/Project3.py
9,092
3.65625
4
import sys class Node: #Initialize def __init__(self, letter = "" , row = None, column = None, left = None, right = None, up = None, down = None, distance= None): self.distance = 0 self.letter = letter self.left = left self.right = right self.up = up self.down =...
e477577bb990e364f265f36fa3d3be201bf9455a
Researching-Algorithms-For-Us/4.Implementation
/baekjoon/python/17478.py
1,046
3.875
4
def set_input(): number = int(input()) return number def main(): number = set_input() def answer(m): step = "_" * 4 * (number-m) print(step + '"재귀함수가 뭔가요?"') if m == 0: print(step + '"재귀함수는 자기 자신을 호출하는 함수라네"') print(step + '라고 답변하였지.') retur...
a1874a1895b2128fd99216b4711c9045c6434bc0
cdngnoob/playground
/python/3.1.2/aufgabe312.py
368
3.5
4
from turtle import * def Weihnachtsbaum(x, y): up() goto(x,y) down() setheading(90) forward(40) left(90) forward(60) right(120) forward(120) right(120) forward(120) right(120) forward(60) #Weihnachtsbaum(50, 100) def Weihnachtswald(): for i in range(-200,200,4...
8cf569857f1f7d8c4f259a63a2040781cc43927a
kavin-lee/AI
/DS/day06/03_vec.py
413
3.84375
4
#!/usr/bin/python3 # !coding=utf-8 ''' 函数矢量化 ''' import numpy as np import math as m def foo(x, y): return np.sqrt(x ** 2 + y ** 2) a, b = 3, 4 a = np.arange(3, 9).reshape(2, 3) b = np.arange(4, 10).reshape(2, 3) print('a:', a) print('b:', b) print('foo:', foo(a, b)) # 矢量化处理函数foo函数,使之可以处理矢量数据 foo_vec = np.vec...
ecf5cda180204ab60c9ddcf1eea66f7332831eb4
wenjuanchendora/Python_Study
/2017-12/2017-12-12.py
1,430
3.96875
4
# 阿姆斯特朗数 # number = int(input("Please enter number: ")) # length = len(str(number)) # sum = 0 # for x in range(length): # sum += int(str(number)[x])**length # if sum == number: # print("%d is an AMSTL number" % number) # else: # print("%d is not an AMSTL number" % number) # minnum = int(input("Please ente...
c9c870321e1c8896a730b66f6e3101896d1eb6d6
danielsimonebeira/prova_n1
/atividade3.py
442
4
4
# 3 - Faça um programa que peça uma nota, entre zero e dez. Mostre uma mensagem # caso o valor seja inválido e continue pedindo até que o usuário informe um valor # válido.(2,0) nota = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] contador = 1 while True: valor = int(input("Digite de 1 a 10: ")) for i in nota: if...
0c20bf4e9a4ee8846063d4bbe06b353b66e10063
paiqu/Online-Discussion-Forum
/client.py
7,728
3.53125
4
# Python 3 # Usage: python3 client.py server_IP server_port import sys import socket import json import os import select import threading import time server_IP = sys.argv[1] server_port = int(sys.argv[2]) # boolean to record if the server is down server_is_down = False def handle_connection(connection): global...
d494c29af7c833479b4e794873ba9685c200d727
daniel-reich/ubiquitous-fiesta
/kmruefq3dhdqxtLeM_5.py
321
3.765625
4
def sum_digits(a, b): new = [] while a <= b: new += [a] a += 1 digits = [] for x in new: while x > 0: digits += [x % 10] x //= 10 total = 0 for x in digits: total += x return total ​ def sum_digits(a, b): return eval('+'.join('+'.join(i for i in str(j)) for j in range(a, b + 1)))
749f21aeee336c443a2060424c0dae6fab471b38
Jayasree-Repalla/Innomatics_Internship_APR_21
/Python Task Day4/String Validators.py
967
3.53125
4
if __name__ == '__main__': s = input() l,m,n,o,p=0,0,0,0,0 for i in s: if (i.isalnum()): print("True") break else: l=l+1 if l==len(s): print("False") for i in s: if (i.isalpha()): print("True") ...
cefdffeffbf47be40b65ef3e646f50a2243f4bf4
edybahia/python2018
/code_curso/mes_de_nascimento.py
1,217
4.4375
4
#criando a tupla # Lista, tem a possibilidade de ser mudada os seus valores que estão guardados, # neste caso estes ela e mutada, sendo assim posso alocar qualquer conteudo lá dentro # Já as TUPLAs, são valores fixos sem possibilidade de mudanças. # Comando Len checa quantos caracter tem dentro de um TUPLA print(len...
bd312ef4abc9614a4f6a088b0400b59947045a34
kjeffreys/pythonKit
/dataLoadingStorageAndFileFormats/dataIOwithPandas/delimitedFormats/myDialect.py
566
3.78125
4
''' CSV files can have a variety of formatting flavors. To define a new format with a different: 1) delimiter, 2) string quoting convention, or 3) line terminator, define a subclass of csv.Dialect ''' import csv import pandas as pd f = 'csvFiles/example.csv' class myDialect(csv.Dialect): lineterminat...
d5dd23ba77169c7cd1336d3706e3f8d3cd377929
ssoso27/Smoothie2
/pythAlgo/programmers/level2/find_prime_number.py
1,237
3.78125
4
prime_number = [] result = set() def make_prime_number(l): global prime_number N = 10 ** l prime_number = [True for _ in range(N)] prime_number[0] = False prime_number[1] = False for i in range(2, int(N**0.5)+1): if prime_number[i]: m = 2 while True: ...
1437dc91a974940d13397027c0df03be9e3069e7
alexwohletz/PyTutorScripts
/write_dict_tocsv.py
226
3.609375
4
with open('dict.csv','w') as csv_file: writer = csv.writer(csv_file) writer.writerow(["Colname1","Colname2"]) for key,value in {item[0]:item[1] for item in zip(l1,l2)}.items(): writer.writerow([key,value])
bacd51a3ab3c65745db13e568e172db186693813
VivekMishra02/Naive_Bayes_Classifier
/BaysClassifier.py
3,842
3.65625
4
# Example of calculating class probabilities from math import sqrt from math import pi from math import exp import pandas as pd # Split the dataset by class values, returns a dictionary def separate_by_class(dataset): separated = dict() for i in range(len(dataset)): vector = dataset[i] ...
57c6e61deb8c91b3add30bd795811608fabf6896
sarinaxie/K9-trainer
/euclidean_distance.py
887
3.828125
4
""" Name: Sarina Xie UNI: sx2166 This file contains a function that calculates the euclidean distance between two 1 x (n+1) vectors. """ import math #for testing from create_data import create_data from integerize_labels import integerize_labels from split import split def euclidean_distance(x1,x2): """Function ...
e02fe717ec2e361a4c4c1dcf085439a7d9be7e9d
patriciaslessa/pythonclass
/RepeticaoFor_14.py
428
3.640625
4
#def lista_2_ex_1(): """ Faça um programa que peça 10 números inteiros, calcule e mostre a quantidade de números pares e a quantidade de números impares. """ n_par = 0 n_impar = 0 for i in range(1,11): number = input("Digite um numero: ") n = int(number) print(f" {n}") if (n % 2 == 0 ): n_p...
3cebc64b953e15f1ca038abb92cb6a29319638a6
Zovengrogg/ProjectEuler
/Euler45_TriangularPentagonalAndHexagonal.py
551
3.515625
4
# Triangular, Pentagonal, and Hexagonal https://projecteuler.net/problem=45 from math import sqrt def isPentagonal(n): number = (sqrt(24*n + 1) + 1)/6 if number.is_integer(): return True return False def isTriangular(n): number = (sqrt(8*n + 1) + 1)/2 if number.is_integer(): ...
41e72e8a5de24c5c7c4215b669c5d4f1c2fb61f3
AdamKnowles/coins-to-cash
/coinsToCash.py
1,158
4.21875
4
# Create a function called calc_dollars. In the function body, define a dictionary and store it in a variable named piggyBank. The dictionary should have the following keys defined. # quarters # nickels # dimes # pennies # For each coin type, give yourself as many as you like. # piggyBank = { # "pennies": 342, # ...
d7d00aa1981b5908e0533106b69690a833b4f5ce
parthoza08/python
/ch-9_prq9.py
168
3.59375
4
with open("file.txt") as F: F1 = F.read() with open("copy.txt") as s: F2 = s.read() if F1 == F2: print("both are same files") else: print("not same")
3557b414b7fc221d7bef53087bd89e8c8efcc130
kdk745/Projects
/CS313E/Josephus.py
3,190
3.625
4
# File: Josephus.py # Description: # Student Name: Juanito Taveras # Student UT EID: jmt3686 # Partner Name: Kayne Khoury # Partner UT EID: # Course Name: CS 313E # Unique Number: # Date Created: 4/2/2015 # Date Last Modified: 4/2/2015 class Link(object): def __init__ (self, data, next = None): ...
fa0eebc063491f3b68db17e2ab193ab28c57da04
camiloprado/Curso-Python
/Aula 15.py
256
4.03125
4
import math angulo = float(input('Digite o ângulo: ')) print('Para os ângulo de {:.0f}°:\nSeno = {:.1f}\nCosseno = {:.1f}\nTangente = {:.1f}'.format(angulo, math.sin(math.radians(angulo)), math.cos(math.radians(angulo)), math.tan(math.radians(angulo))))
6d1c547df083e7ce7ecdbfb1377cbc2ff212fd23
leocjj/holbertonschool-higher_level_programming
/0x10-python-network_0/6-peak.py
1,022
3.953125
4
#!/usr/bin/python3 """This module has a function that finds a peak in a list of unsorted integers. Prototype: def find_peak(list_of_integers): You are not allowed to import any module Your algorithm must have the lowest complexity 6-peak.py must contain the function 6-peak.txt must contain the comp...
e491f0183ac88e71e4a0615c6cbdd69664db1ad5
jsoto3000/js_udacity_Intro_to_Python
/tiles.py
204
3.609375
4
# Fill this in with an expression that calculates how many tiles are needed. print(9*7 + 5*7) # Fill this in with an expression that calculates how many tiles will be left over. print(17*6 - (9*7 + 5*7))
1c2c0cbee56b2e828cb9b5b5e796ca1e81e4f2d7
kosemMG/python_avratech
/exercise-5-dots.py
148
3.625
4
for i in range(15): if i <= 5: print('* ' * i) elif i <= 9: print('* ' * (10 - i)) else: print('* ' * (15 - i))
f19332f441ec20a1c70835d6aea92900addb9400
alllllli1/Python_NanJingUniversity
/2.4.1/break_continue_else.py
498
3.875
4
# -*- coding: utf-8 -*- # @Time : 2020/3/20 10:32 # @Author : wscffaa # @Email : 1294714904@qq.com # @File : break_continue_else.py # @Software: PyCharm # break作用:终止当前循环,转而执行循环之后的语句 #输出2-100之间的素数:2~根号x 只要没有可以整除的数,x就是素数 from math import sqrt j = 2 while j <= 100 : i = 2 k = sqrt(j) while i <= k : ...
12fa7134c14a3521294c1e62e08fafa23dffae2f
f-e-d/2021-Algorithm-Study
/Programmers/jiwoo/2021_kakao_blind/메뉴리뉴얼.py
504
3.546875
4
from collections import Counter from itertools import combinations def solution(orders, course): result = [] for course_size in course: order_combinations = [] for order in orders: order_combinations += combinations(sorted(order), course_size) most_ordered = Counter(order_...
8ce13f17f22c1016b281b51bd33f421f240374fd
PritamTCS/python_assignment
/assignment4/str.py
390
4.3125
4
#!/usr/bin/python ## extracting first& last 2 charcter from a given string def pair(s1): if len(s1) >2: s2=s1[0:2]+s1[-2:] #return s2 print("First&last 2 charcters of the string is:",s2) else: #return "" print("length of string is less than 2") s=input("Enter a string:")...
9cb9372bdaecb5644ae766b239b3747f3e1e4ffe
tianyulang/Database
/assignment4.py
12,068
3.640625
4
import pandas as pd import sqlite3 import matplotlib.pyplot as plt import folium def q1(qq1,connection): start_year= input('Enter start year(YYYY) ') end_year = input('Enter end year(YYYY) ') crime_type = input('Enter crime type ') df = pd.read_sql('select month1,count(Incidents_Count) from (select dist...
9e6264e52999f19787fd542e82a39fe29d9eabd0
Jonathancui123/Coding-Interview
/PythonProjects/448. Find All Numbers Disappeared in an Array.py
1,833
3.828125
4
# CYCLICE SORT, ARRAY, (Use indices to represent numbers) # Ex 1: [3,3,3] -> [1,2] ''' O(n^2) time [brute] : For each number in [1, n], check if it is in nums. If it is not, add it to the output list O(n) time, O(n) space [set]: Create a set initialized to contain [1,n] and remove each element that we see in nums. ...