blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
f0d861d409ea9e701161fc50951558227f467a12 | LeleCastanheira/cursoemvideo-python | /Exercicios/ex039.py | 990 | 4.03125 | 4 | from datetime import date
print('''Escolha o seu sexo:
[ 1 ] Feminino
[ 2 ] Masculino''')
op = int(input('Sua opção: '))
if op == 2:
nasc = int(input('Ano de nascimento: '))
idade = date.today().year - nasc
print('Quem nasceu em {} tem/fará {} anos em {}'.format(nasc, idade, date.today().year))
if idade... |
c7c26be959a82fa450eaaa10dd813e883be4cec2 | darshan-kt/Udacity-FlyingCar-NanoDegree | /P2 - Motion Planning/scripts/bresenham.py | 829 | 3.8125 | 4 | import pybresenham
import matplotlib.pyplot as plt
# Install pybresenham library
# pip install pybresenham
# Note: you can run this for any (x1, y1, x2, y2)
line = (0, 0, 7, 5)
cells = list(pybresenham.line(line[0], line[1], line[2], line[3]))
print(cells) #This diplays the all intermidiate points
#This for v... |
593075c84143d20f395787ad2e010a8efa3a50fc | darshan-kt/Udacity-FlyingCar-NanoDegree | /P2 - Motion Planning/scripts/steering.py | 2,001 | 3.53125 | 4 |
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = 12, 12
# limit the steering angle range
MAX_STEERING_ANGLE = np.deg2rad(30)
# Set the width of the Gaussian we'll draw angles from
ANGLE_STDDEV = np.deg2rad(3)
# NOTE TO THE READER:
# This steer() function is not meant to be a partic... |
337904dc2450ebaf368a58984385087c15fe2395 | ss4328/project_euler | /problem4.py | 855 | 4.25 | 4 | #The purpose of this program is to find largest 3-digit palindrome product
print("Palindrome problem starting...")
n1 = 100
n2 = 100
ans = 0;
def reverse(num):
rev = 0
while num > 0:
rev = (10 * rev) + num % 10
num //= 10
return rev
def isPalindroms(input):
if(input == reverse(input... |
bfadf705e0239c76aed3aaa8f99e9b30afb5774c | tonyfresher/dictionaries | /realizations/linear_search.py | 1,112 | 3.53125 | 4 | from collections import MutableMapping
class LinearSearchDict(MutableMapping):
'''Dictionary on arrays with linear search'''
def __init__(self, **kwargs):
self._count = 0
self._keys = list(kwargs.keys())
self._values = list(kwargs.values())
def __setitem__(self, key, value):
... |
a58f314ff98de418dcf262957b2c336b2d5b12ea | ahsanfirdaus1/Ahsan-Personal-Project | /SimCal1.py | 2,324 | 4.15625 | 4 | print("Welcome To Ahsan Simple Calculator")
print("==================================")
print("Before The Program Starts, May I Know What's Your Name?")
UserName = input("Name: ")
i = 1
while i == 1:
print("Hello", UserName, "! Please Choose What Operator Do U Want")
print("1. + \n2. - \n3. x \... |
9290a7799665fb1f626a0487437d7e8f86162fc6 | flowera/projects | /epicDataReport/epic_data_cleaning.py | 3,624 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Remove Leading and Trailing Spaces of CSV files in particular folders.
Created on Wed Jul 19 15:25:26 2017
@author: GuoRubing
"""
import inspect, os, glob
import csv
# Change this line to whatever folder you want to revise
folder_name = "201706 Implants\\"
# Implant data back... |
ddc65b965c24084a031f5de70c2e04dfd99ad6a1 | coolp4n/NBAStatScraper | /NBAStatScraper/standings.py | 3,551 | 3.765625 | 4 | import pandas as pd
from bs4 import BeautifulSoup, Comment
import requests
from requests_html import HTMLSession
import pyppdf.patch_pyppeteer
def get_division_standings(conference, year):
'''
Scrape the division standings for a given year.
Parameters:
conference (string): The conference to get th... |
39ea1dcb8aa97c661a6cc5fd14357e51ea5c90a1 | nedhanks/py3class | /EXERCISES/ch03-01.py | 825 | 3.875 | 4 | #!/usr/bin/env python
"""
This is the doc string for the module/script.
"""
import sys
# other imports (standard library, standard non-library, local)
# constants (AKA global variables -- keep these to a minimum)
# main function
def main(args):
"""
This is the docstring for the main() function
:param ... |
7692e3274550d7ef4dad4e0c3fb65d608d28f7d3 | Krishnaarunangsu/ArtificialIntelligence | /src/datascience/data_exercises/python_data_assignment_8.py | 1,206 | 4.28125 | 4 | # Difference of two columns in Pandas dataframe
# Difference of two columns in pandas dataframe in Python is carried out by using following methods :
# Method #1 : Using ” -” operator.
import pandas as pd
# Create a DataFrame
df1 = {'Name': ['George', 'Andrea', 'micheal',
'maggie', 'Ravi', 'Xien', 'Ja... |
c4988daadeb56b064ca9558f959a00ec031da04f | Krishnaarunangsu/ArtificialIntelligence | /src/datascience/data_exercises/python_dictionary_1.py | 660 | 4.28125 | 4 | # Creating an empty dictionary
dictionary_1 = dict()
dictionary_2 = {}
print(f'Dictionary-1:{dictionary_1} Type:{type(dictionary_1)}')
print(f'Dictionary-2:{dictionary_2} Type:{type(dictionary_2)}')
# Creating a Dictionary with Integer Keys
dictionary_3 = {1: 'God', 2: 'is', 3: 'Great'}
print(dictionary_3)
# Creating... |
fcc9c9b601411e05ff0d28f5a23f8f4502a3b139 | Krishnaarunangsu/ArtificialIntelligence | /src/datascience/data_exercises/python_list_comprehension_assignment_1.py | 2,033 | 4.59375 | 5 | # Python List Comprehension and Slicing
# List comprehension is an elegant way to define and create list in python. We can create lists just like mathematical statements and in one line only. The syntax of list comprehension is easier to grasp.
#
# A list comprehension generally consist of these parts :
# Output exp... |
ecb605c22f7347231346078c127f18fd3b4ce3af | Krishnaarunangsu/ArtificialIntelligence | /src/datascience/data_exploration/python_ml_eda_1.py | 1,699 | 4 | 4 | import pandas as pd
# Creating the dataframe from csv
df_nba = pd.read_csv('../../../data/nba.csv')
print(f'Dataframe Columns:\n{df_nba.columns}')
print('****************************************')
# Getting dataframe columns from iterables
for column in df_nba.columns:
print(f'Column Name is:{column}')
print(f... |
14226708a9f5473ac80b76c4afe7bc47da5b403b | Krishnaarunangsu/ArtificialIntelligence | /src/datascience/data_exercises/python_data_assignment_2.py | 1,796 | 4.65625 | 5 | # Syntax:
# DataFrame.sort_values(by, axis=0, ascending=True, inplace=False, kind=’quicksort’, na_position=’last’)
# Every parameter has some default values execept the ‘by’ parameter.
# Parameters:
# by: Single/List of column names to sort Data Frame by.
# axis: 0 or ‘index’ for rows and 1 or ‘columns’ for Column.
# a... |
3428dab90cf5035e823b8858e200ab0b5874a563 | liyanghao/ita_3e | /recitation/python/src/recitation2/array_seq.py | 1,597 | 3.96875 | 4 | # coding=utf-8
'''
序列的静态数组实现
'''
class Array_Seq:
def __init__(self):
self.A = []
self.size = 0
def __len__(self):
return self.size
def __iter__(self):
yield from self.A
def build(self, X):
self.A = [a for a in X]
self.size = len(self.A)
def get... |
f73633bbcb4b43f69ea9634bf550c41bba263497 | mvsaha/blahb | /blahb/encoding.py | 12,410 | 3.734375 | 4 | import numpy as np
import numba
"""
The idea of this compression is to pack multiple dimensions that each require
less than 32 bits of information to represent into the _loc array of an
IndexSet.
The compression should be structured such that a lexicographical comparion
between two compressed rows should return the s... |
03f920ebc7b7de63c3f219c9ce5e2c53d94ba438 | mvsaha/blahb | /blahb/image.py | 3,170 | 3.71875 | 4 | """
Tools for converting from IndexSet (spatially explicit) to image (implicit).
"""
import numpy as np
import numba
from .utils import expand_maybe
from .indexset import IndexSet
from .flags import SORTED_UNIQUE
def image(indexset, padding=0, data_col=None):
"""Convert an indexset into a cropped boolean image.
... |
bc8d2aab5424f11ebc231eced3f7a5859893daf3 | ManuelBerrueta/CptS350-Algorithm_Analysis-Design | /Diophantine_Contraints/final.py | 13,093 | 3.609375 | 4 |
import networkx as nx
DEBUG = 1
TESTING = 0
ALGO_TEST = 1
INPUT_TEST = 0
# CptS350 - Diophantine Constraints Using Labeled Graphs Final Exam Project
class Vertex:
def __init__(self, node, payload):
self.id = node
self.payload = payload
self.adjacent = {}
def __str__(self):
... |
64a757f8aa65252fa241517c5377b8230b601525 | tyusliu/CanvassLabs | /python projects/cpe_parse.py | 21,229 | 3.8125 | 4 | import json
import csv
import re
def count_words(how_many_words_in_this_string):
"""Counts words in the given string"""
if isinstance(how_many_words_in_this_string, str):
lengthList = how_many_words_in_this_string.split()
return len(lengthList)
else:
raise ValueError("Inpu... |
7292e151d67f39b26915ecbb13b9f6389674e2b0 | tracyvierra/vigilant-pancake | /TCPM-LPFS/text-2-speech/text_2_speech_live.py | 1,175 | 4.1875 | 4 | # Author: Tracy Vierra
# Date Created: 3/11/2022
# Date Modified: 3/11/2022
# Description: Text to speech example using user input to speech and saved as a file.
# Usage:
from turtle import right
from gtts import gTTS
import os
import tkinter as tk
from tkinter import filedialog as fd
from tkinter import *
# text ... |
259da5baddf6527cba8b3fcdfdb73c2a72c321ca | tracyvierra/vigilant-pancake | /TCPM-LPFS/text-2-speech/text_2_speech_gui.py | 2,213 | 3.828125 | 4 | # Author: Tracy Vierra
# Date Created: 3/11/2022
# Date Modified: 3/11/2022
# Description: Text to speech example
# Usage:
from turtle import bgcolor
from gtts import gTTS
import os
import tkinter as tk
from tkinter import filedialog as fd
from tkinter import ttk
def open_file_input():
input_file = fd.askopenfi... |
92d223b0533546858a70243ac95a8d70eaac8449 | tracyvierra/vigilant-pancake | /TCPM-LPFS/examples/oop_example.py | 605 | 4.0625 | 4 | # Author: Tracy Vierra
# Date Created: 3/1/2022
# Date Modified: 3/1/2022
# Description:
# Usage:
# function example:
# def abc():
# name = input("Enter name: ")
# age = input("Enter age: ")
# print(name)
# print(age)
# abc()
# oop example:
class Student:
def __init__(self, name, age):
... |
768c71d6e2ee67bdba5e3de87ba309be9913270a | tracyvierra/vigilant-pancake | /TCPM-LPFS/examples/multiple_inheritance_example.py | 1,324 | 4.46875 | 4 | # Author: Tracy Vierra
# Date Created: 3/1/2022
# Date Modified: 3/1/2022
# Description: Multiple inheritance example
# Usage:
# class Student: # base class
# def __init__(self, name, age):
# self.name = name
# self.age = age
# def get_data(self):
# self.name = input("En... |
c44e73e1bc6d4d3dc0e02701730ff326d9f81c65 | tracyvierra/vigilant-pancake | /TCPM-LPFS/examples/re_example.py | 597 | 3.671875 | 4 | # Author: Tracy Vierra
# Date Created: 3/2/2022
# Date Modified: 3/2/2022
# Description:
# Usage:
import re
pattern = r"bacon"
if re.match(pattern, "bacon"):
print("Match bacon!")
else:
print("No match!")
if re.match(pattern, "eggs"):
print("Match eggs!")
else:
print("No match!")
if re.search(pattern, "b... |
e537c9e2175b8b719cde06d56625a49ba4b72f5d | tracyvierra/vigilant-pancake | /TCPM-LPFS/examples/regex_examples.py | 4,052 | 4.03125 | 4 | # Author: Tracy Vierra
# Date Created: 3/2/2022
# Date Modified: 3/2/2022
# Description:
# Usage:
import re
string = "abc"
pattern = r"a"
print(re.match(pattern, string)) # returns Match object at the start of the string
print(re.search(pattern, string)) # returns Match object by scanning the whole string
print(re... |
fa39c1953ebb00783a4331ceb6aabb47ab02bde9 | youj70027/CS232-FOSS-LAB | /cars.py | 2,379 | 3.515625 | 4 | import string
import glob
import pickle
def djfcars():
n=input("enter number of cars to be added:")
for i in range(n):
name=raw_input("Car Name:")
a=[]
a.append(raw_input("Model:"))
a.append(input("price:"))
a.append(raw_input("colour:"))
a.append(input("In stock :"))
d[name]=a
def main... |
99de716d9c3357bf79892cb969e3e6dbd55085db | youj70027/CS232-FOSS-LAB | /d.py | 282 | 3.796875 | 4 | print"DIVYA ROSE RAJU"
n=input("enter number of elements:")
l=[]
for i in range(n):
l.append(input("enter element:"))
print l
print "sorted array is :"
for i in range(n):
for j in range(n-1):
if l[j]>=l[j+1] :
temp=l[j]
l[j]=l[j+1]
l[j+1]=temp
print l
|
b5e0800b814ca07a42f179d31d080dfd49dd6235 | tom-williams26/Python | /Numbers.py | 909 | 4.0625 | 4 | if __name__ == '__main__':
first_number = 1
second_number = first_number
second_number += 1
print "\nInteger assignment example:"
print "second_number =", second_number, "first_number = ", first_number
first_list = [1]
second_list = first_list
second_list[0] += 1
print... |
a5e08095e377423567d9cbb478a334fd327e8d3d | Idfa001/praxis-academy | /novice/03-02/oplodec.py | 241 | 4.03125 | 4 | x = float(input("Enter first number :"))
y = float(input("Enter second number :"))
print(x == y)
print(x != y)
print(x > y)
print(x < y)
print(x >= y)
print(x <= y)
print(x > 3 and x < 10)
print(not(x > 3 and x < 10))
print(x > 3 or x < 4)
|
fa308093aff08e52769595080553379acd76b030 | CatGoesBrrr/For-Loops-Practice | /2_8_1_for_loops.py | 114 | 4.125 | 4 | number = int(input("Enter a number: "))
total = 0
for i in range (number + 1):
total = total + i
print (total) |
e0fab44a525cc912f7f8d43c618af3fc3f9ed711 | abdulwagab/Demopygit | /Operators1.py | 531 | 4.21875 | 4 |
'''Relational Operators Example in Python'''
def operator(x, y, z): # Functions name and its arguments
a = 1 # Assign variables in Function
b = 2
c = 0
x = a or c and b # Compare variables in Logical operators but not print
y = a and c or b # Compare variables in Logical operators but n... |
2a4d5558f5a5469a0e68c03a0c396ff16e619f76 | DevilNK/narottam-meena | /three number swapping program.py | 196 | 4.03125 | 4 | x = int(input("enter number 1 :"))
y = int(input("enter number 2 :"))
z = int(input("enter number 3 :"))
print("number that you write :", x,y,z)
x,y,z = y,z,x
print("after swapping :", x,y,z) |
45385918dcd86c990fcd85ce0d5b2b0c3628d476 | shanecroberts/FuelManager | /Route.py | 7,316 | 3.625 | 4 | from AirportVisit import AirportVisit
class ImpossibleRouteError(Exception):
def __init__(self, message):
self.message = message
class Route:
"""
Route: Contains information about a possible route.
Includes a method for calculating the cheapest places to refuel along the route.
Also incl... |
5a883edabf937dce7ae27da06c069b5b9acf8b3a | shanecroberts/FuelManager | /Currency.py | 5,729 | 3.765625 | 4 | import urllib.request
from urllib.error import URLError
URL = "https://www.google.com/finance/converter?a=1&from="
START = "<span class=bld>"
END = " "
class Currency:
"""
Currency class: holds information about a country, its currency and the euro exchange rate.
It contains an accessor method, get_exchang... |
d8868e60095cc3eaa61838284375d63a1a18decb | Vanderscycle/lighthouse-data-notes | /prep_work/Lighthouse lab prep mod katas/kata3-vowels.py | 466 | 4.0625 | 4 | # Counting the number of vowels in a given string
# Input: a string (of varaying length)
# Output number of vowels found
def numberOfVowels(sentence):
vowels = ['a','e','i','o','u']
vowels_count = 0
for letter in sentence:
if letter.lower() in vowels:
vowels_count += 1
r... |
93d669e04066f345afe68017ab73c30d9145e53d | Vanderscycle/lighthouse-data-notes | /prep_work/Lighthouse lab prep mod katas/.ipynb_checkpoints/ch9-linear_algebra-checkpoint.py | 1,504 | 4.15625 | 4 | import numpy as np
x = np.array([1, 2, 3, 4])
print(x)
# Matrix A
A = np.array([[1,2],[3,4],[5,6]])
print(type(A))
# in which the result is a tuple of (columns, rows)|(3x,2y) of the matrix
print(A.shape)
print(x.shape)
print(len(x)) # returns the length of the array (#in the list)
# transpose an a mat... |
b462a95dd89fc748356d1d1c90d20e3da01b71a3 | Vanderscycle/lighthouse-data-notes | /prep_work/Lighthouse lab prep mod katas/kata8-multiplication_table.py | 485 | 4 | 4 |
# INPUT: single integer
# OUTPUT: Not really specified.
#unsure what exact format we want the multiplication table to be in.
def multiplicationTable (maxValue):
column_size = list(range(1, maxValue + 1))
index = 1
line_printer = str()
while index <= maxValue:
for val in column_... |
fcb6c5a851376f57ec2712e2fc99db3ffbbb4d20 | Vanderscycle/lighthouse-data-notes | /prep_work/Lighthouse lab prep mod katas/kata6-smartparking.py | 1,589 | 4.03125 | 4 |
# INPUT: parking grid, type of vehicle
# OUTPUT: returns the coordinates [x/columns,Y/rows] of an available parking sport/ false if none avail
# Regular cars R
# Smol cars R/S
# Motorcycle R/S/M
# Grid: UPPERCASE = AVAILABLE / lowercase = unavailable
# list of lists (use nested loops)
#NOTE1: in your ... |
dee0620a9f930628a7ea44f4d73779e76686b4c2 | melphick/pybasics | /week6/w6e2.py | 342 | 4.28125 | 4 | #!/usr/bin/python
"""
Converts a list to a dictionary where the index of the list is used as the
key to the new dictionary (the function will return the new dictionary).
"""
def list_to_dict(a_list):
a_dict = {}
for i in a_list:
print i
a_dict[i] = a_list[i]
return a_dict
a = range(10)
... |
cbd0d974b4b636760e98b1a4da159129e025be14 | patidarjp87/ROCK-PAPER-SCISSOR-GAME | /ROCK.py | 1,438 | 4.1875 | 4 | import random
print("WELCOME TO ROCK PAPER SCISSOR GAME\n")
lst = ["Rock", "Paper", "Scissor"]
computer_score = 0
player_score = 0
game = 0
chance = 6
while game < chance:
choice = random.choice(lst)
turn = input("choose(rock, paper or scissor) : ").lower()
game +=1
if turn == "rock" and choice == "Scis... |
f3070c91d69aee367348e1b65aa6828da5b5d5eb | JHertz5/nhl_upcoming_games | /nhl_upcoming_games.py | 3,075 | 3.65625 | 4 | '''
This script uses the public nhl api to get schedule information
and print details of any games in the specified date range that
are within the specified time range
'''
import json
import requests
from datetime import datetime,date,timedelta,timezone,time
def generate_filtered_game_list_entry(game, game_datetime_l... |
b8ab1c0d7ef470a9a5ec0c1fc5103fe467c190e5 | qingjiu0/python_homework | /20171212.py | 3,014 | 3.765625 | 4 | '''
while循环
'''
#求1~100递加 1+2+3+···+99+100
n=100
sum=0
counter=1
while counter<=n:
sum=sum+counter
counter+=1
print("1到%d之和为%d"%(n,sum))
n=100
sum=1
counter=1
while counter<=n:
sum=sum*counter
counter+=1
print("1到%d之积为%d"%(n,sum))
#1-1/2+1/3-1/4+·····+1/99-1/100
n=100
result=0
counter=1
while cou... |
f1244ba9b6a536487092b6975f82c89961f49542 | willellis31/weatherForecast | /stage1/forecast.py | 999 | 3.71875 | 4 | #!/usr/bin/python
import httplib
import json
import sys
def getForecast(latitude, longitude, time):
'''Function to get the forecast for a given city'''
try:
# api key and url for site
url = "api.forecast.io"
apiKey = '8fc9edcb289fe71e8dea71b64e5caa8b'
# obtain a connection
... |
650074bf605a56ddb94a4a6ff9ab260cadf72467 | Souravdg/Python.Session_4.Assignment-4.1 | /Filter Long Words.py | 600 | 4.4375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[14]:
##############################################
# A function filter_long_words() that takes a list of words and an integer n and returns
# the list of words that are longer than n
def filter_long_words(lst,length):
newlst = []
for x in range(len(lst)):
i... |
cb85f18e0c77369b04cbf9ed45405b8e7ecc4695 | MitchellX/RecordCommand | /test/snakeGame.py | 6,199 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 12 07:03:50 2014
@author: dell
"""
from tkinter import *
import random
class SnakeGame:
def __init__(self):
# moving step for snake & food that means the block size of food & snake
self.step = 15
# game score
self.g... |
75b9f65e35acefe17ad7daf41e50146535501bc9 | miahnaseem/Predicting-Coding-Problem-Difficulty | /problem1_easy.py | 239 | 3.921875 | 4 | # Given a list of numbers and a number k, return whether any two numbers from a list add up to k
# e.g. list:[10,15,3,7], k:17 -> true
list = [10,15,3,7]
k = 17
for i in list:
if k-i in list:
print(f'True: {i} + {k-i} = {k}') |
f7b334227b9d4055db02c292eb87d5aa36276680 | miahnaseem/Predicting-Coding-Problem-Difficulty | /problem4_hard.py | 888 | 3.984375 | 4 | # Given an array of integers, find the first missing positive integer in linear time and constant space.
# Find the lowest posuitive integer that does not exist in the array
# input: [3,4,-1,1], output: 2
# input: [1,2,0], output: 3
input = [5,3,4,4,-1,1,1]
def first_missing_integer(input):
# Sort to help ensure... |
6f2b19577351a9eb169a85eb2dd3a7c272e1eed1 | onemistake/day1-100 | /day2.py | 839 | 3.953125 | 4 | #摄氏温度和华氏温度转换,答案
f = float(input('请输入华氏温度: '))
c = (f - 32) / 1.8
print('%.1f华氏度 = %.1f摄氏度' % (f, c))
#根据半径计算周长和面积
# import math
# radius = float(input("请输入圆的半径:"))
# perimeter = 2 * math.pi * radius
# area = math.pi * radius ** 2
# print("圆的周长为:" + str(perimeter))
# print("圆的面积为:" + str(area))
#判断平年闰年
# year = int(i... |
3d01ef94ca343673a01661fbafb802e428353235 | meetpritmani/Python | /For Loop 1.py | 107 | 3.78125 | 4 | # for loop 1
i=5
for i in range (6):
for j in range (i):
print(i-j, end=" ")
print() |
4f45a9573c2fe9a59182942fca90d2ce0edb554c | meetpritmani/Python | /user input.py | 183 | 3.78125 | 4 | #simple print
i=5
print(i)
#string value
a="programmer baba"
print(a)
#user input
b= input("Enter Any Message: ")
print(b)
c= int(input("Enter Any Number: "))
print(c) |
51299a1d26a94f266139741aa5717943d1856a39 | smartysam9821/practice | /file1.py | 237 | 3.640625 | 4 | import numpy as np
import matplotlib.pyplot as plt
a = np.random.randint(10,100,50)
#1. crate boxplot for numpy array
plt.boxplot(a)
plt.show()
# 3. create histogram for numpy array
plt.hist(a)
plt.show()
print("histogram plotted")
|
1e87859872e73ad08db887544ac92cb802f7db2d | Garacc/LeetCode | /686. Repeated String Match.py | 284 | 3.5 | 4 | class Solution:
def repeatedStringMatch(self, A, B):
"""
:type A: str
:type B: str
:rtype: int
"""
s = A
while len(s) < 2 * len(A) + len(B):
if B in s: return len(s) // len(A)
s += A
return -1 |
1d2f6c10d1039c610175d5a775826598c62487cc | Garacc/LeetCode | /381. Insert Delete GetRandom O(1) - Duplicates allowed.py | 1,482 | 4.03125 | 4 | import collections
import random
class RandomizedCollection:
def __init__(self):
"""
Initialize your data structure here.
"""
self.values, self.indexs = [], collections.defaultdict(set)
def insert(self, val):
"""
Inserts a value to the collection. Retu... |
db1b4f58c2a81a257934e513d9b909651871717c | TeamRhaegal/Road-Analysis-Project | /Raspberry/RhaegalRaspi/demo_sprint4/roadSignDetection/roadsign_python_source/raspicam.py | 2,880 | 3.765625 | 4 | #!/usr/bin/env python
"""
RASPICAM.PY
This code defines a Raspicam class that allows you to configure the camera of the Raspberry Pi (named Raspicam), which offers to capture photos or videos, and save them or not.
"""
# import libraries
from picamera import PiCamera
from picamera.array import PiRGBArray
from s... |
9cb689ba849248bba41e7e634df966e1fc515470 | noamgl19-meet/meet2017y1lab6 | /funturtle.py | 508 | 3.875 | 4 | import turtle
turtle.shape("turtle")
square = turtle.clone()
square.shape("square")
square.penup()
square.goto(100,100)
square.pendown()
square.goto(200,100)
square.goto(200,200)
square.goto(100,200)
square.goto(100,100)
triangle = turtle.clone()
triangle.shape("triangle")
triangle.penup()
triangle.goto(-100,100)
trian... |
0454437f1b0be23ba50a1f18a4e5380e37bce477 | galactocalypse/python | /Unit4/sol17.py | 784 | 3.609375 | 4 | # Problem17: Lycherel Numbers
def is_pal(z):
s = str(z)
for i in range(len(s)>>1):
if s[i] != s[len(s) - 1 - i]:
return False
return True
def reverse(ss):
s = str(ss)
r = ""
for i in range(len(s)):
r = s[i] + r
return r
def add(x):
y = reverse(str(x))
return int(x) + int(y)
def is_prob_lych(x):
c = 0
... |
6c6e520e30b7f29d21f09d0aa5bab369792b973f | galactocalypse/python | /Unit2/sol7.py | 284 | 3.65625 | 4 | # prob7: MacArthur
month = int(raw_input('enter your birth month[1 for Jan, 2 for Feb and so on]: '))
age = int(raw_input('enter your age: '))
x = (2*month + 5)*50 + age - 365
print 'Special number: ', x
x += 115
na = x % 100
x /= 100
nm = x%10
print 'Age: ', na
print 'Month: ', nm
|
5716c6c384e7e1e63245a4f2627d9c35b81f856b | M-Lambda/Intro-Python-II | /src/adv.py | 5,568 | 3.515625 | 4 | from room import Room
from player import Player
from item import Item
# Declare all the rooms
room = {
'outside': Room("Outside Cave Entrance",
"North of you, the cave mount beckons"),
'foyer': Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east."""... |
4235257b90ca960999d780a44b1f7af7607b8fc8 | cyberchaud/automateBoring | /vid04/vid04.py | 1,183 | 4.1875 | 4 | # pythontutor.com/visualize.html
# Indentation in Python indicates a block of code
# Blocks start where the indentation begins and the block stops where the indentation stops
# if block statements are conditions/expressions
# if the condition evaluates to true; then Python executes the indented code
name = 'Bob'
if ... |
8189b5b2488e0f5f91a999c449089c618a576196 | cyberchaud/automateBoring | /vid22/vid22.py | 1,572 | 4.28125 | 4 | #! /usr/bin/python3
def isPhoneNumber(text):
if len(text) != 12:
return False
for i in range(0,3):
if not text[i].isdecimal():
return False
if text[3]!= '-':
return False
for i in range(4, 7):
if not text[i].isdecimal():
return False
if te... |
f407e16b8c2485680862c746d272b752b0d77eb5 | cyberchaud/automateBoring | /vid01/vid01.py | 601 | 4.28125 | 4 | # Python always evaluates down to a single value.
# Integers are whole number
# Any digits with a decimal is a floating point
# Expresssions are made from Values and Operators
print("Adding")
print(2+2)
print("Substraction")
print(5-3)
print("Multiplication")
print(3*7)
print("Division")
print(21/7)
print("PEMDAS")
... |
5d2d185cb12558f86348b9ec1f0234af2cd5d17b | Samrudhi-Kaware/Data-Wrangling | /dataenrichment.py | 1,016 | 3.796875 | 4 | import pandas as pd
import numpy as np
def function1():
df = pd.read_csv('employees.csv')
print(df.Salary)
# add new column
df['NewBonus'] = df.Salary * 0.10
df['Dummy'] = 0
print(df.head())
# function1()
def function2():
df = pd.read_csv('employees.csv')
... |
d4fe9d6b63145fa8c0a99e079c9ff9dee7cdb3d2 | vevanonarain/Properties-of-Normal-Distribution | /Properties of Normal Distribution/mathScore.py | 1,445 | 3.5 | 4 | import random
import statistics
import pandas as pd
import plotly.figure_factory as ff
df = pd.read_csv("StudentsPerformance.csv")
mathScore = df["math score"].tolist()
mean = sum(mathScore)/len(mathScore)
median = statistics.median(mathScore)
mode = statistics.mode(mathScore)
std_dev = statistics.stdev(ma... |
9b016ea1eb2c7c6c941c7c796ff73edf8473a095 | Ifyokoh/30-Days-of-Code | /Day 5 - Loops.py | 434 | 3.875 | 4 | # Task
# Given an integer, n, print its first 10 multiples. Each multiple n x i(where 1 <= i <= 10)
# should be printed on a new line in the form: n x i = result.
#import math
import os
import random
import re
import sys
if __name__ == '__main__':
n = int(input())
i = 0
for i in rang... |
c7620f801235036ff39b70cf3d65f99efefe668e | hluculent/GetAJob | /Algorithm/LinkedList/printListReversly.py | 781 | 3.96875 | 4 | # -*- coding:utf-8 -*-
"""
输入一个链表,从尾到头打印链表每个节点的值。
输入描述:
输入为链表的表头
输出描述:
输出为需要打印的“新链表”的表头
"""
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# 返回从尾部到头部的列表值序列,例如[1,2,3]
def printListFromTailToHead(self, listNode):
# write code here
... |
b9f0b4515788024742ae2824cc348362debcd97c | hluculent/GetAJob | /Algorithm/Array/rotateArray.py | 1,122 | 3.78125 | 4 | # -*- coding:utf-8 -*_
"""
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。
输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。
例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。
NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。
"""
class Solution:
def minNumberInRotateArray(self, rotateArray):
# write code here
if not rotateArray:
return 0
... |
df74651f44a1374cda21052688d39d00e31ce2fa | hluculent/GetAJob | /Algorithm/Stack&Queue/IsPopOrder.py | 959 | 3.671875 | 4 | # -*- coding:utf-8 -*-
"""
栈的压入、弹出序列
输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。
例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。
(注意:这两个序列的长度是相等的)
"""
class Solution:
def IsPopOrder(self, pushV, popV):
if not pushV or len(pushV) != len(popV):
return Fals... |
39fd4408e5eb5194794bb0b032f7105834b17014 | hluculent/GetAJob | /Algorithm/Array/reOrderArray.py | 763 | 3.859375 | 4 | # -*- coding:utf-8 -*-
"""
调整数组顺序使奇数位于偶数前面
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,
使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,
并保证奇数和奇数,偶数和偶数之间的相对位置不变。
"""
class Solution:
def reOrderArray(self, array):
# write code here
# 相对位置不变,就不能使用两头换的方法了
odd = []
even = []
for num in array:
if ... |
6315d4737ef579420ca2beb45043b8a821b002c9 | hluculent/GetAJob | /Algorithm/Array/NumberOf1Between1AndN.py | 721 | 3.609375 | 4 | # -*- coding:utf-8 -*-
"""
整数中1出现的次数(从1到n整数中1出现的次数)
"""
# class Solution:
# def NumberOf1Between1AndN_Solution(self, n):
# # write code here
# if n <= 0:
# return 0
# count = 0
# for ele in range(1,n+1):
# while ele:
# if ele%10 == 1:
# ... |
3016fc945b0dd546bce6898886602e8bbbce5433 | hluculent/GetAJob | /Algorithm/Stack&Queue/LastRemaining_Solution.py | 1,424 | 3.84375 | 4 | # -*- coding:utf-8 -*-
"""
孩子们的游戏(圆圈中最后剩下的数
每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此。
HF作为牛客的资深元老,自然也准备了一些小游戏。其中,有个游戏是这样的:
首先,让小朋友们围成一个大圈。然后,他随机指定一个数m,让编号为0的小朋友开始报数。
每次喊到m-1的那个小朋友要出列唱首歌,然后可以在礼品箱中任意的挑选礼物,并且不再回到圈中,
从他的下一个小朋友开始,继续0...m-1报数....这样下去....直到剩下最后一个小朋友,
可以不用表演,并且拿到牛客名贵的“名侦探柯南”典藏版(名额有限哦!!^_^)。
请你试着想下,哪个小朋友会得到这份礼品呢?(注... |
194c8ed7a0955ace19efd23177f42d77d05f8168 | hluculent/GetAJob | /Algorithm/bit operation/Numberof1.py | 1,577 | 3.578125 | 4 | # -*- coding:utf-8 -*-
"""
输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。
"""
class Solution:
def NumberOf1(self, n):
# write code here
# 变成2进制,用位运算
# 32位python中Int类型占32位
ans = 0
for i in range(32):
if n & (1<<i):
ans += 1
return ans
# 运行超时:您的程序未... |
25c4120593a234b796a042f0250d29df453c6513 | bwold001/Python | /bounce.py | 1,043 | 3.828125 | 4 | # /usr/bin/env python3
# Bezawit Woldegebriel
# 30 bouncing balls
from random import *
from graphics import*
class Ball:
def __init__ (self, win):
self.dx = randrange(1,5)
self.dy = randrange(1,5)
c1 = Circle(Point(randrange(win.getWidth()),
randrange(win... |
5ee330bb37a38a54362a2b7ba05239bd44111785 | bwold001/Python | /GPA Calculators/simplegpacalc.py | 1,072 | 3.84375 | 4 | #! /usr/bin/env python3
# Bezawit Woldegebriel
# Simple GPA calculator
def main ():
infile = open('grades.txt','r')
totcredhrs = 0
totclasspt = 0
for line in infile:
letgrade, credit = line.split()
credit = int(credit)
... |
4b53ee4e9f50400aa0f5c81336f3ea390b957868 | rrrbba/Sprint-Challenge--Hash-BC | /hashtables/ex1/ex1.py | 1,349 | 3.6875 | 4 | # Hint: You may not need all of these. Remove the unused functions.
from hashtables import (HashTable,
hash_table_insert,
hash_table_retrieve)
def get_indices_of_item_weights(weights, length, limit):
ht = HashTable(16)
"""
Finds two items whose sum of we... |
26c32a1a72db4c7f5999195ac9b3af2b90ea431c | Vijayaswarnamalya/malya | /h_11.py | 185 | 3.671875 | 4 | input_string=input().split(" ")
def rever(strings):
return [x[::-1] for x in strings]
list1=[]
list1=rever(input_string)
s=[str(i) for i in list1]
result=" ".join(s)
print(result)
|
8d6a6daf5a2808845ea1890d331603b9746a1dd7 | krausce/Integrify | /num_base_converter.py | 7,280 | 3.765625 | 4 | '''
Author: Chris Kraus
Input: A number formatted for the input number's base, the initial base,
and output base. Output: A string representative of a number converted
to the expected output base.
'''
import numpy as np
HEX_NUMS = {'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5',
'6': '6', '7': ... |
3b06c59a64a82f7fbaa7eeba84c04c2dc020568c | krausce/Integrify | /WEEK_1/Question_4.py | 1,954 | 4.125 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 6 01:24:18 2019
@author: chris
"""
'''
Question 4 asked us to write a function which looks through a list of int's
and returns '1' if a triplet exists and 0 if not.
My approach to this was to first sort the list using the builtin pyth... |
6d7f10ae288566f254e3eb53f2e8137b36a74216 | Naffsisky/Program-Permutasi | /Permutasi.py | 1,492 | 3.734375 | 4 | # Nama : Prinafsika
# NIM : 21081010278
#module
from itertools import permutations
import pyfiglet
intro = pyfiglet.figlet_format("Permutasi", font = "standard")
intronama = pyfiglet.figlet_format('By : Naff', font = "slant")
#user input + penghitungan
print(intro)
print(intronama)
prin... |
fe22ab33e33de67fa988d00f00d58eeb0bb8cb9d | neelima-j/MITOpenCourseware6.0001 | /ps1c.py | 1,967 | 4.3125 | 4 | '''
To simplify things, assume:
1. Your semiannual raise is .07 (7%)
2. Your investments have an annual return of 0.04 (4%)
3. The down payment is 0.25 (25%) of the cost of the house
4. The cost of the house that you are saving for is $1M.
You are now going to try to find the best rate of savings to achieve a down... |
4ab40a832c4ea5789d7193e627e688aed724ad0c | Treehole/PAT | /1003.py | 829 | 3.515625 | 4 | # _*_ coding: utf-8 _*_
__author__ = 'Treehole'
__date__ = '2019/5/13 20:17'
import re
num = int(input())
for i in range(num):
string = input()
if string == 'PAT':
print('YES')
else:
try:
a = re.match('(.*?)P', string).group(1)
b = re.match('.*?P(.*?)T', string).gro... |
3da0955a9f50d7cc00b6f3ef1e9b43605cb7d851 | wangweiran0129/EPFL_Machine_Learnng_Project1_Submission | /run.py | 4,230 | 3.609375 | 4 | # -*- coding: utf-8 -*-
# The following two packages are the only required ones used for model calculation
import numpy as np
from numpy.lib.function_base import gradient
from proj1_helpers import *
from implementations import *
from cross_validation import *
# main is used for test here
def main():
# choose meth... |
25d5e2eadfee3802240a12f49265767dc406ce5d | jgrushack/Byte-Academy-Projects | /Card-Project/Deck.py | 825 | 3.671875 | 4 | import random
from Card import Card
class Deck():
"""docstring for Deck"""
def __init__(self):
self.cards = []
for suit in range(0,4):
for value in range(0,13):
card = Card(suit, value)
self.cards.append(card)
def __str__(self):
ret =[]
for card in self.cards:
print(str(card))
return '\n'.... |
f72142bae21492da9a5ec6e43749b4cc08fa52d3 | skgbanga/AOC | /2020/3/solution.py | 436 | 3.609375 | 4 | import math
grid = [line.strip() for line in open('input').readlines()]
def traverse(right, down):
R = len(grid)
C = len(grid[0])
trees = 0
r, c = 0, 0
while r < R:
if grid[r][c] == '#':
trees += 1
r += down
c += right
c %= C
return trees
# print(tr... |
688a86a0c615c1105bd842df4d7dfff998716266 | skgbanga/AOC | /2019/1/solution.py | 377 | 3.984375 | 4 | nums = [int(line.strip()) for line in open('input').readlines()]
# Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.
s = 0
for num in nums:
while True:
num = num // 3 - 2
if... |
361b4561b6a87cba7a2b35a603e86f04274e94bc | skgbanga/AOC | /2020/23/solution.py | 1,899 | 4.40625 | 4 | # The crab picks up the three cups that are immediately clockwise of the current cup. They are removed from the circle; cup spacing is adjusted as necessary to maintain the circle.
# The crab selects a destination cup: the cup with a label equal to the current cup's label minus one. If this would select one of the cups... |
082b8604cd469decdb2c83c9715340dbae49735f | sun1534/pyspider | /script/itertoll.py | 469 | 3.78125 | 4 | # -*- coding: utf-8 -*-
import itertools
def main():
I = ['1','2']
J = ['spades', 'hearts']
K = ['3','4']
list_all = (list(itertools.product(I,J,K)))
list_result =[]
for i in range(len(list_all)):
dic = {}
dic['first'] = list(list_all[i])[0]
dic['second'] = list(list_a... |
bf1367ac341d8594bd2758475e4217bfc4d1c0a7 | mdiazv/codejam | /2009/1c/b-center-of-mass/center.py | 1,123 | 3.546875 | 4 | import math
class Vector:
def __init__(self, x, y, z):
self.x, self.y, self.z = x, y, z
def _add(self, other):
self.x += other.x
self.y += other.y
self.z += other.z
return self
def add(self, other):
return Vector(self.x + other.x, self.y + other.y, self.z + ... |
aa98a03245e9113479016c305ecbcbb1849863e6 | ddsnowboard/CodeEval | /Challenge19/main.py | 208 | 3.5 | 4 | from sys import argv
with open(argv[1], 'r') as f:
for i in f:
num, p1, p2 = (int(p) for p in i.split(","))
if (num & 2**(p1-1) == 0) == (num & 2**(p2-1) == 0):
print('true')
else:
print('false') |
d53d079e9e7be0e1d72e317cd090f82d7520861c | ann-ko/Python | /Lesson2_Task3.py | 1,386 | 4.21875 | 4 | while True:
month = int(input("Введите номер месяца в виде целого числа от 1 до 12: "))
if month in range(1, 13):
break
else:
print("Номер введен некорректно - повторите ввод")
# наименования времен года закодируем, чтобы в случае переименования изменяли в одном месте а не во всем ко... |
018c1294c2c4cadcb47219baaa4f325b6b1893c6 | ann-ko/Python | /_6.py | 337 | 3.8125 | 4 | start = int(input("Укажите количество КМ за первый день >>> "))
goal = int(input("Укажите желаемое количество КМ >>> "))
day_counter = 1
while start < goal:
day_counter += 1
start += start * .10
else:
print(f"День достижения = {day_counter}") |
891c4f8c7b6e238686e43e4e637f988f4c5652b5 | RavensbourneWebMedia/Ravensbourne | /mymodule.py | 1,210 | 4.625 | 5 | ## mymodule: a module containing functions to print a message, convert temperatures and find the 3rd letter of a word ##
# INSTRUCTIONS
# Write code for the three functions below:
# This function should use 'raw_input' to ask for the user's name, and then print a friendly message including
# the user's name to the co... |
802633eb618f859dffe9b5bcc43862471cac1191 | simatei/CS-problems | /fibonacci3.py | 206 | 3.8125 | 4 | # Fibonacci with automatic memoization
from functools import lru_cache
@lru_cache(maxsize = None)
def fib3(n: int) -> int:
# base case
if n < 2:
return n
return fib3(n-1) + fib3(n-2)
|
1118075a197557b0db72c88f96d510d0f1ceb9db | Waqas-Ali-Azhar/code_challenges | /leetcode/maximum-depth-of-binary-tree.py | 728 | 3.890625 | 4 | #https://leetcode.com/problems/maximum-depth-of-binary-tree/
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
depth = 0;
def getDepth(self,root,depth):
... |
3bc22bead890d715639381d331db145dd9356c1d | Waqas-Ali-Azhar/code_challenges | /general data structures/binary-tree.py | 1,026 | 3.96875 | 4 | class Node():
def __init__(self,data):
self.data = data;
self.left = None
self.right = None
class BinaryTree():
def __init__(self):
self.head = None
self.root = None
def addNode(self,data):
new_node = Node(data)
if self.head is None:
self.head = new_node
self.root ... |
2780ad343c757e6794a654f4537ea7757087f94f | Zooeee/travel_planner | /backend/auto_complete_flight.py | 512 | 3.6875 | 4 | import json
import requests
'''
The function returns the IATA codes for the corresponding
'''
def main():
city = raw_input("city")
codes(city)
def codes(city):
url = "https://api.sandbox.amadeus.com/v1.2/airports/autocomplete?apikey=mbZfPQ5trh2G97whOJeTxGwB5MiHkkoV&term=" + city
response = requests.get(url)
par... |
035a7ff57b6bf3cf9dbff0ce0fcfad79149c2ad9 | Mahany93/PythonStudyNotes | /Loop_Advanced_Dict.py | 950 | 3.53125 | 4 | ##########################################
#--------------Advanced-Loop-------------#
##########################################
# # Dictionary
mySkills = {
"HTML": "90%",
"CSS": "60%",
"PHP": "70%",
"JS": "80%",
"Python": "85%"
}
# print(mySkills.items())
# # First Method
# for skill in mySkills:... |
9a1e80ba82d91034985d641f7aae453352f77edb | Mahany93/PythonStudyNotes | /Decorators.py | 1,314 | 4.0625 | 4 | #################################################
#-------------------Decorators------------------#
#################################################
# def myDecorator(func): # Decorator
# def nestedFunc():
# print("Before Decoration")
# func()
# print("After Decoration")
# return nest... |
cd6cce873ab055a9a317c71dd51d5f589cc64b3c | Girbons/LearnPythonTheHardWay | /ex4.py | 539 | 3.515625 | 4 | my_name='Alessandro'
my_age=16
my_height=183#cm
my_weight=74#kg
my_eyes='black or brown'#i don't know
my_hair='black'
my_teeth='white'
print "let'stalk about %s"%my_name
print "he's %d inches tall"%my_height
print "he's %d pounds heavy"%my_weight
print "actually thats's not too heavy"
print "he's got %s eyes and%s hai... |
41d8cb734adbac98b519ec864113b49c162bb810 | narckot/CALCULATOR_V2 | /calculator.py | 1,232 | 4.0625 | 4 | from repeat import repeat
def add(number_1, number_2):
return number_1 + number_2
def sub(number_1, number_2):
return number_1 - number_2
def div(number_1, number_2):
return number_1 / number_2
def mul(number_1, number_2):
return number_1 * number_2
OPERATION = {
'+': add,
'-': sub,
... |
91a24306c5e80512f20679dc5ba6d84e5ab97fca | Rebecca-Simms/Python-MIT-Problems | /Problem-Set-4/test2.py | 3,367 | 4.375 | 4 | import string
def load_words(file_name):
'''
file_name (string): the name of the file containing
the list of words to load
Returns: a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this function may
take a while to finish.
'''
print("Loading word list fro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.