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 |
|---|---|---|---|---|---|---|
080d28c6f1467abf777e76ac49a786b0e0055333 | chrismvelez97/GuideToPython | /techniques/functions/built_in_functions/sum.py | 478 | 4.15625 | 4 | # How to use the sum() function
'''
The sum() function adds all the numbers up from a list of numbers.
Note that for min, max, and sum, you can only do them on lists full of numbers.
also it is not a method attached to the number datatype which is why it is in
the techniques folder instead o... |
97a8074488d0ee8e03d0f1ba2e3ed725c0820691 | chrismvelez97/GuideToPython | /techniques/functions/built_in_functions/range.py | 1,471 | 4.90625 | 5 | # How to use range in python
'''
So after looking over this I really debated with myself if I should
put this under method or techniques and I ended up putting it here because,
the function doesn't execute if not in conjunction with a for loop, hence it
being a technique.
The range(start, en... |
38c5fa3b7f2798b48e0aaab62bf319f18ff2c8f9 | chrismvelez97/GuideToPython | /techniques/loops/looping_dictionaries.py | 995 | 4.5 | 4 | # How to loop Dictionaries
'''
You can loop through dictionaries but it should be noted that they will not
come out in any specific order because are not ordered by indices
'''
dictionary = {
"words": {
"penultimate": "The second to last item in a group.",
"ultimate": "The... |
3ee9a77844a39d684c92dc24a53ab189c63762de | Jakob666/merip-seqPeakMapper | /interval_tree.py | 6,260 | 3.625 | 4 | # -*- coding:utf-8 -*-
"""
@author: hbs
@date: 2018-9-27
description:
区间树算法
"""
class IntervalTree:
def __init__(self):
self.root = None
def left_rotate(self, node):
"""
红黑树的左旋,以node为支点向左旋转
:param node:
:return:
"""
assert self.root is not None and ... |
358169c174ee0c23f4f1c4eaa3c26095d963a83a | WilliamRo/greedy_snake | /Section I/step_1.py | 703 | 4 | 4 | """
If you want to create a game based on whatever programming language, you must
decide where to show your user interface. It can be on terminal (sometimes
people call it 'command line window' or 'command shell') of course, yet a
window on which we can draw whatever shape with whatever color is definitely
more prefera... |
8f85f0d385e66bf0cc1c5da7c45a65572fd9f8d1 | Liunerd/leetcode_solution | /python/075-sort_color.py | 509 | 3.578125 | 4 | class Solution:
def sortColors(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
color = [0,0,0]
for pixel in nums:
color[pixel] += 1
for i in range(len(nums)):
if color[0]:
... |
5ce845e64d5d199d6949de209eca75e023d98768 | Liunerd/leetcode_solution | /python/102-binary_tree_level_order_traversal.py | 714 | 3.71875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def levelOrder(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
if root is None... |
a1d2e7b806e029b685ad1cb15c9108cc865a8d33 | Liunerd/leetcode_solution | /python/206-reverse_linked_list.py | 575 | 3.875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reverseList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head is None or head.next is None:
... |
df5c3328e9e7caaa00ea595820ee307fb8ab485a | mccallkaley/Day-4-Homework-OOP-Shopping-Cart | /parkinglot.py | 3,372 | 3.828125 | 4 | # Your parking gargage class should have the following methods:
# - takeTicket
# - This should decrease the amount of tickets available by 1
# - This should decrease the amount of parkingSpaces available by 1
# - payForParking
# - Display an input that waits for an amount from the user and store it in a variable
# - ... |
33e159f1e225f2701870f5853d108936dae39220 | Superanjali/asl | /insert_image.py | 1,391 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 10 09:47:40 2018
@author: Home
"""
import cv2
import numpy as np
# Parameters ##############################################################
cv_blue = (255,0,0)
height = 480
width = 640
# Frame is just a black frame:
frame = blank_image = np.zeros((height,width,3), n... |
68183e79eb949d819b3e501049f8b38b0cf9be0b | akhil-2009it/python_programming | /Interview_program/factorialOfNum.py | 210 | 4 | 4 | #5 = 1*2*3*4*5 = 120
num=5
factorial = 1
if num<0:
print("No fac")
elif num==0:
print("fact is 1")
else:
for i in range (1, num+1):
factorial= factorial*i
print("fact is", factorial) |
5d78a3c2062f6fac4bfdc32fc8a6639ba17fd054 | akhil-2009it/python_programming | /Interview_program/factorialrecursive.py | 110 | 3.671875 | 4 |
def fact(n):
if(n==0 or n==1):
return 1
if n >1:
return n* fact(n-1)
print(fact(10)) |
a078fd9ceb8c8b2a792a8aff36afc770c429ced3 | NEWADS/Using-Python | /Magnet.py | 209 | 3.578125 | 4 | import clipboard as cp
maglink = input("Please type in words you think is magnet:")
tmp = "magnet:?xt=urn:btih:"
result = tmp + maglink
# try to employ clipboard function......
print(result)
cp.copy(result)
|
1276cf91b54495bf6dd99198bb97a29d98ee5ef8 | RashmiR31/Python-Projects | /URL Shortener.py | 749 | 3.5 | 4 | from tkinter import *
import pyshorteners as srt
import pyperclip
root=Tk()
root.geometry('450x350')
root.title('URL Shortener application')
def shorten():
short_url=srt.Shortener().tinyurl.short(link.get())
link.set(short_url)
pyperclip.copy(short_url)
clip.set('Copied to Clipboard'... |
c16e36cf57dcef1e363ce4b92cc1bbbd96b400f1 | Mindt/tutorial | /Zahlenraten.py | 445 | 3.9375 | 4 | import random
a=random.randrange(12)
of=True
while of:
x= input ("Geben Sie eine zahl ein: ")
if x< 0 or x > 13:
print " Zahl ist außerhalb des Bereichs."
if x < a:
print "zu niedrig"
elif x == a:
print "Super,das ist die richtige Zahl."
of = False
else:
p... |
0db76113d050f509dd4d018e1ad4843f4357cdb5 | olehb/ita3 | /matrix/multiplication.py | 2,051 | 3.59375 | 4 | import matrix
from matrix import Matrix, Submatrix, concatenate_matrices, multiple_submatrices
def __M(m,n):
def submatrix(i,j):
return Submatrix(m, (i-1)*n, (j-1)*n, n, n)
return submatrix
def simple(m1, m2):
return m1*m2
def divide_and_conquer(m1, m2):
assert m1.nCols == m2.nRows
if m... |
45deffd76a959d12838ce5e16345a644cf0035e2 | olehb/ita3 | /sorting/mergesort.py | 654 | 3.859375 | 4 | import insertion_sort
def merge(a, p, r, q):
sorted_a = []
i = p
j = r+1
while i <= r and j <= q:
if a[i] < a[j]:
sorted_a.append(a[i])
i += 1
else:
sorted_a.append(a[j])
j += 1
if i <= r:
sorted_a.extend(a[i:r+1])
else:
sorted_a.extend(a[j:q+1])
a[p:q+1] = sorted_a
def sort(a, p, q, ... |
a5d24fbee492882a3802ab5a147d333a937494b2 | pratishhegde/rosalind | /problems/fibd/fibd.py | 1,184 | 4.125 | 4 | # -*- coding: utf-8 -*-
'''
Recall the definition of the Fibonacci numbers from “Rabbits and Recurrence
Relations”, which followed the recurrence relation Fn=Fn−1+Fn−2 and assumed that
each pair of rabbits reaches maturity in one month and produces a single pair of
offspring (one male, one female) each subsequent mon... |
f328aecf57e54be5d7f07f46655a42f22d8c9309 | pratishhegde/rosalind | /problems/dij/dij.py | 597 | 3.703125 | 4 | import networkx as nx
import matplotlib.pyplot as plt
def dij():
with open("rosalind_dij.txt") as f:
n, m = map(int, f.readline().strip().split())
lines = f.readlines()
edge_list = map(lambda x: map(int, x.strip().split()), lines)
# Create the graph
G = nx.DiGraph()
G.add_nodes_fr... |
9669e1f436ffd13a549f5ece80449a50014c2350 | willywallyfrank/crypto | /affine_cipher_ascii.py | 2,629 | 3.59375 | 4 | #AFFINE CIPHER using the ASCII symbols 32 - 126
def readPtext():
Pfile =input('enter file name containing plain text: ')
PfileLoc = 'Pfile + '.txt'
plainText = open (PfileLoc,"r")
pText = plainText.read()
plainText.close()
return pText
def enterKey():
print('Given C = a + bP M... |
213d03640d9d98a182a5577ca2160bde549e052c | Adam-Banderker/Dice-Simulator---Sprint- | /dice-simulator.py | 4,260 | 4.28125 | 4 | import random #imports the random module which contains random numbers
import time # this module imports time in my code as i want the code to pause at certain stages before execution
"""introduction Screen to my users"""
print('Welcome to our Dice Rolling Simulator!\n')
time.sleep(1) # this line executes the pause b... |
116b374f3bbef77c407cd2ce49bdd89fc4f99987 | WinterNis/pdc1 | /ihm_pdc1/ihm/backend/preprocessing.py | 1,453 | 3.59375 | 4 | import string
import nltk
from nltk.corpus import stopwords
from nltk.stem.porter import *
#########################
# Preprocessing functions
#########################
stop_word_set = set(stopwords.words('english'))
# Breaks the given text up into a list of words (tokens)
def tokenize(text):
text = text.lower()... |
d941bdc5069bd04f0bb7764e9506fe5ed930121a | richistron/PythonCabal-richistron | /Clase_2/clase2.py | 1,002 | 3.84375 | 4 | class Robot:
"Un robot con nombre, posición y dirección."
def __init__( self, nombre, posicion=(0,0) , direccion='N' ):
"Constructor"
self.nombre = nombre
self.x, self.y = posicion
self.direccion = direccion
def avanza( self, direccion='' ):
"Avanza posición del rob... |
050db804af0751dbf1f141e6206b45617647b0c3 | adityasaurabh/python | /cls.py | 2,125 | 3.9375 | 4 | # class Avenger:
# avengerscount=0
# def __init__(self, name, power):
# Avenger.avengerscount += 1
# self.name = name
# self.power = power
# def howmany():
# print("total Avengers %d" % Avenger.avengerscount)
# def getname(self):
# print("Avenger name:"+name+" have power"+power)
# hulk=Avenger(... |
6cb42b95e2161f755acc4795907648d2017408e4 | Jd0824um/testing_practice | /Camel_Case/test_camel_case.py | 900 | 3.734375 | 4 | from unittest import TestCase
from Labs.Camel_Case.camel_case import alternate_case
'''python -m unittest test.py from command prompt'''
class TestFunctions(TestCase):
#Tests for correct alternate case
def test_alternate_case(self):
self.assertEqual('hElLo', alternate_case('hello'))
... |
5967842957d56d65888bd47a1073b10b6e6b1696 | mkbeh/CRyptoLab-RestAPI-data | /utils.py | 308 | 3.734375 | 4 | # -*- coding: utf-8 -*-
def del_dict_item(dict_, key_name):
"""
Func which delete specific dict item by key.
:param dict_:
:param key_name:
:return:
"""
dict_copy = dict_.copy()
for key in dict_copy:
if key == key_name:
del dict_[key]
return dict_
|
7ac4527ba233e39bf952a56b069e4a2f5ff4418c | Wamique-DS/my_world | /Some Basic Program in Python...py | 1,650 | 4.1875 | 4 |
# coding: utf-8
# In[3]:
# prgogarm to find Area of circle
radius=eval(input("Enter the radius of circle ")) # eval takes any value either integer or float
# calculate area
area=radius*radius*3.14
# Display result
print("Area of circle of radius", radius,"is",round(area,2))
# In[8]:
# Program to find area of... |
d0da4358f77b9ccc58885a475510ac2cdfe17638 | Wamique-DS/my_world | /Exception Handling in Python Programming...py | 5,588 | 3.984375 | 4 |
# coding: utf-8
# # Exception Handling:Enables a program to deal with exceptions and continue its normal execution.
# In[1]:
''' Errors That occured during run time is called Exception..'''
1/0 # Gives zero division error,which is built in error
# In[3]:
open('love.txt') # It gives Error ,as it did not fi... |
4bd226e181c1cb73be4ecafb6237ba2ddbcd2d21 | cuyu/python-demo | /Python Training/chain.py | 1,811 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: Curtis Yu
@contact: cuyu@splunk.com
@since: 8/23/17
"""
class ChainIterator(object):
def __init__(self, *list_of_iterable):
self.list_of_iterable = list_of_iterable
self.index = 0 # The position of current iterator in list_of_iterable
... |
85bf02a6a31f75c9db749cb36e42c688f02cc12f | cuyu/python-demo | /demo_mock_1.py | 2,103 | 3.90625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: Curtis Yu
@contact: cuyu@splunk.com
@since: 9/12/16
"""
from mock import patch
def foo():
return 'foo'
# patch can simply used by only inputting the target object that need to replaced.
# In this situation, you must append an argument to the method's in... |
0f4ef1cbe7125c1dcc73cab92d8c4610c376eba4 | pjwerneck/Diaspar | /cryptography/stream.py | 282 | 3.84375 | 4 |
import random
key = '28dhnwjwx2'
text = "Why, Lord, do you stand far off? Why do you pay no attention during times of trouble?"
def crypt(text, key):
random.seed(key)
for c in text:
yield chr(ord(c) ^ random.randint(0, 255))
print repr(''.join(crypt(text, key)))
|
010f75dcf627d4ffad4260f1dc755a1e5cf28402 | pjwerneck/Diaspar | /sorting/sorting.py | 5,553 | 3.84375 | 4 |
import random
import math
import timeit
import heapq
N = 100
# Insertion sort
def insertionsort(A):
for i in xrange(1, len(A)):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
return A
def test_insertionsort():
D =... |
d19e1b5c7b3e7d8552b972fba628157dbe77f79e | kunzhang1110/COMP9021-Principles-of-Programming | /Labs/Lab_7/test.py | 414 | 3.71875 | 4 | def check_sublist(ls1, ls2):
# sublist ls1 and list ls2
list_1 = ls1.copy()
list_2 = ls2.copy()
for item in list_1:
found = 0
for i in range(len(list_2)):
if item == list_2[i]:
list_2.pop(i)
found = 1
break
if not found:... |
0c74ba95f0cbcc2e617e81c4d0047e8cbadca524 | kunzhang1110/COMP9021-Principles-of-Programming | /Labs/Lab_6/Lab_6_1.py | 477 | 3.75 | 4 | import itertools
available_digit_input = '1234321'
desired_sum_input = '5'
number_of_solution = 0
available_digit = [int(s) for s in available_digit_input]
desired_sum = int(desired_sum_input)
for number_of_digit in range(2,len(available_digit)+1):
for comb in itertools.combinations(available_digit,number_of_digi... |
d887b834cf6f361fcaa70c8fd826062bb5913fa1 | kunzhang1110/COMP9021-Principles-of-Programming | /Labs/Lab_4/Lab_4_my/Lab_4_2.py | 430 | 3.59375 | 4 | import sys
filename = input("Enter the name of a file:")
try:
fh = open(filename, 'r')
except IOError:
print("Cannot open file")
sys.exit()
dic = {}
for line in fh:
for c in line:
if c.isdigit():
dic[c] = dic.setdefault(c, 0) + 1
ls = []
for key in dic:
ls.append((key, dic[key]))
ls.sort()
print("Digits:\... |
501071e1a2345854bf674fbf4a2eccafb2cc0c00 | kunzhang1110/COMP9021-Principles-of-Programming | /Labs/Lab_4/Lab_4_solutions/question_2.py | 822 | 3.765625 | 4 | # Prompts the user for the name of a file and outputs
# how many occurrences of each digit has been input, if any.
#
# Written by Eric Martin for COMP9021
with open(input('Enter the name of a file: '), 'r') as file:
digit_found = False
count = [0] * 10
for line in file:
for c in line:
... |
ea0061abbd4db6b8ca9a0ac80a4f3698be8aa9d3 | kunzhang1110/COMP9021-Principles-of-Programming | /Lecture Notes/Lecture_12/insertion_sort.py | 203 | 3.625 | 4 | # Written by Eric Martin for COMP9021
def insertion_sort(L):
for i in range(1, len(L)):
j = i
while j and L[j - 1] > L[j]:
L[j - 1], L[j] = L[j], L[j - 1]
j -= 1
|
a6d7ad5f3380a4f03c08fbff5e47dc7e4771a7f9 | kunzhang1110/COMP9021-Principles-of-Programming | /Quiz/Quiz 1/quiz_1.py | 1,634 | 4.0625 | 4 | # Generates a list of 10 random numbers between 0 and 19 included,
# and determines the length of the longest strictly increasing sequence and
# the smallest most frequent element in the list.
#
# Writtten by Kun Zhang and Eric Martin for COMP9021
# Quiz 1
import sys
from random import seed, randint
nb_of_elements =... |
475803e53b2eec8a454bce6f866324da716cc383 | kunzhang1110/COMP9021-Principles-of-Programming | /Quiz/Quiz 5/quiz_5.py | 2,603 | 3.640625 | 4 | # Randomly fills a grid of size 10 x 10 with 0s and 1s
# and computes the size of the largest area with a checkers pattern.
#
# Written by *** and Eric Martin for COMP9021
import sys
from random import seed, randint
dim = 10
grid = [[None] * dim for _ in range(dim)]
def display_grid():
for i in range(dim):
... |
a7a76576a08a327259bb981cb861ded391f56304 | kunzhang1110/COMP9021-Principles-of-Programming | /Quiz/Quiz_8/quiz_8.py | 3,377 | 4.09375 | 4 | # Randomly fills a grid of size 10 x 10 with digits between 0
# and bound - 1, with bound provided by the user.
# Given a point P of coordinates (x, y) and an integer "target"
# also all provided by the user, finds a path starting from P,
# moving either horizontally or vertically, in either direction,
# so that the nu... |
901bfe55f38adb6702d4ce85ef8473b0a6e7da4d | kunzhang1110/COMP9021-Principles-of-Programming | /Quiz/Quiz 6/quiz_6.py | 2,804 | 4.1875 | 4 | # Defines two classes, Point() and Triangle().
# An object for the second class is created by passing named arguments,
# point_1, point_2 and point_3, to its constructor.
# Such an object can be modified by changing one point, two or three points
# thanks to the function change_point_or_points().
# At any stage, the ob... |
8aa41dc27f269cb487620d43f7ba2d83c878ea0c | FoxRobotLab/ImageMatching | /PythonVersion/partitionAlg.py | 3,769 | 3.546875 | 4 |
import numpy as np
def partition(vec, eqPred):
"""A python version of the OpenCV partition function implemented in C++.
This function splits the input sequence or set into one or more equivalence
classes and returns the vector of labels - 0-based class indexes for each
element. predicate(a,b) retur... |
cce4e45fa6bb90564277832c7e21b58e80b044b5 | Nadav23AnT/DevOpsExperts_Path | /Challenges/ImageChallenge.py | 654 | 3.984375 | 4 | # Creating an Image from the Challenge
from PIL import Image, ImageFont, ImageDraw
name_file = open(r'E:\Python Projects\names.txt', 'a')
name_list = []
number = 3
while number > 0:
name_list.append(input('What is your name: '))
number -= 1
for name in name_list:
name_file.write(name+"\n")
name_file.close(... |
c183543dfe2b5967cf14c8bae73813d122b7d14f | Nyota254/password-locker | /test-class-password-locker.py | 3,242 | 4 | 4 | import unittest
from users import User
from credentials import Credential
class TestUsers(unittest.TestCase):
'''
Test class that defines test cases for the users
Arg:
unittest.TestCase: TestCase class that helps in creating test cases
'''
def setUp(self):
'''
This method ... |
96da5d78c19274d0c1f335e52f424c5a5f869a6f | antoniojsp/RoadTurns | /experiments/angle.py | 224 | 3.75 | 4 | import math
#function that calculate the angle of three points.
def get_angle(a, b, c):
ang = math.degrees(math.atan2(c[1]-b[1], c[0]-b[0]) - math.atan2(a[1]-b[1], a[0]-b[0]))
return ang + 360 if ang < 0 else ang
|
c8538a1803eefac7d1ada5a8850a74fcef77bbe7 | samrat527/pysam | /taskCLI12.02.py | 826 | 3.96875 | 4 | import sys
print(sys.argv)
if len(sys.argv)==2:
if sys.argv[1].isdigit():
l=int(sys.argv[1])
mylist=[]
for i in range(1,l+1):
mylist.append(i)
print(mylist)
sq=[i**2 for i in range(1,l+1)]
print(sq)
else:
print("Enter a digit:")
else:
prin... |
f3d6d126428f2f25a426bfbde5838139595c29a3 | SilverW0o0W/Python | /Code/interview/decorator.py | 1,166 | 3.5625 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@author: Silver (silver.codingcat@gmail.com)
@create: 2022/8/29
@brief:
"""
import functools
import time
def print_time_without_input(func):
def wrapper():
t1 = time.time()
func()
t2 = time.time()
print(t2 - t1)
return wrappe... |
667e34fb89fc133969d6649bb218c3c0c40adaa5 | Maria61/test_script | /2020-08-03/test1.py | 272 | 4.34375 | 4 | # 注释:“:”后缩进的语句视为代码块;python大小写敏感
# a = 100
# if a >= 0:
# print(a)
# else:
# print(-a)
#
# print('I\'m \"OK\"')
#
# print('I\'m OK')
#
# print(r'\\\t\\\ ')
# print('T \t i \n m')
print('''asdf
jlkl
... werwqre
... d''') |
6e3f6b4df14bd6c0647d330ab0355958a80f3f21 | Maria61/test_script | /2020-08-18/advanced_features.py | 1,368 | 3.9375 | 4 | from collections import Iterable
# TODO:高级特性
# 切片
# L = ['AAA','BBB','CCC','DDD','EEE']
# print(L[0:3]) # 取L的 下标范围为[0,3)的元素
# print(L[:3]) # 前面的参数是0可以省略
# print(L[3:]) # 后面的参数是最后一个下标也可以省略
# print('--------------------------------------')
# print(L[:-1]) # 参数可以是负数
# print(L[-1:]) #
# print('--------------------------... |
c159ab3cb87d420b584ca54d07397f7942600269 | ridolenai/Day_Trip_Generator | /DayTripGenerator.py | 2,583 | 4.15625 | 4 | import random
destinations = ["Disney World", "Oktoberfest", "Crawfish Festival", "Mawmaw's House"]
restaurants = ["Applebee's", "Schnitzel Emporium", "Pizza Hut", "Sullivan's"]
transportation = ['Car', 'Bicycle', '4-wheeler', 'Yee Yee Truck']
entertainment = ['Miley Cyrus Concert', 'Chainsaw Juggler', 'Sock Manufactu... |
738c94be9e3b00c0ee61ae8e4886ea4a4f91b9a9 | powersjt4/Algorithms | /sort/stoogesort.py | 1,070 | 3.59375 | 4 | """
This is an implementation of stooge sort that presents the running time
for average case.
Other resources: https://rosettacode.org/wiki/Sorting_algorithms/Stooge_sort
"""
import time
import random
import math
def StoogeSort(A,l,h):
if (A[l] > A[h]):
A[l],A[h] = A[h],A[l]
if (h-... |
859d1e751ad99c34734b7d542dd47311f42999f1 | powersjt4/Algorithms | /sort/InputInsertsort.py | 627 | 4 | 4 | """
This is an implementation of insertion sort that presents the running time
for average case.
from introduction to algorithms, CLRS
Other resources: https://www.geeksforgeeks.org/insertion-sort/
"""
import time
import random
nums = input("Number of random values: ")
array = []
for x in range(nums):
array.appen... |
c21d9ce87e81316c8dc18ea15f4228cb04152e8b | ashutosh-qa/PythonTesting | /PythonBasics/First.py | 509 | 4.28125 | 4 | # To print anything
print("This is first Pyhton program")
# How to define variable in python
a = 3
print(a)
# How to define String
Str="Ashutosh"
print(Str)
# Other examples
x, y, z = 5, 8.3, "Test"
print(x, y, z)
# to print different data types - use format method
print ("{} {}".format("Value is:", x))
# How to k... |
6f2a1beff4d4b9ab9b721c314bf9286495aa40ac | raghavendrajain/IROS2015 | /sphereManipulation/safe.py | 219 | 3.578125 | 4 | import csv
with open('example_11.csv', 'rb') as f:
reader = csv.reader(f)
your_list = list(reader)
print your_list
with open("output.csv", "wb") as f:
writer = csv.writer(f)
writer.writerows(your_list) |
3d8cd884ba8b7b3e16e51ccc3eff71d111f4813b | hteopls88/LE11 | /model.py | 1,789 | 3.796875 | 4 | from Tkinter import*
import factory
class Data:
def __init__(self):
#self.inglist = {"beef":0, "pasta":0, "cheese":0, "tomato":0, "leaves":0, "banana":0, "cream":0, "icecream":0, "chocolate":0, "milk":0}
#self.foodlist = {"lasagna":0, "vegplatter":0, "bananasplit":0, "sundae":0, "bbt":0, "chocomilkshake":0}
sel... |
17f289bd74fe021af46302755b70d86006e988c0 | JuliaKut/Programming-technologies | /Lab_2a/new.py | 1,520 | 3.828125 | 4 | # 2.і
# виведення констант
print("My constant", True)
print("CONSTANT2", None)
G=255
L=200
print("G=",G,"L=",L)
print("G-L=",G-L)
# 2.іі
# моє прізвище починається на букву "к" ,я не знайшла функції на цю букву,
# тому візму функцію на букву "с" та на букву "l" (chr , len)
print("-------------------------------------... |
b954d17ab669c917da8f7a900c11b0ba3103918a | cgaldamez14/rolling-eve | /character.py | 522 | 3.703125 | 4 | '''
CHARACTER MODULE
Any character created of this game will inherit from this character class
Author: Carlos M Galdamez
'''
class Character(object):
'''
Constructor creates three instance variables for Character.
@param name - name of the character
@param health - total health of the char... |
0cc387c42619fa4a3bdcd06dc48cf8c3c64e65c1 | fabiolealsc/quest | /branching.py | 261 | 3.546875 | 4 | import sys
n1 = int(sys.argv[1])
n2 = int(sys.argv[2])
if n1 + n2 <= 0:
print('You have chosen the path of destitution.')
elif 1 <= (n1 + n2) <= 100:
print('You have chosen the path of plenty.')
else:
print('You have chosen the path of excess.')
|
c2472f093027005794ed73c931a7afa8d0c9e758 | rhjames/src | /Python/turtlegraphics1.py | 634 | 4.09375 | 4 | import math
import turtle
print"Lets draw some lines! This program will intake 2 sets of coordinates and draw lines"
onex = float(raw_input("Please enter a first X coordinate "))
oney = float(raw_input("Please enter a first Y coordinate "))
twox = float(raw_input("Please enter a second X coordinate "))
twoy = float(r... |
38dd157356ec9c30991f841927ba9662980c2583 | tthomps/python-challenge | /PyBank/Resources/pypollscript.py | 1,688 | 3.515625 | 4 | #election data
#import csv and os module
import csv
import os
#define variables
winner = ""
win_votes = ""
candidate = ""
can_percent = {}
can_votes = {}
total_votes = 0
#add/open file path as write
filepath = ('Resources', './election_data.csv')
with open(filepath,'r', newline="") as csvfile:
csvreader = csv... |
584b57bbf980e2fcf8e7243bd2c90801d8c16731 | Robert-Dunn/HandySoftwareFiles | /Python/Udemy/11-essential-coding-interview-questions/1-Most_Frequent_Occurring_Item_In_Array/solution.py | 600 | 3.703125 | 4 | mplement your function below.
def most_frequent(given_list):
max_item = None
return max_item
# NOTE: The following input values will be used for testing your solution.
# most_frequent(list1) should return 1
list1 = [1, 3, 1, 3, 2, 1]
# most_frequent(list2) should ret... |
04f373e0bb32fc3a4f4e9d77e1fc83fe368803f2 | Dame-ui/Algorithms | /bubblesort.py | 797 | 4.375 | 4 |
def bubble_sort(list_of_numbers):
for i in range(len(list_of_numbers)): #run N times, where N is number of elements in a list
# Last i elements are already in place
# It starts at 1 so we can access the previous element
for j in range(1, len(list_of_numbers) - i): # N-i elements
... |
e8ec94c083096cf3b238ebb76c662e6d401a9d34 | thinhld80/python3 | /python3-38/python3-38.py | 1,133 | 3.828125 | 4 | #Pickle
#dill
#Serializing objects
#Saving and loading objects and their states
#Python data types, and top level classes
#https://docs.python.org/3/library/pickle.html
import pickle
def outline(func):
def inner(*args, **kwargs):
print('-'*20)
print(f'Function: {func.__name__}')
func(*arg... |
c44dc53c8c6aea407e29c934b9559c752a9e0216 | thinhld80/python3 | /python3-17/python3-17.py | 1,695 | 4.3125 | 4 | #Functions in depth
#No Arguments
def test():
print('Normal function')
print('\r\n------ No Arguments')
test()
#Positional and Keyword Arguments
def message(name,msg,age):
print(f'Hello {name}, {msg}, you are {age} years old')
print('\r\n------ Positional and Keyword Arguments')
message('Bryan', 'good morni... |
8bc9cb211ce9780e5d76303f4869eac4aa0d87bb | thinhld80/python3 | /python3-48/python3-48.py | 2,113 | 4.375 | 4 | #Queues and Futures
#Getting values from a thread
#This is a problem for future me
"""
Queues is like leaving a message
A Future is used for synchronizing program execution
in some concurrent programming languages. They describe an
object that acts as a proxy for a result that is initially unknown,
usually because... |
34953844e759a37f2b697a345c7ed870d6098e3e | thinhld80/python3 | /python3-4/python3-4.py | 685 | 4.15625 | 4 | #Numbers - int float complex
#int
iVal = 34
print(f'iVal = {iVal}')
#float
fVal = 3.14
print(f'fVal = {fVal}')
import sys
print(sys.float_info) # https://docs.python.org/3/library/sys.html#sys.float_info
#complex - complex([real[, imag]])
cVal = 3 +6j
print(f'cVal = {cVal}')
cVal = complex(5,3)
print(f'cVal = {cVal}... |
bfb4bccf2883c18c442043bd7cd89c5b8af12460 | thinhld80/python3 | /python3-30/python3-30.py | 515 | 3.875 | 4 | #Introduction to classes
#OOP - Object Oriented Programming
#Blue prints for creating objects
#Classes are a big topic
#We will cover this over multiple videos
#Create the class
#Import the class
import cat
from cat import Cat
#Use the class
def test():
b = Cat('KitKat',1,'tabby')
c = Cat('Othello',6,'black... |
0cdafb79c9df477474722c851deb8c28efe02905 | thinhld80/python3 | /python3-32/python3-32.py | 1,055 | 4.15625 | 4 | #Multiple Inheritance
#Inherit from multiple classes at the same time
#Vehical class
class Vehical:
speed = 0
def drive(self,speed):
self.speed = speed
print('Driving')
def stop(self):
self.speed = 0
print('Stopped')
def display(self):
print(f'Driving at {self... |
69c6d465f4c876513c27579b73af085219b89989 | thinhld80/python3 | /python3-61/python3-61.py | 1,539 | 3.765625 | 4 | #DateTime
#Working with dates, times, deltas and formats
#Imports
from datetime import datetime, timedelta
from time import strftime
def main():
#Now
#If the host machine is in the UTC timezone then there will be no difference between
now = datetime.now()
utc = datetime.utcnow()
print(f'Now: {now... |
8579d3e9933115a259e8bebe517ec51b6ae95f1c | loganmcampbell/CSCE-3193 | /Homework[7]/my_cipher2.py | 2,896 | 4.25 | 4 | import functioncipyer
# START HERE : ENTER A THE KEYWORD TO CIPHER AND UPPERCASE IT
word = input("Enter keyword for encrpyt: ")
while (word == ""):
word = input("Enter keyword for encrpyt: ")
print("w o r d : ", word)
word = word.upper()
original = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
original = " ".join(original... |
046bb871e7c520be524597c11f67e0bc198f824a | ravenusmc/eu_terrorism | /main.py | 10,918 | 4.3125 | 4 | #Main File for the project.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from valid import *
#This is the main function of the progam that will actually start everything.
def main():
print("\033c")
print("Welcome to European Terrorism Data.")
print("This program will allow the user... |
b2c291e5874215f83b65a83fe3d96854d5a0b47a | ilhamdwibakti/Python3.x_Object_Oriented_Programming | /Episode #04 - Method/Main.py | 1,880 | 3.84375 | 4 | class Hero:
# class variabel
jumlah_hero = 0 #class variabel / statik variable
def __init__(self, inputName, inputHealth, inputPower, inputArmor):#merupakan salh satu konstruktor, Metode __init__(sering disebut "the instaler"),
# melewati instance yang baru ... |
e8346ebe79a28e2ec8d5a2b48271fe88eb8f4437 | Yonibrese/challenge_18_11_16 | /challenge.py | 576 | 3.9375 | 4 | # import datetime
year_birth = int(input("what year were you born?"))
# month = input("what month?")
# day = input("what day?")
year_current = int(input("what is the current year?"))
age = year_current - year_birth
candels = int(list(str(age))[-1])
top_c = "i"*candels
happy = "H:a:p:p:y:"
birthday = "B:i:r:t:h:d:a:... |
ebf7e0dfc717117d978fa50e89055c5c1262d1cb | Alefuentes982/listas | /eliminalista.py | 239 | 3.8125 | 4 | list1 = [0,1,2,3,4]
print("los elementos de la lista son: ", list1)
print("el largo de la lista original es: ", len(list1))
del list1[1]
print("\n")
print("los elementos de la lista modificada son: ", list1, "y su largo es: ", len(list1)) |
eb19359f9ab4b05cb1a79bb68ca24ebe0983f688 | LeeCrawford11/cp1404practicals | /cp1404practicals/prac_03/password_check.py | 534 | 3.734375 | 4 | """
Lee Crawford
CP1404
prac 3
password_check
"""
def main():
minimum_length = 4
password = get_password(minimum_length)
print_number_of_astericks(password)
def print_number_of_astericks(password):
print("*" * len(password))
def get_password(minimum_length):
password = input("please enter your... |
312aed1328f602b6849d7a64ed17658caacd1606 | LeeCrawford11/cp1404practicals | /prac_06/guitars.py | 616 | 3.953125 | 4 | """
Lee Crawford
CP1404/CP5632 Practical - Do-from-scratch Exercises
Guitars
"""
from guitar import Guitars
def main():
guitars = []
finished = False
print("My guitars!")
while not finished:
name = input("Name: ")
print(name)
if name == "":
finished = True
... |
862ee4bd215fb06ff6daa7284d2245e596baf8ae | ageojo/MIT_Introduction_to_CS_Spring2013 | /ps1/ps1a.py | 584 | 3.953125 | 4 | # Problem Set 1A
# Name: Amy C. Geojo
interest = float(raw_input('Enter the interest rate as a decimal: '))
monthly_investment = float(raw_input('Enter the fixed monthly investment: '))
balance = 0
count = 0
for i in range(12):
count = count + 1
balance = balance + balance*interest/12 + monthly_investment
... |
0a0ff0ba909e88091e2fffaabaca08d2e5fcb011 | ageojo/MIT_Introduction_to_CS_Spring2013 | /cs_code/binary_search__bisection.py | 357 | 3.671875 | 4 | from __future__ import division, print_function
def binary_search(f, goal, low, high, epsilon):
"""returns the value such that f(value) = goal within epsiolon"""
mid = (low + high) / 2.0
value = f(mid)
while abs(value - goal) > epsilon:
if (value < goal):
low = mid
else:
high = mid
mid = (low + high) /... |
0459bd0d3f0b4c50d443653901790de902481b81 | ageojo/MIT_Introduction_to_CS_Spring2013 | /cs_code/computing_pi.py | 259 | 3.671875 | 4 | from __future__ import division, print_function
# Computing pi
N = 1000.0
numberInCircle=0.0
x = -1.0
while x < 1.0:
y = -1.0
while y < 1.0:
if x*x*y*y < 1:
numberInCircle = numberInCircle + 1
y = (y+1) / N
x = (x+1) / N
print(numberInCircle)
|
2e371ed587a6d664fb9117300d0045a4d4e43320 | lin12345678910/work | /3.py | 457 | 3.703125 | 4 | a=int(input("請輸入西元年:"))
b= a%12
if b == 4:
print("rat")
elif b == 5:
print("ox")
elif b == 6:
print("tiger")
elif b == 7:
print("rabbit")
elif b == 7:
print("dragon")
elif b == 9:
print("snake")
elif b == 10:
print("horse")
elif b == 11:
print("sheep")
elif b == 0:
... |
581df65610b7ceba6bee1ef196fa51608a1e87ca | lin12345678910/work | /32.py | 334 | 3.546875 | 4 | data1=int(input("輸入一正整數:"))
data2=data1%2
data3=data1%11
data4=data1%5
data5=data1%7
if data2==0 and data3==0:
if data4!=0 and data5!=0:
print("%d為新公倍數?:YES" %(data1))
else:
print("%d為新公倍數?:NO" %(data1))
else:
print("%d為新公倍數?:NO" %(data1)) |
9d66d175dfd63c71c3fcb5cfed4fc800e182454e | furknckmk/Phyton-Basic | /Temel/recopDemo5.py | 514 | 3.546875 | 4 | # -*- coding: utf-8 -*-
import sys
liste = [7,'furkan',0,3,"6"]
for x in liste:
try:
print("Sayi: "+ str(x))
sonuc = 1/int(x)
print("Sonuc :" + str(sonuc))
except ValueError:
print(str(x)+"Bir Sayi Degil!")
except ZeroDivisionError:
... |
e0d0fac4ab9f832f9e99d751ef9b2cc45ebf23a5 | furknckmk/Phyton-Basic | /Temel+(1)/Temel/map.py | 396 | 3.734375 | 4 | # -*- coding: utf-8 -*-
sayilar = [1,2,3,4,5]
sayilarKareli = list(map(lambda sayi: sayi*sayi,sayilar))
#for sayi in sayilar:
# sayilarKareli.append(sayi*sayi)
sayilarFiltreli = list(filter(lambda sayi : sayi>2,sayilar))
print(sayilarKareli)
print(sayilarFiltreli)
from functools import reduce
sayilarF... |
1badc9a72d1da23cb15126fc8483989b8a7fd4f4 | furknckmk/Phyton-Basic | /UpperProjects/pcuyg.py | 1,460 | 3.671875 | 4 | # -*- coding: utf-8 -*-
def topla(a,b):
return a+b
def cikar(a,b):
return a-b
def carp(a,b):
return a*b
def bol(a,b):
return a/b
def kontrol():
deger = None
secim =print(input("Programa Devam Etmek Istiyor musunuz ? E == 'E ye Basiniz.'"))
if secim=='e' or secim== 'E':
deger = ... |
22c38b1c20c0a02f66249a7370e904574c175ada | drupalmk/Google-Class-Python-Exercice | /basic/string2.py | 4,129 | 4.53125 | 5 | #!/usr/bin/python2.4 -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
# Additional basic string exercises
# D. verbing
# Given a string, if its length is a... |
b54823699e9f6a724e5cc5346967fddc3241036d | tammiehall/Black_Jack_Game | /main.py | 2,363 | 3.84375 | 4 | import random
class Card:
def __init__(self, suit, value):
self.suit = suit
self.value = value
def __repr__(self):
return ' of ' .join((self.suit, self.value))
class Deck:
def __init__(self):
self.cards = [Card(s, v) for s in ['Spades', 'Clubs', 'Hearts', 'Diamon... |
aa7160180e69a7b8fedf0cb86ac314ef48e1c9bf | PingMaster99/Microproject1NM | /GraphicInterface.py | 4,709 | 3.953125 | 4 | # encoding: utf-8
"""
GraphicInterface.py
Displays the circuit calculator graphically
Dario Marroquin 18269 (dariomarroquin)
Pablo Ruiz 18259 (PingMaster99)
Version 1.0
Updated February 19, 2020
"""
from tkinter import *
import CalculationMethods as Cm
import matplotlib.pyplot a... |
e3e040f163e158a4c37b8d0ec33b01376d6e8707 | naoto0804/atcoder_practice | /contests/arc/00/006/c.py | 1,039 | 3.765625 | 4 | # 今一番上にあるもののリストが保持できれば良い
# このリストを常に昇順ソートした状態で保持しておくと
# 挿入する要素が
# どの要素よりも大きいときだけ新要素が生える
# そうでないときはそれより大きいもののうち最小と入れ替える (かぶりがある場合に注意)
import bisect
N = int(input())
W = []
for i in range(N):
W.append(int(input()))
current_top_list = []
for w in W:
if len(current_top_list) == 0:
current_top_list.appe... |
f353436f92547bb31c625658f9f7c5d3be97d8c0 | naoto0804/atcoder_practice | /contests/abc/05/055/b.py | 191 | 3.5 | 4 | N = int(input())
power = 1
tmp = 1 # this is devided by 10^{9} + 7
prime = int(1e9 + 7)
for n in range(1, N + 1):
tmp = tmp * n
if tmp > prime:
tmp = tmp % prime
print(tmp)
|
30a36586b9df3b0795b66bf19eb58a5ae0e40ef0 | lfparra/MDS-UAI-Programacion-con-Python-Ejercicios | /guia_02_ciclos_01/10.py | 914 | 3.78125 | 4 | print('Ingrese su genero')
print('Para genero femenino ingrese "f"')
print('Para genero masculino ingrese "m"')
print('Si prefiere no informarlo ingrese "n"')
print('Programa finaliza ingresando "x"')
genero = input()
personas_ingresadas = 0
suma_f = 0
suma_m = 0
suma_n = 0
while genero != 'x':
personas_ingresadas... |
785fffb08b85733af5b84d021ada26e0999b59aa | lfparra/MDS-UAI-Programacion-con-Python-Ejercicios | /guia_01_condicionales/03.py | 183 | 4 | 4 | A = int(input('Ingresa A: '))
B = int(input('Ingresa B: '))
division = A%B
if division == 0:
print('B divide exactamente a A')
else:
print('B no divide a A en forma entera') |
a75362958f11b8f8d98419c52837deb99f748518 | lfparra/MDS-UAI-Programacion-con-Python-Ejercicios | /guia_02_ciclos_01/09.py | 133 | 4.125 | 4 | numero = int(input('Ingrese un número: '))
factorial = 1
for i in range(numero):
factorial = factorial * (i+1)
print(factorial) |
8ed8c49a7b826f676b6987a6cb1fb583fefa8d52 | lfparra/MDS-UAI-Programacion-con-Python-Ejercicios | /guia_02_ciclos_01/06.py | 339 | 4.125 | 4 | numero_ingresado = int(input('Ingrese un número, programa finaliza con un -1: '))
suma = 0
while numero_ingresado != -1:
suma = suma + numero_ingresado
numero_ingresado = int(input('Ingrese un número, programa finaliza con un -1: '))
if numero_ingresado == -1:
print('Programa finalizado')
print(f'Sum... |
efe16ceac9023f93d390eed229e4852ceb5cf78a | lfparra/MDS-UAI-Programacion-con-Python-Ejercicios | /guia_04_ciclos_anidados/03.py | 233 | 3.859375 | 4 | escalones = int(input('Ingresa el número de escalones: '))
filas = escalones
pisos = (escalones*2) - (escalones*2-2)
for i in range(filas):
for j in range(pisos):
print('#', end ='')
pisos = pisos + 2
print('') |
1f56ee6192b146dced5c13c1973d3f23120763dc | tallesbrito/datascience | /curso/agrupamento/kmeans.py3 | 785 | 3.515625 | 4 | #Implementação do K-Means no scikit-learn, a implementação utiliza distância euclidiana.
import matplotlib.pyplot as plt
import seaborn as sns; sns.set() # biblioteca para gráficos estatísticos
import numpy as np
from sklearn.datasets.samples_generator import make_blobs
from sklearn.cluster import KMeans
#Gerando um ... |
781a342cc9f6464ec1b914708ccac4617f1bfec6 | bedevere/CS161 | /rpg.py | 2,435 | 3.875 | 4 | #Copywrite (c) Paul Ashby 2014
#Weight Effect
#First Game
print("\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\")
print("\\ \\ \\ \\ Weight Effect \\ \\ \\ \\")
print("\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\")
print("\nBy Paul Ashby")
main = input("\n\nWelcome, would you like to start... |
474ab536ae9e43aaa23f559c39a1d6733ad151ae | klmr/parsecsv | /parsecsv.py | 1,593 | 3.5 | 4 | #!/usr/bin/env python
import argparse
import csv
import itertools
import io
import sys
from argx.default import default_arg
def csv_to_fields(istream, ostream, delim, skip):
"""
Write CSV data from `istream` to `ostream` using `delim` as the field delimiter.
"""
header = istream.peek(1000)
dialec... |
df05a8f7b32471865bc7b3eb292736f4635dcd1a | zmm0404/python- | /实战5_成绩的分差及平均数.py | 251 | 3.65625 | 4 |
P = 95 # python成绩
E = 92 # Engish成绩
C = 89 # c语言成绩
D = P - E # python与English之间的分差
E = (P+E+C)/3
print('python课程和English课程之间的成绩差为:')
print(D)
print ('三门课程的平均分为:')
print(E)
|
7b6012df92397006fa1855f042f2650bf3e3ba11 | zmm0404/python- | /实战28_面试资格确认.py | 469 | 3.84375 | 4 | while True:
age = int(input('请输入您的年龄:'))
subject = input('请输入您的专业:')
college = input('是否为重点大大学:')
if age > 25 and subject == '电子信息工程':
print('恭喜您已被录取\n')
elif subject == '电子信息工程' and college == '是':
print('恭喜您已被录取\n')
elif age < 28 and subject == '计算机':
print('恭喜您已被录取\n')
else:
print('抱歉,您未达到面试要求')
... |
5a9423be4068bceff4976b3028f6175de95ceba9 | zmm0404/python- | /实战3_bmiexponent.py | 209 | 3.71875 | 4 | print ('请输入您的身高(单位:m):')
a = input()
print('请输入您的体重(单位:kg):')
b = input()
c = float(a)
d = float(b)
BMI = d/(c*c)
print('您的BMI指数为:')
print (BMI)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.