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 |
|---|---|---|---|---|---|---|
531389502dac8cacf8f628a76453a2760f6d51d7 | ningshengit/small_spider | /PythonExample/PythonExample/菜鸟编程网站基础实例/Python 翻转列表.py | 410 | 4.1875 | 4 | 实例 1
def Reverse(lst):
return [ele for ele in reversed(lst)]
lst = [10, 11, 12, 13, 14, 15]
print(Reverse(lst))
实例 2
def Reverse(lst):
lst.reverse()
return lst
lst = [10, 11, 12, 13, 14, 15]
print(Reverse(lst))
实例 3
def Reverse(lst):
new_lst = lst[::-1]
re... |
42912022fbc9cb00f9ee3721a18434e955d46f69 | ningshengit/small_spider | /PythonExample/PythonExample/菜鸟编程网站基础实例/Python 将列表中的指定位置的两个元素对调.py | 822 | 4.125 | 4 | 实例 1
def swapPositions(list, pos1, pos2):
list[pos1], list[pos2] = list[pos2], list[pos1]
return list
List = [23, 65, 19, 90]
pos1, pos2 = 1, 3
print(swapPositions(List, pos1-1, pos2-1))
实例 2
def swapPositions(list, pos1, pos2):
first_ele = list.pop(pos1)
se... |
154a9ec48a29f5356fb9269de54e25ace806b3dd | jbkornegay/Hello-Git | /Budget.py | 1,705 | 3.8125 | 4 | class Category:
# constructor
def __init__(self, category, amount):
self.category = category
self.amount = amount
# methods
def deposit(self, amount):
self.amount += amount
return "You have successfully deposited $%.2f in %s budget." %(amount, self.category)
def ba... |
2f73af58786062b14ef82eb8a292ded9fdee011c | merdey/Project-Euler | /29.py | 211 | 3.84375 | 4 | '''
How many distinct terms are in the sequence generated by a^b for 2 <= a <= 100 and 2 <= b <= 100?
'''
res = set()
for a in range(2, 101):
for b in range(2, 101):
res.add(a ** b)
print len(res) |
15cefad5d0f7a8aad29c1c7cb0fa3923a261c2e9 | merdey/Project-Euler | /30.py | 584 | 4.09375 | 4 | '''
Surprisingly there are only three numbers that can be written as the
sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44
As 1 = 14 is not a sum it is not included.
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
Find the sum of all the numbers ... |
983340456cdb05fddb95ec68743db043dba3f27d | merdey/Project-Euler | /3.py | 614 | 3.671875 | 4 | '''
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
'''
primes = [2]
def factor(n):
factors = []
while max(primes) < n:
p = primes[-1]
while n % p == 0:
n = n / p
factors.append(p)
generateNextPrime(... |
f1c7b8baa085363cd5ecb0390275300dbc658e49 | JaninePrukop/Work-Stuff | /Python Programs/Automation Programs/CompLinksFromNames.py | 2,643 | 3.640625 | 4 | """
Written by Janine Prukop
Header needed (Order matters):
Company Name, Company URL
This will take a list of company names from a .csv file and return an output file that adds the found urls.
It will ask what what file to read out of and if you want to leave any existing websites.
This program requires chomedr... |
7086501b77df2459bb92bbaa87025df6825f0d69 | JaninePrukop/Work-Stuff | /Python Programs/Automation Programs/validateBundle.py | 4,045 | 3.71875 | 4 | """
# Original Author Kaleb Moore
# Edits by Janine Prukop
# Date last modified 7-15-2019
This program does not run on its own, it is required for emailcheck.py
"""
from validate_email import validate_email
import re
import time
def permute(first_name, last_name, domain):
# Permutes potential email addresses
... |
0c98aecf543889b9c73f73b014508a184b0507e2 | Tower5954/Instagram-higher-lower-game | /main.py | 1,790 | 4.21875 | 4 | # Display art
# Generate a random account from the game data.
# Format account data into printable format.
# Ask user for a guess.
# Check if user is correct.
## Get follower count.
## If Statement
# Feedback.
# Score Keeping.
# Make game repeatable.
# Make B become the next A.
# Add art.
# Clear screen between rounds.... |
acf01d218a2045c829d6a0f570c925e0ae0739a8 | QQbp/pygame | /begals try.py | 5,487 | 3.859375 | 4 | ##IndexError: list index out of range <<<1.可能是因為我們給的INDEX太短,而程式裡寫得太長 2.也可能是因為我們要的INDEX裡沒東西
import random
import math
import time
def gotquestion():
question=random.randint(100,1000)
return question
##str = raw_input("please input the number:")
##if str.isdigit():
def separatenumber(number):
#print(number... |
565f280d7794b4410ed9b168fc16035f1ed3993f | avalonsolutions/avalonx-stockpriceprediction | /model/randomwalk_process.py | 13,418 | 3.65625 | 4 | #!/usr/bin/env python3
import sys
import argparse
import pandas_datareader as web
# import pandas
import numpy
import csv
import math
import time
import logging
from random import randint
logging.basicConfig(filename='./model_test.log', datefmt='%m/%d/%Y %I:%M:%S %p',
level=logging.DEBUG,
... |
707a1f5b4cb2479d668487151c813a527c27f42b | IceMage144/Algorithms | /Collatz/ConjectureV2/mathLib.py | 3,322 | 3.84375 | 4 | def get_factors(num):
factor = 2
array = []
while num != 1:
while num % factor == 0:
num //= factor
array.append(factor)
factor += 1
return array
def even_rule(num):
return num // 2
def odd_rule(num):
return 3 * num + 1
def iterated_collatz(num):
wh... |
80ac17949c445619dda20aa217ae6a7158b014ce | wz33/MagicNumber | /magic_number.py | 1,761 | 4.3125 | 4 | from builtins import input # for handling user input gracefully in Python 2 & 3
#!/usr/bin/env Python3
# Python 2 & 3
"""
Program generates a random number between 1 and 100, inclusive. User has five attempts to correctly guess the number.
"""
# Import Python module
import random # for "magic" number generatio... |
45deabdc34da826aa541ec4318812277a9cd94ae | Angad02/LC_questions | /LC_questions.py | 51,839 | 3.90625 | 4 | # Top N Buzzwords
class Solution:
def topNBuzzWords(self, numToys, topToys, toys, numQuotes, quotes):
# Base case: if toys list is empty or quotes list is empty, the output list should also be []
if not toys or not quotes:
return []
# Base case: if topToys are 0, that means we ... |
bea93cce6d9b1fb3198a91555a6d30e5be3d3e6f | amir-mersad/number-guess | /guess.py | 911 | 4 | 4 | #!/usr/bin/env python3
# Created by Amir Mersad
# Created on September 2019
# This program is a number guessing game
from random import randint
class number:
def __init__(self):
self.random_number = randint(1, 65500)
self.user_number = 0
def game(self):
while True:
self.... |
f7deed66ee60a23cbeaf6119fa2f1e4d3ebf0a9a | NamJinWoo/Python-Study | /ex03.py | 67 | 3.609375 | 4 | num = 11
if num<10:
print("smaller")
else:
print("bigger")
|
6dea378a3d0caad45614a2e9311f713d5f01c177 | moncadacrear/Dojo_assignments | /python_stack/functions_folder/function_inter1.py | 486 | 4.03125 | 4 | import random
def randInt( min = 0 , max = 100 ):
for min in range (max):
num = random.random()*max
return round(num)
# print(randInt()) # should print a random integer between 0 to 100
# print(randInt(max=50)) # should print a random integer between 0 to 50
# print... |
eae0d8785182d6fc598e91f7f1aff2a82e820e0a | psychehose/Programmers | /Level_2/문자열압축/main.py | 2,027 | 3.546875 | 4 | # This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
def solution(s):
str_len = len(s)
max_slice = round(str_len / 2)
final = s
for length in range(1, max_slice + 1):
... |
8d56284d45480737b0b2cd79d8c2358355828f8b | zahidkhawaja/cs-module-project-iterative-sorting | /src/iterative_sorting/iterative_sorting.py | 1,989 | 4.375 | 4 | # Runtime complexity: O(n ^ 2) - Quadratic
# Nested for-loop
def selection_sort(arr):
# loop through n-1 elements
for i in range(0, len(arr) - 1):
cur_index = i
smallest_index = cur_index
# TO-DO: find next smallest element
# (hint, can do in 3 loc)
for x in range(cur_ind... |
423edcefd0a82a56f398e3ce006bc9e4cc0ba123 | HybridSystemsLab/CrazyFlieAvoidanceExperiment | /cost.py | 368 | 3.578125 | 4 |
import numpy as np
# calculates the sum of costs across N points on the trajectory
def costSum(l, p, N):
totalCost = 0
for i in range(0, N):
totalCost = totalCost + cost(l[i][:], p.tolist())
return totalCost
# cost function - distance from point to target point
def cost(xi, p):
cost = np... |
4336e31db35d2afb26410e9f9d7a1111974644f1 | Luigiar10/holbertonschool-higher_level_programming | /0x03-python-data_structures/10-divisible_by_2.py | 217 | 3.953125 | 4 | #!/usr/bin/python3
def divisible_by_2(my_list=[]):
list_new = []
for i in my_list:
if i % 2 == 0:
list_new.append(True)
else:
list_new.append(False)
return list_new
|
54dde7561bb2c3ef7fab4db446088c997c168037 | ZhaohanJackWang/me | /week3/exercise3.py | 2,448 | 4.40625 | 4 | """Week 3, Exercise 3.
Steps on the way to making your own guessing game.
"""
import random
def check_number(number):
while True:
try:
number = int(number)
return number
except Exception:
number = input("it is not number plz enter again: ")
def check_upper(upper, low):
upper = check_n... |
810e9765bbd716871a7524d6647800ec0301ed45 | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /week 1/turtle_5.py | 251 | 3.59375 | 4 | import turtle
wn=turtle.Screen()
wn.bgcolor("lightblue")
t1=turtle.Turtle()
t1.color("blue")
t1.shape("turtle")
dist=5
t1.up()
for i in range(60):
t1.stamp()
t1.forward(dist)
t1.right(24)
dist=dist+2
wn.exitonclick()
|
69d705b017380b3127c4c7cfda8636c3d8c16e3d | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /week 4/ALIASING.py | 636 | 4.21875 | 4 | list1=[10,20,30]
list2=[10,20,30]
#CHECKING WHETHER THE TWO LISTS ARE SAME OR NOT.
print(list1 is list2)
#CHECKING THE IDS OF THE TWO LISTS.
print('THE ID OF list1 is',id(list1))
print('THE ID OF list2 is',id(list2))
#CHECKING WHETHER THE LISTS ARE EQUIVALENT OR NOT.
print(list1==list2)
#--------AL... |
e8775aa08f5fe1084f28736705a7a3a7579a2621 | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /Python Classes and Inheritance/week 1/DEFINING A CLASS.py | 226 | 3.703125 | 4 | #=================DEFINNING A CLASS==============================================
class point: #DECLARED A CLASS
pass
point1=point()
point2=point()
point1.x=10
point2.x=5
print(point1.x)
print(point2.x)
|
7d4a471478b43d0a6e95512e1b03c7d184a99729 | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /week 3/character counting.py | 205 | 4.03125 | 4 | #NUMBER OF CHARACTERS IN A STRING(ONLY SPACES WIL BE NEGLECTED)
line="Hey there! life is awesome."
total=0
for _ in line:
if _ !=' ':
total=total+1
print('Total characters =',total)
|
b5278bb8872dd0ad65f8cc46180085c42e9fcdc0 | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /week 2/indexing.py | 204 | 4.46875 | 4 | #STRING AND LIST INDEXING
st="SMARTPHONE"
list1=['moto','mi','nokia','samsung']
#PRINTING THE LIST IN REVERSE ORDER
print(list1[-1::-1])
#PRINTING THE STRING IN REVERSE ORDER
print(st[-1::-1])
|
b259e685aef03dabe48233184d84bd228beac2a9 | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /PYTHON FUNCTIONS FILES AND DICTIONARIES/week 4/ADDITION OF AS MANY NUMBERS AS POSSIBLE.py | 263 | 4.5 | 4 | #PROGRAM TO ADD AS MANY NUMBERS AS POSSIBLE. TO STOP THE ADDITION ENTER ZERO.
#THIS KIND OF LOOP IS ALSO KNOWN AS LISTENER'S LOOP.
SUM=0
number=1
while number!=0:
number=int(input('Enter a number to add-'))
SUM=SUM+number
print('The sum =',SUM)
|
ca0a7ee0294a77402a773cd3e928cdf7d2e075b6 | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /week 4/NON MUTATING METHODS OF STRINGS.py | 499 | 4.1875 | 4 | #NON MUTATING METHODS OF STRINGS
# 1.UPPER METHOD
s=' souradeep is an engineer '
print(s.upper())
# 2.LOWER METHOD
s2=' SOURADEEP IS AN ENGINEER. '
SS=s2.lower()
print(SS)
#3. COUNT METHOD
c=s.count('e')
print('THE TOTAL NUMBER OF "e"',c)
#4. STRIP METHOD
print('***'+s.strip()+"***")
... |
28eab86e7ae9182d4d79bd829292c0d0896c72fb | SOURADEEP-DONNY/PYTHON-3-PROGRAMMING | /PYTHON FUNCTIONS FILES AND DICTIONARIES/week 1/READING A CSV FILE.py | 364 | 3.515625 | 4 | # READING A CSV FILE
f=open('PLAYERS.CSV','r')
print(f.read())
f.close()
print('\n\n\n')
#SPLITTING THE CONTENTS OF THE FILES LINE BY LINE
f=open('PLAYERS.CSV','r')
print(f.readlines())
f.close()
print('\n\n\n')
#SPLITTING EACH WORD LINE BY LINE.
with open('PLAYERS.CSV')as p:
for i in p:
... |
b8c1a71328b8bbee9df43d97f9227da11319d099 | itsmegatunger/TimYTuong | /YTSTcrawler/writingToFile/write.py | 368 | 3.546875 | 4 | import csv
import traceback
def writingToFile(self, ideas):
try:
filename = self.nameFile
with open(filename, 'a') as f:
w = csv.DictWriter(f, self.fieldsname)
for idea in ideas:
w.writerow(idea)
except Exception:
print('Error occurred while writi... |
efffd756652aa5ab72b3db2acc25ebcfa9a26dc6 | shivanand3939/Algorithms | /MinimalMovesToString.py | 854 | 3.78125 | 4 | #https://practice.geeksforgeeks.org/problems/minimal-moves-to-form-a-string/0
from collections import deque
test_size = input(" Enter the size of Test Cases ")
user_inputs = []
for i in range(int(test_size)):
user_input = input(" Enter the Test Cases ")
user_inputs.append(user_input)
for text in us... |
8cfce7d9202aa366c83d00139314c5e6ba415e54 | ransomts/Numerical-Methods | /numericalIntegration.py | 709 | 4.0625 | 4 | import math
'''
Implementation of the Trapazoid method and Simpnon's method of numerical integration.
'''
def trapezoid(f, a, b, n):
# f: continuous funciton to estimate the signed area for
# a and b: the limets of integration (with a<b)
# n: the number of subintervals desired
h = (b - a) / n
# summation form of an... |
c36f2df9e7734fe622ded0923f38d8ce116c8748 | Ryanhustler420/py_web_scrapper | /scrape_data_inside_table.py | 462 | 3.59375 | 4 | from bs4 import BeautifulSoup
html_doc = """
<!DOCTYPE html>
<html>
<head>
<title>HTML Tables</title>
</head>
<body>
<table border="1">
<tr>
<td>Row 1, Cloumn 1</td>
<td>Row 1, Cloumn 2</td>
</tr>
<tr>
<td>Row 2, Cloumn 1</td>
<td>Row 2, Cloumn 2</td>
</tr>
</table>
</body>
</html>
"""
soup = B... |
5657d7952734daebc82bfe24eb3be196ee82e22d | FukkinHikidashi/UUUwarehouse | /test_3dayslater.py | 1,025 | 4.0625 | 4 | import datetime
import calendar
# 大型連休のロジックを確認して追記したい
def threeWorkingDaysLater(n):
marineday = get_day_of_nth_dow(n.year, 7, 3, 0)
print(marineday)
m = n + datetime.timedelta(days=3)
# 土日の場合は2日すすめる
if m.weekday() in [5, 6]:
m = m + datetime.timedelta(days=2)
# 海の日連休の場合は2日すすめる
if m... |
34097097d436f0cb9c2dfeadac55f406a941ad66 | Maxkipkorir/Variable | /variables.py | 273 | 3.78125 | 4 | #A code to explain or describe variables
#An interger assignment
age= 21
houses=5
print(age , houses)
score =80
print(score)
#Float point
y=23.78
print(y)
weight=47
print(weight)
#string
x="python variables"
a=b=c=d=45.98
print(a , b , c , d)
print(x)
|
d188d7d331e2924ae008ed4d15a0b2c143696d7e | jes5802/ashburntech | /anothertest.py | 307 | 3.796875 | 4 | import math
def is_unique(s):
s = list(s)
s.sort()
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
return 0
else:
return 1
def func1(s):
return math.sqrt(s)
if __name__ == "__main__":
print(is_unique(input("Input a number ")))
print(func1(9))
|
b6d0fabe123a7ec16e84b1823ff5b6ff503fbda1 | mmars2/MH8801-G1901772B | /04/ProgramC1,C2,C3,H1.py | 2,054 | 3.59375 | 4 | #Program C1
m_list=[9,41,12,3,74,15]
min_value=None
for i in m_list:
if min_value==None:
min_value=i
continue
if i<min_value:
min_value=i
print('The list containing',m_list,'has:')
print('Minimum value:',min_value)
#Program C2
def mymin(ls):
min_value=None
for i in ls... |
93d86908c4713b74c1e5d13f8aff639c967a4e3d | olgarozhdestvina/pands-problems-2020 | /Labs/Topic03-Variables/lab03.06-‐randomfruit.py | 220 | 4.0625 | 4 | #Program that prints out random fruit
import random
fruits = ("Banana", "Apple", "Orange", "Kiwi", "Pineapple")
index = random.randint(0,len(fruits)-1)
fruit = fruits[index]
print("A Random Fruit: {}". format(fruit)) |
7e5bcef6c5fcd895064702e2b04432e03fd508ce | olgarozhdestvina/pands-problems-2020 | /Labs/Topic03-Variables/lab03.2-sub.py | 243 | 3.921875 | 4 | # This program reads in two numbers and subracts
# the first one from the second one in a string
x = int(input("Enter first number: "))
y = int(input("Enter second number: "))
answer = x - y
print("{} minus {} is {}". format(x, y, answer)) |
006875e1cc3800e781e6949b24953539c89f22b9 | olgarozhdestvina/pands-problems-2020 | /Labs/Topic03-Variables/lab03.09---dictionary.py | 182 | 4.375 | 4 | student = {
"firstname": "joe",
"lastname": "bloggs"
}
print (student)
print("The student's full name is:")
for value in student.values():
print(" => {}".format(value)) |
27d3b911284cdc52fe20d4751019fd0ee9fb84df | olgarozhdestvina/pands-problems-2020 | /Problem Set/secondstring.py | 213 | 3.9375 | 4 | # Olga Rozhdestvina
# Program that takes asks a user to input a string
# and outputs every second letter in reverse order.
s = str(input("Please input a sentence: "))
print(s[::-2]) #formula found in WhirlwindTourOfPython |
53d6f8a3a438037857021c5d2264c6817c7406a1 | olgarozhdestvina/pands-problems-2020 | /Labs/Topic09-errors/check_input.py | 417 | 4.28125 | 4 | # Olga Rozhdestvina
# a program that takes in a number as an input and subtracts 10%
# prints the result,
# the program should throw a value error of the input is less than 0
# input number
num = int(input("Please enter a number: "))
# calculate 90%
percent = 0.90 # (1- 0.10)
ans = num * percent
if num < 0:
rai... |
ede2b58122235095b0854a2c06247775bf1aaf47 | olgarozhdestvina/pands-problems-2020 | /Labs/Topic07-files/overwrite.py | 254 | 3.828125 | 4 | # Olga Rozhdestvina
# a function that takes in a number and overwrites a file with that number
filename = "count.txt"
number = int(input("enter a number: "))
def overWrite(number):
with open(filename, 'wt') as c:
c.write(str(number))
overWrite(number) |
0c36ee9c96375e33398b939d293504b3ca5bccab | scooley/teals | /debug.py | 227 | 4.03125 | 4 | str_time = input("What time is it now?")
str_wait_time = input("What is the number of nours to wait?")
time = int(str_time)
wait_time = int(str_wait_time)
time_when_alarm_go_off = time + wait_time
print(time_when_alarm_go_off) |
466305ea92b6c73bce5286d86d8afc62fbe1cbf2 | jrbublitz/Aulas-python | /exercicios/0 - PrimeiroExercicio.py | 136 | 3.78125 | 4 |
nome = input("Digite seu nome: ")
print(nome)
print("Quantidade de Letras: ", len(nome))
print("Tipo da variável: ", type(nome))
|
ad6d93d3e1a7f72bf3749244698bf8dbaa7b4399 | jrbublitz/Aulas-python | /material/0 Primeiros passos/apoio.py | 998 | 4.28125 | 4 | # Declaração de variável
x = 1
y = "Teste"
_nome = "Gustavo"
Altura = 1.8
# Eclusão de uma variável
del x
del y
del _nome
del Altura
# Declarando várias variaveis com o mesmo valor
x = y = z = "Um valor aí"
# Declarando várias variaveis com o vários valores
x, y, z = "Valor1", 2, True
# ou
x, y, z = ("Valor1", 2,... |
24d271026e3974e196af3a02db723c13546238e6 | UladzislauB/university-monorepo | /6term/OSaN/codelab6/lab_6.py | 1,141 | 3.5625 | 4 | from tkinter import Tk, Label, Button
import tkinter as tk
isOn = False
step = 1
WIDTH, HEIGHT = 500, 500
x = WIDTH / 2
y = (HEIGHT - 100) / 2
class MyFirstGUI:
def __init__(self, master):
self.master = master
master.title("lab_6")
self.greet_button = Button(master, text="Start", command... |
0ffd40a66dc66c97987c66370362e61d662bec32 | UladzislauB/university-monorepo | /7term/ISM/3/DashaExample/MZI_Lab3/main.py | 694 | 4.0625 | 4 | import rsa.rsa as rsa
def write_to_file(file_name, data):
with open(file_name, "w") as file:
file.write(str(data))
def main():
with open("files/initial.txt", "r") as file:
data = file.read()
n, e, d = rsa.make_key_pair(2048)
print(n, ' ', e, ' ', d)
encrypted_dat... |
3d94d350fe8feab3fc139a4f281f164c64ed910d | hay/codecourse | /examples/lists2.py | 249 | 3.90625 | 4 | birthdays = [
["Hay", 1983],
["Lotte", 1981],
["Jesse", 1985]
]
print birthdays[0] # ["Hay", 1983]
print birthdays[0][1] # 1983
for bday in birthdays:
name = bday[0]
year = bday[1]
print "%s is jarig in %s" % (name, year)
|
d7e9be6759cb173b56f833577204d05de105fef6 | hay/codecourse | /solutions/hay/cheatsheet.py | 7,836 | 3.921875 | 4 | # -*- coding: utf-8 -*-
# In Python begint commentaar met een hekje (#)
# Alles waar een hekje voorstaat wordt door Python overgeslagen
print "Hallo, wereld!" # Ook als het niet aan het begin van een zin staat
# De gouden tip: tik 'python' (zonder bestandsnaam) en je komt in de REPL
# Waar je dit soort dingen allemaa... |
85bb1fe7789199c56764cc8e42c056066c4fbbe2 | hay/codecourse | /solutions/erwin/opdracht06.py | 421 | 4.21875 | 4 | # -*- coding: utf-8 -*-
names = []
for name in range(3):
print name
name = raw_input("Noem een naam: ")
names.append(name)
fruit = raw_input("Vertel me je lievelingsvrucht: ")
for name in names:
if name[0].isupper():
print "Aangenaam, " + name
else:
print "Hoi " + name
print "De lettercombinatie '... |
7fdb5e7f4739524f695709b801cd5110c147079b | hay/codecourse | /solutions/lotte/7.py | 829 | 4.0625 | 4 | films = [
{
"titel" : "The Third Man",
"jaar" : 1949
},
{
"titel" : "Ace Ventura: Pet Detective",
"jaar" : 1994
}
]
titel3 = raw_input("Wat vind je een toffe film?")
jaar3 = raw_input("Uit welk jaar komt deze film?")
film3 = {}
film3["titel"] = titel3
film3["jaar"] = in... |
6409f5ccee1d11003b90f3e56e2573c7996c7bea | hay/codecourse | /solutions/lotte/h1.py | 799 | 3.671875 | 4 |
name = raw_input("Welkom bij de Swiebertje quiz! Hoe heet je?")
print "Van harte welkom, " + name + "!"
vraag1 = raw_input("Bij deze de eerste vraag: noem een willekeurig jaar waarin Swiebertje op tv was")
print int(vraag1)
if int(vraag1) >=1955 and int(vraag1) <=1975:
print "Correct"
score = score + 1
else:... |
c48d5d9e088acfed0c59e99d3227c25689d205c6 | hay/codecourse | /solutions/maarten/opdracht3.py | 159 | 3.5 | 4 | naam = raw_input("Wat is je naam?")
getal = raw_input("Geef me een getal?")
if naam == "Barrie":
print "Welkom " * int(getal)
else:
print "Helaas, tot ziens" |
ab907f02f23f3ef5122cce52a80cc8b65570509e | hay/codecourse | /solutions/nienke/opdracht7.py | 463 | 3.796875 | 4 | totaal = [
{
"naam" : "Armegeddon",
"jaar" : 1990
},
{
"naam" : "Ace Ventura",
"jaar" : 1994
}
]
list1 = {}
list1["naam"] = raw_input("welke film is jouw favoriet? ")
list1["jaar"] = int(raw_input("in welk jaar verscheen deze film? "))
totaal.append(list1)
for film in totaal:
naam ... |
a142e7901d6517a5f203c3a42783d22fc744fd40 | hay/codecourse | /examples/lists1.py | 559 | 4.21875 | 4 | names = ["Bert", "Ernie", "Pino"]
for name in names:
print "Aangenaam, " + name
print names[1] # "Bert"
print names[-1] # "Pino"
hellos = []
for name in names:
hellos.append("Hallo " + name)
for hello in hellos:
print hello
years = [1983, 1980, 1993]
for year in years:
print year
print 1983 in y... |
8d335dd4ef6447ee0d43a7d3cf5f36ecd2f5ab95 | dianaespc/EjercicioFibonacci | /Fibonacci.py | 213 | 3.59375 | 4 | # Diana Paola Espitia Carvajal - 201629290 - dp.espitia
a = 0
b = 1
c = 0
serie = [a,b]
num = int(input("Ingrese numero"))
while c < num:
c=a+b
if c < num:
serie.append(c)
a = b
b = c
print (serie)
|
2e89cd885ca414ee4e9306a14547e20443406e82 | lproctor10242/MABE-ADReSSo | /fileIO.py | 488 | 3.578125 | 4 | import csv
def readCSV(fileIn):
with open(fileIn, newline='') as csvfile:
#putting all values of the csv file into a list object
segments = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC)
seglist = []
#making a list of lists containing each row
for row in segments:
seglist.append(row)
ret... |
97b13a150ef74a7c63d5d34731d9c0b040a9bee6 | dpflann/Project_Euler | /pe45/pe45.py | 645 | 3.96875 | 4 | from math import sqrt
def is_hexagonal(N):
# 2n^2 - n - N = 0
n = (1 + sqrt(1 + 4*2*N)) / 4
return n == int(n)
def is_pentagonal(N):
# 3n^2 - n - 2N = 0
n = (1 + sqrt(1 + 4*3*2*N)) / 6
return n == int(n)
def triangular_number(n):
return int((n * (n + 1)) / 2)
def find_next_triangular_number(n):
foun... |
790d329990d4a7b6b116b239973ef4be27660614 | dpflann/Project_Euler | /pe50/pe50.py | 1,156 | 3.84375 | 4 | def primes_sieve(limit):
a = [True] * limit
a[0] = a[1] = False
for (i, isprime) in enumerate(a):
if isprime:
yield i
for n in range(i*i, limit, i):
a[n] = False
def find_upper_limit(primes):
i = 0
while sum(primes[i:i+2]) < primes[-1]:
i += 1
return i
def find_prime_comprised_... |
3db3e24fadb1abfc644a89970396ede01a4953da | dpflann/Project_Euler | /pe34/pe34.py | 1,444 | 3.984375 | 4 | #!/usr/bin/python
# -*- coding: utf8 -*-
# 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
#
# Find the sum of all numbers which are equal to the sum of the factorial of their digits.
#
# Note: as 1! = 1 and 2! = 2 are not sums they are not included.
import math as m
from matplotlib import pyplot
from ... |
ed8078db37cc38a015d14b8908d56ca4bfb88d7e | Zahidsqldba07/CodeSignal-26 | /The Core/Spring of Integration/094 - beautifulText.py | 134 | 3.546875 | 4 | def beautifulText(s, l, r):
return any(all(j==" " for j in s[i-1::i])and(len(s)-len(s[i-1::i]))%(i-1)==0 for i in range(l+1,r+2))
|
519facc5aec6b9a2ba2d928f3fa52a9205f36dfc | Zahidsqldba07/CodeSignal-26 | /Intro/Smooth Sailing/012 - sortByHeight.py | 214 | 3.609375 | 4 | def sortByHeight(a):
b = sorted([x for x in a if x != -1])
print (b)
j = 0
for i in range(a.__len__()) :
if a[i] != -1 :
a[i] = b[j]
j += 1
return a
|
4e6842d9f53c4758de4a8bdb5814dd3832d27866 | Zahidsqldba07/CodeSignal-26 | /Intro/Rains of Reason/028 - alphabeticShift.py | 151 | 3.625 | 4 | def alphabeticShift(inputString):
res = ''
for c in list(inputString) :
res += chr(97) if ord(c)==122 else chr(ord(c)+1)
return "".join(res)
|
b1acec3ae9a460a64fff34c6be76ca9b37871732 | Zahidsqldba07/CodeSignal-26 | /Python/Drilling the Lists/064 - primesSum.py | 182 | 3.59375 | 4 | def primesSum(a, b):
return sum ( [item for item in [num for num in range( a, b + 1)] if item>1 and len([i for i in range( 2, 1+int( math.sqrt(item) ) ) if item % i == 0])==0] )
|
c8024be6066756e42abd1882bb71f678313793eb | Zahidsqldba07/CodeSignal-26 | /Graphs/Contours of Everything/012 - isWheel.py | 317 | 3.828125 | 4 | def isWheel(adj):
if len([1 for i in range(len(adj)) if adj[i][i]])>0:
return False
patterns=sorted([sum([1 for j in range(len(adj)) if adj[i][j] and i!=j]) for i in range(len(adj))],reverse=True)
return patterns[0]==len(adj)-1 and len([1 for i in range(1,len(patterns))if patterns[i]!=3])==0
|
538fe285c04b99ed8e89845a17687e45694ae4b1 | Cadzman/UCDPA_GAVINCADOGAN | /Netflix finalised code.py | 4,555 | 3.5625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_columns', 12)
pd.set_option('display.width', 1000)
Netflix = pd.read_csv("ucdprojectgc/netflix_titles.csv")
Netflix_ind = Netflix.set_index(["release_year"])
print(Netflix_i... |
3dd4bb8045424272fe4f70d384c606e7440564a3 | Malon242/GenPred | /Data/Scripts/statistics.py | 1,879 | 3.765625 | 4 | #!/usr/bin/env python3
'''
This program calculates and prints statistics for the Twitter and Reddit
training, validation and test sets. The statistics contain information about
the number of rows (size) of the data sets, the number of unique users per gender
and the average length of the combined posts per gender and... |
e1b61b1c68f2b66e4cd9b5020d2ed714dbb83b53 | karunya-venugopalan/analysisOfGDPvsSocialFactors | /GDPvsSocialFactors.py | 23,062 | 3.734375 | 4 | '''Program to display the trend in various statistics as a scatter graph.
Project work done by V.Karunya and G.S.Nikkitha as part of 2nd Semester studies.
Program components
------------------
1. Data file prepartion program
- This reads the datafiles available in the public domain from the URL https://fred.st... |
dd7902e3048b7bfa2f9447a1dec2082d2b591516 | cifpfbmoll/practica-6-python-JLCardona | /E8.py | 767 | 3.578125 | 4 | from os import system
system("cls")
limite = int (input ("Dame el límite : "))
valor=int (input ("Ahora dame un valor para empezar la lista : "))
lista = []
lista.append (valor)
suma = valor
while (suma!=limite):
if (suma < limite):
valor = int (input ("Ahora dame otro valor : "))
suma = suma + valo... |
2afaaae419623c401d884b9bf03dbb86acdafac0 | prodhan/python-book-practical | /List/6_2.py | 211 | 4.0625 | 4 | # A program to print numbers in two dimensional forms
# Author: Ariful Islam
a = [[1, 2, 3, 4], [5, 6, 2], [7, 8, 9]]
for i in range(len(a)):
for j in range(len(a[i])):
print(a[i][j], end=' ')
print() |
84d7bc020795854d4c16f2aaced050be01b964a8 | prodhan/python-book-practical | /File/8_2.py | 186 | 4.0625 | 4 | # A program to read information from file
# Author: Ariful Islam
# Open a file
fo = open("example.txt", "r+")
str = fo.read(50);
print("Read String is : ", str)
# Close opened file
fo.close() |
c93ecf463802956b9a5e7656e5393bf57020ceb8 | arjun619/streamlit_app | /plotter.py | 1,058 | 3.84375 | 4 | import plotly.express as px
import pandas as pd
import streamlit as st
def bi_variate_graph(data,column_names):
column_names=tuple(column_names)
feature1=st.selectbox("Select first feature",column_names,key="selector")
feature2=st.selectbox("Select second feature",column_names,key="selector1")
flag_vi... |
3d110ca6509fdbef4d4509d5cc2c557bf4ca4060 | violenttestpen/DataStructureAlgorithms | /tests/QueueTest.py | 1,257 | 3.90625 | 4 | import timeit
list_size = 1000
number = 100
setup = f'''
import random
array = list(range({list_size}))
random.shuffle(array)
def run_queue(queue):
for i in array:
queue.enqueue(i)
for i in array:
queue.dequeue()
def run_priority_queue(queue):
for i in array:
queue.enqueue(i, i)
... |
42ab4e8a4a380ec78d9beb9ec99db394f47f6f81 | violenttestpen/DataStructureAlgorithms | /Queue/ArrayPriorityQueue.py | 970 | 3.8125 | 4 | class ArrayPriorityQueue:
def __init__(self):
self.__data = []
self.__order = []
def isempty(self):
return False if self.__data else True
def search(self, key):
return self.__data.index(key) if key in self.__data else None
def peek(self):
return self.__data... |
073b69a34fc2a7a0daaae566faad71b4812aa53d | Peter5793/alx-backend-python | /0x02-python_async_comprehension/0-async_generator.py | 377 | 3.578125 | 4 | #!/usr/bin/env python3
""" Async a generator that takes no argument"""
import asyncio
import random
from typing import Generator
async def async_generator() -> Generator[float, None, None]:
""" Generate numbers
args: void
Return:
float time random
"""
for i in range(10):
aw... |
f522ea705a61a623b7ec04dfc3163caf1b972fb3 | shubham-shar/Log-Analysis | /Log.py | 2,316 | 3.671875 | 4 | #!/usr/bin/env python2.7
import psycopg2
def log_analysis(query, string):
'''
The function takes in two parameters, one is the query to be executed and
the second one is the helper string for better formatted answer.
The function executes the query and prints the result in a formatted way.
'''
... |
326f824c5da9e3238e310bf849ed90f06c35cf90 | RaOneG/CS106A-Completionist-Files | /Section-5/stringconstruction.py | 1,964 | 4.28125 | 4 |
def only_one_first_char_new(s):
"""This function builds up a new string adding all characters in the input string except those that are
the same as the first char
>>> only_one_first_char_new('abba abba abba')
'abb bb bb'
>>> only_one_first_char_new('Stanford')
'Stanford'
>>> o... |
6ee4502584d5d20166c3378208951425eac3e729 | immanuelw/PyMegaman | /geom.py | 2,448 | 3.59375 | 4 | '''
Py6V -- Pythonic VVVVVV
geom -- Geometry
Defines the Geometry class.
Because of our simplistic world, a Geometry is a region defined by a collection
of rectangles. At any time another rectangle can be tested against it, and it
will return a dict mapping a HIT* constant to the tuple (penetration, rect),
s... |
b459c226f96305610e5c616fd1d8be19f19b9aa2 | SirMatix/Python | /MITx 6.00.1x Introduction to Computer Science using Python/week 1/Problem set 1/Problem 2.py | 361 | 4.03125 | 4 | """
Problem 2
10.0/10.0 points (graded)
Assume s is a string of lower case characters.
Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print
Number of times bob occurs is: 2
"""
count=0
for i in range(len(s)):
if s[i:i+... |
524e98dfa7805b3c42ff0c3c021510afdabeaf0a | SirMatix/Python | /MITx 6.00.1x Introduction to Computer Science using Python/week 1/Problem set 1/Problem 3.py | 1,413 | 4.15625 | 4 | """
Problem 3
15.0/15.0 points (graded)
Assume s is a string of lower case characters.
Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print
Longest substring in alphabetical order is: beggh
In th... |
ffdebe3ee68c6f90c884bebff8ddc4248de8151c | SirMatix/Python | /MITx 6.00.1x Introduction to Computer Science using Python/week 6/Problem set 6/Problem 5/search.py | 1,428 | 3.953125 | 4 | ##def search(L, e):
## for i in range(len(L)):
## if L[i] == e:
## return True
## if L[i] > e:
## return False
## return False
##
##def newsearch(L, e):
## size = len(L)
## for i in range(size):
## if L[size-i-1] == e:
## return True
## if L[i] < ... |
792c98b819b7ec4d3885ab4149a488729f78e566 | ShivamDixit478/InformationSecurityAssignment | /Ques_2.py | 4,305 | 4.25 | 4 | # Write a program that can encrypt and decrypt using the Affine Cipher.
lower_alphabet = "abcdefghijklmnopqrstuvwxyz"
upper_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# The gcd function is going to help co-prime function
def gcd(a, b):
# Everything divides 0
if (a == 0 or b == 0):
return 0
... |
25226873ff5819b1e8e7baafe917d138b19b6161 | euclude/PythonFinance | /utils/BasicUtils.py | 2,167 | 3.625 | 4 | import os, inspect
import math
import pandas as pd
def total_return(df, field=None):
'''
Calculates the total return
Parameters:
df - pandas.DataFrame or pandas.Series
field=None - optinal parameter with column name of the target
Returns:
int
'''
if field is None:
... |
32bdfb0fc4263f7ef892171adb4e9d255a7da32c | srsapireddy/Python-Practice---2019 | /Python Practice - 2019/Part One/one.py | 4,803 | 4.4375 | 4 | # Hello World
"""
print("Hello World")
print("Hello World")
print("Welcome to Edureka")
print("Happy Learning \nWelcome to Python") # New line character
"""
# ---------------------------------------------------------------
# Variables
"""
A = 10
B = "edureka!"
print(A,B)
x,y,z = 10,20,30
print(x)
print(y)
print(z)
""... |
228cf954828c32517882f1d086ae115322226fbb | ernestoacosta75/CorsoPython | /codice_sezione_PYTHON_LV_2/05_controllo_del_flusso/controllo_del_flusso.py | 330 | 3.921875 | 4 | eta = input("Inserisce l'età: ")
hai_patente = input("Hai la patente (True/False)? ")
if int(eta) >= 18 and bool(hai_patente) == True:
print("Puoi noleggiare una Ferrari!")
elif int(eta) >= 18 and bool(hai_patente) == False:
print("Niente Ferrari! Prima la patente!")
else:
print("Ne riparleremo tra qualche... |
9c2c03f066ef011dd3e12ac8b5244404ac2a9657 | ernestoacosta75/CorsoPython | /codice_sezione_PYTHON_LV_1/prova_pratica/prova_pratica_lv1.py | 343 | 3.703125 | 4 | print("Benvenuti al Programma \"Moltiplicatore\"!")
print("Restituisce in output il risultato di una moltiplicazione tra due numeri!")
primo_valore = input("Inserisce il primo valore -->")
secondo_valore = input("Inserisce il secondo valore -->")
print("Il risultato della moltiplicazione è: ", float(primo_valore) * f... |
c7bdafeb939aa2e781d6b07c8953b8dc563707a1 | ernestoacosta75/CorsoPython | /codice_sezione_PYTHON_LV_2/esercizi_pratici/fattoriale.py | 196 | 3.90625 | 4 | def fattoriale(n):
if n == 1:
return n
else:
result = n * fattoriale(n-1)
return result
num = int(8))
# num = int(input('Inserisci il numero da fattorizzare -> '))
print(fattoriale(num))
|
40204fd8f122c7c40569882845f71f04d04de79e | ernestoacosta75/CorsoPython | /codice_sezione_PYTHON_LV_2/08_la_standard_library/standard_library.py | 168 | 3.53125 | 4 | import random
from math import sqrt
from os import *
# for x in range(10):
# numero = random.randint(1, 100)
# print(numero)
print(sqrt(169))
print(getcwd())
|
d02e1ea14258a91fb4a64e8eb32406d24c87b4b0 | iamnidheesh/MyCodes | /Python-Files/comma.py | 165 | 3.796875 | 4 | def comma(b) :
for i in b :
if i==b[len(b)-1] :
print("and " +i)
else :
print(i,end=', ')
a=input()
a=a.split()
comma(a)
|
3d98365e0ba0ebbf714acc17e52c5d9b9a219e44 | iamnidheesh/MyCodes | /Python-Files/inputvalidiation.py | 396 | 4.1875 | 4 | #the Collatz sequence
def collatz(m):
if m%2==0 :
m=m//2
return m
elif m%2==1 :
m=3*m+1
return m
c=0
while c!=1 :
try :
n=int(input("Enter number :"))
c=c+1
while True :
print(n)
n=collatz(n)
if n==1 :
... |
5890aa56fda2b902c4cd294ac4b1982142699d97 | iamnidheesh/MyCodes | /Codeforces/cf_old/133-A/133-A-15442198.py | 74 | 3.875 | 4 | s=input()
print("YES" if ('H' in s) or ('Q'in s )or('9'in s) else "NO") |
362f55356e4cb49d1ab3e8ac11907bc1426c9d02 | iamnidheesh/MyCodes | /Python-Files/tableprint.py | 321 | 3.59375 | 4 | tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice','Bob','Carol','David'],
['dogs','cats','moose','goose']]
def printtable(tdata):
m=[0,0,0]
m[0]=max(len(tdata))
for i in tdata:
for j in i :
print(j.ljust(m[i]),end=' ')
print()
printtable(tableData)... |
a0506783b0b1d5b27329a19f47d050e68a112217 | htem/gunpowder | /gunpowder/morphology.py | 1,998 | 3.515625 | 4 | import numpy as np
from scipy.ndimage.morphology import distance_transform_edt
def enlarge_binary_map(
binary_map,
radius,
voxel_size,
ring_inner=None,
in_place=False):
'''Enlarge existing regions in a binary map.
Args:
binary_map (numpy array):
A matrix with zeros, i... |
f9301552d9b6ef6d5c99b43c60ca73fee68d2969 | Curso-de-Historia-Unilab-Males/urlshortner | /urlshortner.py | 416 | 3.875 | 4 | '''
Crie um encurtador de URL com Python
Author: Eric Brasil a partir do código de Ayushi Rawat
'''
# Importando o pacote
from pyshorteners import Shortener
# Definindo o link a ser encurtado
link = str(input('Insira o link a ser encurtado: '))
# Chamando o Shortener e aplicando na variável link
s = Shortener()
short... |
5600d557d505b2fb6283996edfc9c3f097174717 | banjocat/codeeval_solutions | /31/main.py | 345 | 3.515625 | 4 | import sys
def main():
with open(sys.argv[1]) as f:
for line in f:
solve(line)
def solve(line):
(word, end) = line.split(',')
letter = end.strip()
pos = -1
for x in range(0, len(word)):
if word[x] == letter:
pos = x
print(pos)
if __name__ == '... |
01040b53e133c23942a5e599f5eaa518ab1e1a83 | HarshithKulkarni/Pi-Learn-Python-Basics | /decorators.py | 653 | 3.890625 | 4 | # # Function inside function ##
# def create_adder(x):
# def adder(y):
# return x+y
# return adder
# add_15 = create_adder(15)
# print(a_15(10))
##############################
def hello_decorator(func):
def inner1():
print("Hello, this is before function execution")
... |
30c2e4f148e81fc01bae7dc436b2afcb74778dd3 | HarshithKulkarni/Pi-Learn-Python-Basics | /issubclass.py | 341 | 3.8125 | 4 | class Base(object):
pass # Empty Class
class Derived(Base):
pass # Empty Class
# Driver Code
print(issubclass(Derived, Base))
print(issubclass(Base, Derived))
dog = Derived()
bag = Base()
# b is not an instance of Derived
print(isinstance(bag, Derived))
# But d is an instance of Base
print(is... |
3baeaeb6d67740aea614653a6185c3bcf6c2e124 | jell0720/Python27_Sublime_Dondon | /src/ClassContens/firstClass/ObjectOriented.py | 1,829 | 3.796875 | 4 | #coding=utf-8
class Person():
count = 0 # Static/class variable
def __init__(self, name, city):
self.name = name # Variable for the instance
self.city = city # Variable for the instance
Person.count += 1
def number_of_persons(self):
return Person.count
p1 = Person(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.