blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
5ec9485cede2ef582e6bc8adaad68f6983ea454e | mobamba1/QA_Challenges | /Example.py | 402 | 3.5 | 4 | july_names = ["Christopher", "Samuel", "Steven", "Christopher", "John", "Bradley", "Wasim", "Domenico", "Jacob", "Diarmuid", "Joshua", "Tobias", "Amanda", "Arsalan", "Clifford", "Mohamed", "Sithembiso", "Edmund", "Javas", "Jason", "Ryan"]
july_names.append("Luke")
print(july_names)
print(july_names[4])
print("Christoph... |
699dae0ab18b9697cc3ff5ee5c6c271b7eac556f | Kazagha/Python-Prototype | /ContextGame/Cast.py | 614 | 3.875 | 4 | class cast:
spell_outer = ''
spell_inner = ''
def __init__(self, spell_inner, spell_outer = None):
self.spell_inner = spell_inner
self.spell_outer = spell_outer
def __enter__(self):
if(self.spell_outer == None):
#return self.spell_inner
with self.spell_... |
8dd8056d42f4b32c463bc559c4ee173c2339e067 | tlarson07/dataStructures | /tuples.py | 1,378 | 4.3125 | 4 | #NOTES 12/31/2016
#Python Data Structures: Tuples
#Similar to lists BUT
#Can't be changed after creation (NO: appending, sorting, reversing, etc.
#Therefore they are more efficient
friends = ("Annalise", "Gigi", "Kepler") #
numbers = (13,6,1,23,7)
print friends[1]
print max(numbers)
(age,name) = (15,"Lauren") #assi... |
211273d69389aee16e11ffc9cf9275c0f509029e | sudhapotla/untitled | /Enthusiastic python group Day-2.py | 2,426 | 4.28125 | 4 | # Output Variables
# python uses + character to combine both text and Variable
x = ("hard ")
print("we need to work " + x)
x = ("hardwork is the ")
y = (" key to success")
z = (x + y)
print(z)
#Create a variable outside of a function, and use it inside the function
x = "not stressfull"
def myfunc():
print("Python ... |
deaa241ca580c969b2704ae2eb830487b247c766 | sudhapotla/untitled | /Python variables,Datatypes,Numbers,Casting.py | 1,192 | 4.25 | 4 | #Python Variables
#Variables are containers for storing data values.
#Rules for Variable names
#A variable name must start with a letter or the underscore character
#A variable name cannot start with a number
#A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
#Variable names a... |
2d130c9d112ae83011701dddb4ee0d927c479c57 | IcaroTARique/APA_1 | /insertionSort.py | 1,005 | 4 | 4 | #!/usr/bin/python3.5
#PARA RODAR O PROGRAMA ./insertionSort.py
import sys
#coding=UTF-8
def insertionSort(lista, tamanho):
for i in range (1,len(lista),1):
menor = i
#for j in range(0, i, -1): <== (FOR DANDO ERRO DESCONHECIDO)
j = i - 1
while j >= 0:
if lista[menor] <l... |
245244a152af17e12bf007f9b63eefd2503b27ed | somshivgupta/phonebook | /phonebook.py | 996 | 3.65625 | 4 | """Integration and Front-End module"""
import utils.user
import utils.contacts
def input_user_menu_choice():
"""Displays user management options and returns user's input choice"""
print('1. Add user')
print('2. Delete user')
print('3: Select user')
choice = int(input('Input choice: '))
if choic... |
9f7fe998d216afff518f6952cfa0c202533fcc63 | merubtsova/MyClassFiles | /hw5.py | 3,034 | 4.1875 | 4 | # -------------------------------------------------#
# Title: Working with Dictionaries
# Dev: merubtsova
# Date: 3/12/2019
# ChangeLog: (Who, When, What)
# RRoot, 11/02/2016, Created starting template
# merubtsova, 3/12/2019, Added code to complete assignment 5
# https://www.tutorialspoint.com/python/pyt... |
fe6d646bdce1ddba21cb9cfd07e1c73060f2f7b7 | matt-chapman/master-thesis | /Experiments/Python/ChangeDetection/src/scaffold.py | 8,356 | 3.703125 | 4 | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
from collections import defaultdict
np.set_printoptions(precision=3, suppress=True)
"""
Code adapted from Aman Ahuja (https://github.com/amanahuja/change-detection-tutorial/)
"""
def dict_to_arrays(ddict):
"""
Convenience function u... |
35121d1ca6f9c9c18b4d0c2e3e06a2a20af5fc63 | Allegheny-Computer-Science-102-F2018/classDocs | /lessons/14_week_setsAndFrequencies/sandbox/diceProbability.py | 918 | 3.75 | 4 | # date: 27 Nov 2018
# Saha, page 132
def probability(space, event):
return (1.0 * len(event))/len(space)
# the 1.0 is used to convert floats in python2
#end of probability()
def check_prime(number):
if number != 1:
for factor in range(2, number):
if number % factor == 0:
... |
a070d7391d0b798ed5d4b143c113b58d2134b6c4 | Allegheny-Computer-Science-102-F2018/classDocs | /labs/04_lab/sandbox/myTruthCalculatorDemo.py | 1,176 | 4.3125 | 4 | #!/usr/bin/env python3
# Note: In terminal, type in "chmod +x program.py" to make file executable
"""calcTruth.py A demo to show how lists can be used with functions to make boolean calculations"""
__author__ = "Oliver Bonham-Carter"
__date__ = "3 October 2018"
def myAND(in1_bool, in2_bool):
# functio... |
739e87c6d60bcb3d832d906330d09abfbddee5cc | Allegheny-Computer-Science-102-F2018/classDocs | /lessons/10_week_objects_classes/sandbox/monday_29Oct2018.py | 942 | 3.546875 | 4 |
# Date: 29 Oct 2018
class Family(): #create class
pass # class does nothing
#end of class Family
myPals = Family() #instance of object
myPals.f_name00 = "Alexander"
myPals.l_name00 = "Banhom-Certar"
myPals.f_name01 = "Daisy"
myPals.l_name01 = "Conham-Barter"
print(" Call the class for the first time")
print... |
59485df36da39c43d05c0a85c3dbe612a9acb1f3 | Allegheny-Computer-Science-102-F2018/classDocs | /lessons/11_week_visualizingData/sandbox/charPlot.py | 773 | 3.609375 | 4 | # date: 7 Nov 2018
# simple plotting tool for frequencies of characters in a string
from pylab import plot, show, title, savefig, xlabel, ylabel, legend
s_str = "hello" # string to study
sCount_dict = {} # save the counts here
# count the letters in the word
for i in s_str:
if i not in sCount_dict:
sCoun... |
13c09909126f39eabb96c39c623e0a76c80a5e7f | ViciousCupcake/leetcode | /src/prob88.py | 551 | 3.546875 | 4 | def merge(nums1: list[int], m: int, nums2: list[int], n: int) -> None:
idx1 = 0
idx2 = 0
buffer = []
while idx1 < m and idx2 < len(nums2):
if nums1[idx1] < nums2[idx2]:
buffer.append(nums1[idx1])
idx1 = idx1 + 1
else:
buffer.append(nums2[idx2])
... |
a96f064e63cb9104c7bc3b7b4c009628dbcc66c0 | robbinc91/segviz | /segviz/utils.py | 10,945 | 3.9375 | 4 | import numpy as np
from PIL import Image
from pathlib import Path
import importlib.resources
MIN_UINT8 = 0
MAX_UINT8 = 255
def assign_colors(label_image, colors):
"""Assigns colors to a label image.
Note:
* The values of ``label_image`` correspond to the row indices of the
array colors.
... |
63621bc0cc5e5145a72763c2ddc286038e58c69a | mehulchopradev/curtly-python | /xyz/supercoders/bank/account.py | 1,301 | 3.875 | 4 | from xyz.supercoders.bank.minbalerror import MinimumBalanceError
class Account:
minbalance = 2000
def __init__(self, accno, accname, acctype, accbalance):
self.accno = accno
self.accname = accname
self.acctype = acctype
self.accbalance = accbalance
def deposit(self, depositamt):
self.accbal... |
7425ab4844fd5684ab5cdd80d2a760aabf6675bd | mehulchopradev/curtly-python | /xyz/supercoders/lib/series.py | 643 | 3.71875 | 4 | # module 'series' has reusable library kind of functions
def get_fiboseries(n):
result = ''
a, b = 0, 1
result += str(a) + ' ' + str(b) + ' '
for v in range(1, n - 1):
c = a + b
result += str(c) + ' '
a, b = b, c
return result
def get_even_series(n):
result = ''
for ele in range(0, n + 1, 2... |
cbe189e695f9b2a21c1f708c3a724fb5ab8e23af | mehulchopradev/curtly-python | /more_more_functions.py | 853 | 4.15625 | 4 | def abc():
a = 5 # scope will abc
b = 4
def pqr(): # scope will abc
print('PQR')
print(a) # pqr() can access the enclosing function variables
b = 10 # scope will pqr
print(b) # 10
pqr()
print(b) # 4
abc()
# pqr() # will not work
# fun -> function object
# scope -> module
def fun():
p... |
d80dcff9be08846685f9f553817a16daf91a2d77 | JeanneBM/PyCalculator | /src/classy_calc.py | 1,271 | 4.15625 | 4 | class PyCalculator():
def __init__(self,x,y):
self.x=x
self.y=y
def addition(self):
return self.x+self.y
def subtraction(self):
return self.x - self.y
def multiplication(self):
return self.x*self.y
def division(self):
if self.y == 0:
... |
3f6ff625caa4763758eab2acd908db3abb976e1c | taizilinger123/apple | /day2/高阶函数.py | 938 | 4.125 | 4 | var result = subtract(multiply(add(1,2),3),4); #函数式编程
def add(a,b,f): #高阶函数
return f(a)+f(b)
res = add(3,-6,abs)
print(res)
{
'backend':'www.oldboy.org',
'record':{
'server':'100.1.7.9',
'weight':20,
'maxconn':30
}
}
>>> b = '''
... {
... 'backend':'www.oldboy.org',
... ... |
ee136845779de40a10d2deb1362f98d3700455dc | markorodic/python_data_structures | /algorithms/bubble_sort/bubble_sort.py | 238 | 4.15625 | 4 | def bubblesort(array):
for j in range(len(array)-1):
for i in range(len(array)-1):
if array[i] > array[i+1]:
array[i], array[i+1] = array[i+1], array[i]
return array
# list = [7,4,2,3,1,6]
# print list
# print bubblesort(list) |
0be37a7f3f074d289f2e6ba40e7203b7d58eb651 | bdferr/masters-project | /gs_preprocessor2.py | 4,282 | 3.609375 | 4 | #This script processes both the tagged and untagged files in the second half of the gold standard corpus.
#It strips everything but the tokens and part of speech tags from the tagged files
#and produces text files listing both the tagged and untagged files
#in the order they were processed.
#It finally concatenates eve... |
2ad4c1f448972bbbae742e7f59eeab379513eb72 | Derimar/folha-de-pagamento | /src/payroll/schedule.py | 2,131 | 3.65625 | 4 | from abc import ABC, abstractmethod
import calendar
from datetime import date, timedelta
class Schedule(ABC):
def __init__(self, desiredDay):
self._desiredDay = desiredDay
self._payday = self.calc()
@property
def desiredDay(self):
return self._desiredDay
@property
... |
db6b5fd00c1b6f9e089e76e20b6ce9afb322de8c | jocogum10/learning_python_crash_course | /user_02.py | 983 | 4.09375 | 4 | class User():
"""A class that defines a user."""
def __init__(self, first_name, last_name, gender, age):
"""Initialize the first name, last name, age, and gender attributes."""
self.first_name = first_name
self.last_name = last_name
self.gender = gender
self.age = age
self.login_attempt = 0
def desc... |
ff7dbb03f9a296067fbd7e9cfff1ff58d2a00a63 | jocogum10/learning_python_crash_course | /numbers.py | 1,487 | 4.40625 | 4 | for value in range(1,5):
print(value)
for value in range(1,6):
print(value)
numbers = list(range(1,6))
print(numbers)
even_numbers = list(range(2,11,2))
print(even_numbers)
#square values
squares = [] #create empty list
for value in range(1,11): #loop from 1 to 10 using range function
square = value**2 #st... |
168623d3ad75e1bd3d736a2a11f7535b393529f6 | jocogum10/learning_python_crash_course | /die.py | 287 | 3.796875 | 4 | from random import randint
class Die():
"""A class that simulates a die"""
def __init__(self, sides=6):
"""Initialize the attributes"""
self.sides = sides
def roll_die(self):
"""method to roll a die"""
x = randint(1, self.sides)
print(x)
dice = Die()
dice.roll_die()
|
eb60cfbe2f62d92d90b775e969301d071725ec8a | jocogum10/learning_python_crash_course | /favorite_number.py | 348 | 3.59375 | 4 | import json
filename = 'favorite_number.json'
try:
with open(filename) as file_object:
message = json.load(file_object)
except FileNotFoundError:
with open(filename, 'w') as file_object:
message = input("What is your favorite number? ")
json.dump(message, file_object)
else:
print("I know your favorite number... |
7e6555072dee4b38dd17137e8f50fb91ade515b6 | jocogum10/learning_python_crash_course | /guest.py | 276 | 3.53125 | 4 | filename = 'guest_book.txt'
with open(filename, 'a') as file_object:
active = True
while active:
message = input("\nWhat is your name? ")
if message == 'q':
active = False
else:
file_object.write(message + "\n")
print("\nHello, " + message.title() + ".")
|
c6bbf4c5494812bfd79488604137cc747b93fde5 | Mykola-L/PythonBaseITEA | /Lesson3/Task1version2.py | 1,481 | 3.671875 | 4 | import random
from random import seed
n = int(input('Введіть, будь-ласка, кількість цілочисельних випадкових значень '))
my_list = [] # створюю список
# seed random number generator
seed(1)
# generate some integers
for _ in range(n): # кількість чисел, елементів у списку масиву
my_list.append((random.randint(1,... |
c6e9dde2a7ede750711151de1899b529b425b382 | Mykola-L/PythonBaseITEA | /Lesson10/HW2/1_9.py | 221 | 3.515625 | 4 | # s = "text text : one two three"
# print(s.split(':')[1])
# s = entry1.get()
s = 'https://image.shutterstock.com/image-photo/mountains-during-sunset-beautiful-natural-260nw-407021107.jpg'
b = (s.split("/")[-1])
print(b) |
a967afe22c56102335cdb87a3f13f235196ca9f7 | Mykola-L/PythonBaseITEA | /Lesson4/range.py | 657 | 3.5625 | 4 | r = range(100) # range спеціальний об'єкт, своєрідний ітерований об'єкт. Списки стандартні об'єкти.
# Основне призначення використовувати їх в середині циклу.
# range спеціальна штурка яка може використовуватися в середині циклу for, необов'язково це робити словником або списком.
print(r) # бажано не приводити range до... |
ae953ab50be2893d603aae05b3ad97128a1233a6 | Mykola-L/PythonBaseITEA | /Lesson4/for_dict.py | 412 | 3.515625 | 4 | test_dict = {'milk': 20, 'meat': 90, 'tomato': 20} # словник
for i in test_dict:
print(test_dict[i]) # так ми зможемо вивести значення
# змінна і виступає в ролі ключа
#print(i) # повертаються тільки ключі, в змінну і записуються тільки ключі, а значення ігноруються
|
6341cca74cc12f5aea1b450f8a38f8c6daece393 | Mykola-L/PythonBaseITEA | /Lesson3/0.py | 2,047 | 4.0625 | 4 | import random
# print(random.random)
#
# n = input('Введіть, будь-ласка, кількість цілочисельних випадкових значень ')
#
# my_random = random.randint(50, 100) # генерує випадкові числа від 50 до 100
#
# print(my_random)
# print(random.seed([X], version=2))
# print(list(random.seed([1], version=2)))
# from random im... |
bcf64be5f6707bb72b2d71a464441c72979f45d5 | Mykola-L/PythonBaseITEA | /Lesson3/min_max_function.py | 162 | 3.578125 | 4 | my_list = [1, 2, 3, 4, 10]
print(max(my_list)) # можна саму функцію передати в якості аргумента іншої функції |
92bc39205aee2bb9579e7babefdaec3631a347a4 | Mykola-L/PythonBaseITEA | /lesson5/HW2/3_6.py | 204 | 3.890625 | 4 | # generate random integer values
from random import seed
from random import randint
# seed random number generator
seed(1)
# generate some integers
for _ in range(5):
value = randint(5, 15)
print(value) |
a033a1dd328958de1c4c8a1f5d5354ae3d964d87 | Mykola-L/PythonBaseITEA | /Lesson3/standart_functions.py | 226 | 3.671875 | 4 | # len від слова length довжина
my_list = [1, 2, 3, 4, 10]
length = len(my_list)
print(length)
my_list = tuple(my_list) # my_list перевели в tuple
print(my_list)
sum_list = sum(my_list)
print(sum_list) |
4a2a3e6f60a78a223bbe70039745895fb60d2e60 | Mykola-L/PythonBaseITEA | /Lesson3/2.py | 483 | 3.5 | 4 | import random
n = int(input('Введіть, будь-ласка, кількість цілочисельних випадкових значень '))
# Як вивести функцію print() багато разів
i = 0
while i < 10:
# print(list(range(random.randint(1, 1000)))) # переводимо range в list
print(random.randint(1, 1000)) # генерує випадкові числа від 1 до 1000
i += ... |
f943fa24ef81b1bb4de3b04932ec39679f641915 | Mykola-L/PythonBaseITEA | /Lesson8/exeptions.py | 1,251 | 3.953125 | 4 | # якщо користувач введе замість цифр букви або інші символи
try:
number1 = float(input('Введіть ділене '))
number2 = float(input('Введіть дільник '))
except ValueError: # блок Exception виконається, якщо виконається будь-який виняток який наслідується від Exception
# Ієрархія винятків, презентація, урок 8, ... |
7cc0ba06dadafcafabacd8ccba8ebf045e6a8755 | Mykola-L/PythonBaseITEA | /Lesson3/while_loop.py | 997 | 3.796875 | 4 | #loop цикл
# i = 0
# list_size = 6
# my_list = [1, 2, 3, 4, 5, 6]
# while i < list_size:
# print(my_list[i])
# i += 1 # i = i + 1
# my_list = [1, 2, 3, 4, 5, 6]
# print(my_list[-1])
# Continue and break
# numbers = (2, 2, 3, 2, 4, 5, 4, 5, 10, 20, 30, 40) # масив кортеж
# i = 0
# length_of_tuple = 12 # довжи... |
db9188af650b37fe2cc122d932b752283a32a516 | Mykola-L/PythonBaseITEA | /Lesson3/9.py | 1,787 | 3.5625 | 4 | import random
n = int(input('Введіть, будь-ласка, кількість цілочисельних випадкових значень '))
for i in list(range(random.randint(1, 1000))): # можна перевести range в list
#for i in list(range(randint(1, 1000))): # можна перевести range в list
print(i)
#my_list = [] # створюю список
# Цикл while викликає фу... |
8c699d5ce4f696b9db4931317163bf70c2af9b9b | m-regina/rm-py4e | /ex_07/ex_07_02.py | 419 | 3.671875 | 4 | # use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
try:
fh = open(fname)
except:
print("Error. Try again.")
quit()
count = 0
total = 0
for line in fh:
if not line.startswith("X-DSPAM-Confidence:"):
continue
count = count + 1
fnum = line.find(" ")
num = line[fnum+1:]
f... |
2e7d7008a0995f0b6619ffad04db860166db78d9 | m-regina/rm-py4e | /ex_11/ex_11.py | 272 | 3.671875 | 4 | import re
fname = input("File name: ")
handle = open(fname)
total = 0
count = 0
line = handle.read()
num = re.findall('([0-9]+)', line)
#re.findal will return a list of strings
for n in num:
total = total + int(n)
count = count + 1
#print(count)
print(total)
|
f972327b858585803df52000dd0fd92e307569b3 | chrisgmartin/DATA602 | /CMartin_hw4.py | 2,799 | 3.671875 | 4 | # This assignment will give you a chance to do a few important analytical tasks.
# As with Homework 3, I am looking for complete program.
# There are two parts below, do them both.
# 1 Design and implement a system that takes a webpage URL as input.
# The program will read the page and extract the important text, news... |
b56f4a2d6d9465470118939604ad77b22f12d9f2 | Boya-Z/CS540 | /nqueens.py | 6,303 | 3.78125 | 4 | import copy
import random
# given a state of the board, return a list of all valid successor states
def succ(state, boulderX, boulderY):
successor = list()
size = len(state)
m = 0
while m < size:
n = 0
while n < size:
if not (m == boulderX and n == boulderY):
... |
5e0879097dd50b146c486bb95618c965d095f8f6 | rakeshprasadyaday/basic | /histogram.py | 634 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Oct 25 05:30:09 2018
@author: cse19
"""
import matplotlib.pyplot as plt
# x-coordinates of left sides of bars
left = [1, 2, 3, 4, 5,6]
# heights of bars
height = [221,239,245,256,269,277.5]
# labels for bars
tick_label = [2012,2013,2014,2015,2016,2017]
# plotting a... |
d3e65f320706ef836e2bbda8d819be34a54cf74d | Mahmoud-Ashraf98/US-Bikeshare-Data | /bikeshare.py | 11,657 | 4.40625 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
print('Hello! Let\'s explore some US bikeshare data!')
# below I've created the get_filters function that takes the user sele... |
630c9f2b8313805e5293e59ec3c08c69c8580e90 | piyushghiya/Taxi-data-analysis | /NightLife/map.py | 1,851 | 3.78125 | 4 | #!/usr/bin/env python
import sys
import datetime
def convert_str_to_date(date_str):
date_obj = None
try:
date_obj = datetime.datetime.strptime(date_str,'%Y-%m-%d %H:%M:%S')
except Exception:
pass
return date_obj
def is_weekend(date_obj):
return date_obj.weekday==5 or date_obj.weekd... |
5e14f411512360c6df4d6c013878dae5ac4b61dd | piyushghiya/Taxi-data-analysis | /FareTimeAnalysis/map.py | 2,256 | 4.03125 | 4 | #!/usr/bin/env python
import sys
import datetime
def convert_str_to_date(date_str):
date_obj = None
try:
date_obj = datetime.datetime.strptime(date_str,'%Y-%m-%d %H:%M:%S')
except Exception:
pass
return date_obj
def is_weekend(date_obj):
return date_obj.weekday()==5 or date_obj.wee... |
689cac08ff9fa748591acf215058953a565a5698 | serviceberry3/nn_tuts | /train_written_digit_network.py | 14,784 | 4.28125 | 4 | #HAND-TRAIN A NN TO ESTIMATE DIGITS THAT THE PIXELS REPRESENT
from sklearn.datasets import load_digits
import matplotlib.pyplot as plt
import sys
#load up the digit-pixel map dataset
digits = load_digits()
#log shape of input data matrix
print(digits.data.shape)
#make sure we can get the images, test by displaying ... |
3fb70b7606e070f693f328e0bb35fb4fb0f9205f | szijderveld/Solving_MNIST_from_scratch | /Using_Fully_Connected_Layer_NN/catergorical.py | 1,274 | 4.03125 | 4 | """Numpy-related utilities."""
import numpy as np
def to_categorical(y, num_classes=None, dtype='float32'):
"""Converts a class vector (integers) to binary class matrix.
E.g. for use with categorical_crossentropy.
Usage Example:
>>> y = [0, 1, 2, 3]
>>> tf.keras.utils.to_categorical(y, num_cl... |
089261da783a0400232c52dedd8b8622d8a64e4e | rounaksalim95/utilities | /Grading/push_grades.py | 2,037 | 3.5625 | 4 | '''
This script is intended to be used to help with grading in CS 891/892 [works with both python2 and python3]
It uses a file repos.txt that should contain lines with the name of the student followed by their gitlab repo url separated by a space
Example: Rick_Sanchez git@rick.git
Script expects two arguments, the na... |
21229197d4cf04dff847e236c61fc8f003826861 | dubok11/python | /kek.py | 259 | 3.796875 | 4 | from random import *
x = randint(0, 100)
y = randint(0, 100)
print("x =",x,"\ny =",y)
if x > y:
print(y," - наименьшее число")
elif x < y:
print(x," - наименьшее число")
else:
print("числа равны")
|
95a006c4e89baf5ccbd8da7689a40b9cd6b76514 | EMGuyant/python_fundamentals | /graphics/circle_radius.py | 9,187 | 4.65625 | 5 | # Programming Excerise #10
# This program takes a user specified radius value and draws a blue circle with that radius
# Draws a red radius line segment, and a green diameter line segment
# After the circle is drawn there is a user option to "View Measurments" which includes displaying
# the radius value, d... |
7c2f8f89556ae1f8018f028d9ef21c4911575886 | adgedenkers/miniature-octo-adventure | /code_test.py | 3,970 | 3.828125 | 4 | screen_height = 320
screen_width = 480
# ---------- Display Buttons ------------- #
# Default button styling:
BUTTON_HEIGHT = 40
BUTTON_WIDTH = 80
# We want three buttons across the top of the screen
TAPS_HEIGHT = 40
TAPS_WIDTH = int(screen_width/3)
TAPS_Y = 0
# We want two big buttons at the bottom of the screen
B... |
a5884534803b5e38c0b1621b2be8fb97e8e4448e | moontasirabtahee/Toph.co_Solve | /Fibonacci Numbers.py | 226 | 3.890625 | 4 | N = int(input())
first = 0
second = 1
output = 0
if N == 1:
print(0)
elif N ==2:
print(1)
else:
for i in range(1,N,1):
output = first+second
first = second
second = output
print(output) |
2467e92954a6b10ed67412a8f7a3cf83f724f40c | moontasirabtahee/Toph.co_Solve | /Is Palindrome.py | 194 | 3.859375 | 4 | word = input()
count = 0
for first,last in zip(word,reversed(word)):
if first == last:
count += 1
else:
print('No')
break
if count == len(word):
print("Yes") |
3adc2d3de83772964fa723561bf7f22490308f69 | ilanzs/LearningToCode | /Python/CodeForces/Opposite.py | 463 | 3.640625 | 4 | t = int(input())
inputs = []
for i in range(t):
inputs.append(input().split())
for nums in inputs:
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
circle_size = abs(a - b) * 2
half_circle_size = circle_size / 2
output = abs(half_circle_size + c) % circle_size
if output == 0:
... |
b25903c79e73656812cec9daf6095440b9b41f48 | ilanzs/LearningToCode | /Python/MazeGeneration/RecursiveBacktrackingMazeGeneration.py | 3,933 | 3.671875 | 4 | import random
import math
import pygame
# make the screen
WIDTH, HEIGHT = 700, 700
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Maze Generator")
FPS = 100000000000
clock = pygame.time.Clock()
# make variables for the maze
w = 10
cols = math.floor(WIDTH / w)
rows = math.floor(HEIGHT / w)
... |
e73572680ddec83ccd6cd33d56a450ac7ece0cee | yusuf963/python-pg | /dic-loop.py | 236 | 3.953125 | 4 |
num = [1, 2, 3]
# i = 0
# while i < len(num):
# print(num[i])
# i = i + 1
# ! git the undex and the item
for w, num in enumerate(num):
print(f"{w}, {num} 'hello'")
# ! juming
for num1 in range(0, 11, 2):
print(num1)
|
a47e028423195dacbd01d5d8a85db7ea72e1c5d0 | CrownCrafter/School | /ser2.py | 236 | 3.546875 | 4 | #!/usr/bin/env python3
x = int(input("Enter x "))
n = int(input("Enter n "))
s = 1
i = 1
sign = 1
while i <= n:
if(sign == 1):
s -= x ** i
sign = 0
else:
s += x ** i
sign = 1
i += 1
print(s)
|
53c2c448ee79c59bd73571bae255b2b94aa64ef8 | CrownCrafter/School | /func.py | 693 | 3.90625 | 4 | def cyl(h, r):
area_cyl = 2 * 3.14 * r * h
return(area_cyl)
def con(r, l):
area_con = 3.14 * r * l
return(area_con)
def final_price(cost):
tax = 0.18 * cost
re_price = cost + tax
return(re_price)
print("Enter Values of cylindrical part of tent ")
h = float(input("Height : "))
r = float(inpu... |
b61b0a61c389a4516705426fe898581a05364421 | CrownCrafter/School | /continue.py | 115 | 4.125 | 4 | num = 0
for num in range(6):
num += 1
if num == 3:
continue
print(str(num))
print("Complete")
|
f38a0a567da80562246900f4d8986106e6f99509 | CrownCrafter/School | /great3.py | 423 | 4.15625 | 4 | #!/usr/bin/env python3
a = int(input("Enter Number "))
b = int(input("Enter Number "))
c = int(input("Enter Number "))
if(a>=b and a>=c):
print("Largest is " + str(a))
elif(b>=a and b>=c):
print("Largest is " + str(b))
else:
print("Largest is " + str(c))
if(a<=b and a<=c):
print("Smallest is " + st... |
ad9e6ee4061c94dfb1b537cc6c4660d44175d155 | clauchile/zoo-python | /Animales/Tigre.py | 1,189 | 3.65625 | 4 | if __name__ == '__main__':
from animal import *
else:
from .animal import *
class Tigre(Beast):
def __init__(self, name,edad,salud=100, nivelDeFelicidad=100):
super().__init__(name,edad,salud,nivelDeFelicidad)
self.peso = 400
def mostrarInfo(self):
print("-"*100)
... |
2bf4dc8a6bf1f9ca31ce518591c7faf4a1e05822 | simplypixi/bpu | /dbpu-l1/zadanie5.py | 424 | 3.640625 | 4 | from sys import argv
script, filename = argv
text = "darek"
def search(line, text):
contain = 0
for i in range(0, len(line)-1):
if (line[i] == text[0]):
j = 1
while (j < len(text)):
if (line[i+j] != text[j]):
j -= 1
break
j += 1
if (j == len(text)):
contain = 1
break
return c... |
17d50543233400d554d9c838e64ec0c6f5506ce6 | ArashDai/SchoolProjects | /Python/Transpose_Matrix.py | 1,452 | 4.3125 | 4 | # Write a function called diagonal that accepts one argument, a 2D matrix, and returns the diagonal of
# the matrix.
def diagonal(m):
# this function takes a matrix m ad returns an array containing the diagonal values
final = []
start = 0
for row in m:
final.append(row[start])
start += 1
... |
40787d3eeace92e2bb313e62ea61497558842728 | yinwenzhi/pytorchpractice | /utils/draw a dynamic line chart.py | 570 | 3.546875 | 4 | import numpy as np
import matplotlib.pyplot as plt
plt.axis([0, 100, 0, 1])
plt.ion()
xs = [0, 0]
ys = [1, 1]
for i in range(100):
y = np.random.random()
xs[0] = xs[1]
ys[0] = ys[1]
xs[1] = i
ys[1] = y
plt.plot(xs, ys)
plt.pause(0.1)
# ---------------------
# 作者:Reacubeth
# 来源:CSDN
# 原文... |
7f54cb88c8af104b7a9f5dc34bb6c77963f5faa9 | sekhorroy/URLshortner-using_NLP | /contextualizer/webScapper.py | 1,491 | 3.515625 | 4 | #import libraries
import requests
from bs4 import BeautifulSoup
import re
# specify url
def return_web_content(url3):
url1 = "https://timesofindia.indiatimes.com/india/pm-modi-hosts-dinner-for-russian-president-putin/articleshow/66075563.cms"
url = "https://timesofindia.indiatimes.com/india/clown-princ... |
97f9b81787a1c0f24135bd7b766c330b90219de7 | nomorewzx/guanzhong | /example/first_app.py | 3,959 | 3.921875 | 4 | import streamlit as st
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import plotly.graph_objs as go
import time
st.title('Example in Guanzhong')
st.write("""
Basically, in this tutorial, streamlit shows its ability to:
- Display Message and raw pandas dataframe table
- Display chart using naiv... |
15380c51a8f569f66e9ecf0f34000dfe32db85c0 | DoolPool/Python | /Calculadora Basica/Calculadora-Vs1.py | 1,147 | 4.1875 | 4 | print("=== CALCULADORA BASICA ===")
print("Elige una opción : ")
print("1.-Suma")
print("2.-Resta")
print("3.-Multiplicación")
print("4.-División")
x= input("Escribe tu elección : ")
y= float(x)
if(y==1):
a=input("Introduce el primer numero \n")
b=input("Introduce el segundo numero \n")
a2=float(a)
... |
12e86891a8ed9864f69f97bb6facc0169568184f | ColeCrase/Week9-Assignment | /Page198.py | 246 | 3.796875 | 4 | def summation(lower, upper):
"""Returns the sum of the numbers form lower
through upper."""
if lower > upper:
return 0
else:
return reduce(lambda x, y: x + y,
range(lower, upper + 1))
|
cab14d3da92d25d6ac0995cbcfea2a8bef236675 | 92hackers/algorithms | /linked_list.py | 4,712 | 4.03125 | 4 | # 链表
# 支持基本的增删改查操作
# TODO: how to sort a list
class ListNode:
def __init__(self, value):
self.data = value
self.next = None
self.prev = None
class LinkedList:
def __init__(self, *args):
self.head = None
self.tail = None
self.size = None
self.build_list(... |
6af4f07470d8ce0b743cadfb62d9383609658e54 | hkdeman/FunScripts | /drawing-trees.py | 893 | 3.59375 | 4 | import turtle
# canvas = turtle.Turtle()
tree = list("(a(b(d(h,i),e),c(f,g)))")
tree_as_dict = {"a":[{"b":[{"d":["h","i"]},"e"]},{"c":["f",{"g":["j",{"k":["l"]}]}]}]}
# canvas.penup()
START_POS = (0,0)
# canvas.setposition(START_POS[0],START_POS[1])
last_pos = START_POS
level = 0
total_inner_nodes = 0
def get_inn... |
86d248be924683d1aad11882033d81969f31730d | emmalkl/python | /0529/条件.py | 593 | 3.640625 | 4 | '''
一段关于条件控制的小程序
'''
''' mood=True
if mood:
print('go to left')
#print('back away')#没有缩进的时候就当作一句话处理
else:
print('go to right') '''
# 真实情况下使用条件控制语句
account = 'lilin'
password = '123456'
print('请输入account')
user_account = input() #此函数为用户输入的操作
print('请输入password')
user_password = input()
# 如果用户名密码相同,打印succ... |
b344b3b45ef2d5ff9668b5ee4cb5a10571057149 | emmalkl/python | /0529/for2.py | 515 | 3.96875 | 4 |
""" for(i=0;i<10;i++){
} """
# for each
# a=[1,2,3,4,5,....]
#range函数,从0开始有10个数字。
""" for x in range(0,10):
print(x) """
#结果:打印0~9
""" for x in range(0,10,2):
print(x,end='|') """
#结果:0|2|4|6|8|
""" for x in range(10,0,-2):
print(x,end='|') """
#结果:10|8|6|4|2|
a=[1,2,3,4,5,6,7,8]#打印间隔数1,3,5,7
""" for... |
198acdb8b1a570128448a7a121664ceed4ca139c | polyactis/repos | /variation/trunk/src/rfun.py | 2,353 | 3.984375 | 4 | """
A file that contains various helpful functions to deal with R.
"""
import util
def plotVectorsOnSameGraph(x,vectorList, main="", xlab="", ylab="",type=None):
pass
def plotVectors(x, vectorList, main="", xlab="", ylab="",type=None, xname="x", ynames=None):
"""
Writes out a simple R string to plot the... |
6f39621a06ee6425aa9e0e82a0c07f4df683eeaa | polyactis/repos | /pymodule/trunk/clique.py | 2,580 | 3.515625 | 4 | #!/usr/bin/env python
"""
2007-10-01
module to get the maximum clique
"""
import sys
sys.setrecursionlimit(50000)
class clique:
def __init__(self, debug=0):
self.debug = int(debug)
self.max_clique_size = 0
self.max_clique_ls = []
def sub_max_clique(self, graph, node_ls, current_clique_size):
"""
2007-10... |
343a3277f87a4060d980b62a815d7b028081b4be | Remyaaadwik171017/mypythonprograms | /flow controls/patterns/squarenpattern.py | 74 | 3.8125 | 4 | n=int(input("Enter n value"))
for i in range(n):
print((str(n)+' ')*n) |
3f2328a01dd09470f4421e4958f607c3b97a5e1f | Remyaaadwik171017/mypythonprograms | /flow controls/flowcontrol.py | 244 | 4.15625 | 4 | #flow controls
#decision making(if, if.... else, if... elif... if)
#if
#syntax
#if(condition):
# statement
#else:
#statement
age= int(input("Enter your age:"))
if age>=18:
print("you can vote")
else:
print("you can't vote") |
73e378771cc03082fab5b5019e444a896c3bd7e6 | Remyaaadwik171017/mypythonprograms | /functions/sumof n no.py | 114 | 4.03125 | 4 | def sum():
n=int(input("Enter any value: "))
result=0
for i in range(n+1):
result+=i
print(result)
sum()
|
8d5ecf1bf2815b642c4b9d094e4f0ebfa347ae3d | Remyaaadwik171017/mypythonprograms | /functions/fact.py | 95 | 3.90625 | 4 | num=int(input("Enter any no"))
fact1=1
for i in range(1, num+1):
fact1=fact1*i
print(fact1) |
7628876721aa32f65975c1b70dbda18e7ae0c627 | Remyaaadwik171017/mypythonprograms | /functions/factorial.py | 133 | 3.921875 | 4 | def fact():
num=int(input("Enter any no: "))
fact1=1
for i in range(1,num+1):
fact1*=i
print(fact1)
fact()
|
5e573026e76941335e53302db0934e0c800e751a | Remyaaadwik171017/mypythonprograms | /flow controls/nestedif.py | 218 | 3.84375 | 4 | salary=float(input("Enter your salary:"))
year_of_service=int(input("Enter your year of service:"))
if year_of_service>5:
bonus=0.5*salary
print("bonus:",bonus)
else:
print("You have no bonus in this year") |
1890711e1cafeb65b1b4216d335556b04e6d45f4 | Remyaaadwik171017/mypythonprograms | /collections/list/list10.py | 368 | 3.8125 | 4 | lst=[10,12,3,4,5,7,8,9,6,1]
lst.sort()
print(lst)
low=0
upp = len(lst) - 1
n=int(input("Enter searching element: "))
flag=0
while (low<=upp):
mid=(low+upp)//2
if (n>lst[mid]):
low=mid+1
elif(n<lst[mid]):
upp=mid-1
elif(n==lst[mid]):
flag=1
break
if flag>0:
print("elem... |
935ddbc01a3f00810d27da29a6cee00165a00a82 | Remyaaadwik171017/mypythonprograms | /flow controls/looping/sumofnnumbers.py | 136 | 3.9375 | 4 | n=int(input("Enter n value: ")) #n=5
i=1
sum=0
while i<=n: #1<=5,#2<=5
sum =sum+i #0+1,1+2, 2+3
i=i+1 #2 ,3
print("sum is",sum) |
54cc6a2f0c8c27fe06ec0ccb3df08a8003b04a70 | sahrialihsani/EX_SDA_STACK | /Hometask1.2_stack.py | 2,832 | 3.625 | 4 | class convertToPre :
precedence={'^':5,'*':4,'/':4,'+':3,'-':3,'(':2,')':1}
def __init__(self):
self.items=[]
self.size=-1
def push(self,value):
self.items.append(value)
self.size+=1
def pop(self):
if self.isempty():
return 0
else:
... |
09ce90eaf76e02759b4be62e87d8fba29d889087 | danksalot/AdventOfCode | /2016/Day01/Program.py | 1,371 | 3.984375 | 4 | def Turn(orientation, direction):
if direction == "R":
orientation += 1
if direction == "L":
orientation -= 1
if orientation == -1:
orientation = 3
if orientation == 4:
orientation = 0
return orientation
def VisitHorizontal(oldX, newX, Y, map):
for X in range(oldX+1, newX+1):
if map[X][Y] == 1:
prin... |
8fd6028336cac45579980611e661c84e892bbf12 | danksalot/AdventOfCode | /2016/Day03/Part2.py | 601 | 4.125 | 4 | def IsValidTriangle(sides):
sides.sort()
return sides[0] + sides[1] > sides [2]
count = 0
with open("Input") as inputFile:
lines = inputFile.readlines()
for step in range(0, len(lines), 3):
group = lines[step:step+3]
group[0] = map(int, group[0].split())
group[1] = map(int, group[1].split())
group[2] = map(i... |
64d7d3fcb7c4d06dedbd3f749c66a1d1b7bc2dfa | danksalot/AdventOfCode | /2018/Day18/Program.py | 1,853 | 3.5 | 4 | DIRECTIONS = [
(-1, 0), #UP
( 0, -1), #LEFT
( 0, 1), #RIGHT
( 1, 0), #DOWN
(-1, -1), #UP-LEFT
(-1, 1), #UP-RIGHT
( 1, -1), #DOWN-LEFT
( 1, 1) #DOWN-RIGHT
]
size = 50
def getNeighbors(y, x):
neighbors = [(y + dy, x + dx) for dy, dx in DIRECTIONS]
return [coords for coords in neighbors if 0 <= coords[0... |
2b6f35fee3e4670a81e669a97ede35c7d1850f1e | danksalot/AdventOfCode | /2017/Day16/Program.py | 1,021 | 3.65625 | 4 | def spin(dancers, num):
return dancers[-num:] + dancers[:-num]
def exchange(dancers, first, second):
dancers[first], dancers[second] = dancers[second], dancers[first]
return dancers
def partner(dancers, first, second):
return exchange(dancers, dancers.index(first), dancers.index(second))
def dance(troop, steps, ... |
59eb833b9f74b68d3edab85e22203c52cd6d0a3d | danksalot/AdventOfCode | /2015/Day09/Program.py | 761 | 3.5 | 4 | from collections import defaultdict
from itertools import permutations
distances = defaultdict(dict)
with open('Input') as inputFile:
for line in inputFile:
parts = line.split()
distances[parts[0]][parts[2]] = int(parts[4])
distances[parts[2]][parts[0]] = int(parts[4])
possibleRoutes = permutation... |
38780c9f4e19af2c9c310bc1ac9b1ac3a11b7b36 | sumnous/Leetcode_python | /threeSumClosest.py | 1,122 | 4.09375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2014-1-2
@author: Ting Wang
'''
# Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target.
# Return the sum of the three integers. You may assume that each input would have exactly one solution.
# For e... |
005807a3b2a9d1c4d9d1c7c556ac27b7c526c39f | sumnous/Leetcode_python | /reverseLinkedList2.py | 1,585 | 4.25 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2014-03-02
@author: Ting Wang
'''
#Reverse a linked list from position m to n. Do it in-place and in one-pass.
#For example:
#Given 1->2->3->4->5->NULL, m = 2 and n = 4,
#return 1->4->3->2->5->NULL.
#Note:
#Given m, n satisfy the following condition:
#1 ≤ m ... |
f8e21887c7c8819e2def77674c09c1e2e24e36d8 | sumnous/Leetcode_python | /fourSum.py | 1,365 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2014-1-2
@author: Ting Wang
'''
# Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target?
# Find all unique quadruplets in the array which gives the sum of target.
# Note:
# Elements in a quadruplet (a,b,c,d) ... |
6b317e610f09a043a80db8ca2ce06fb28ab7bec1 | sumnous/Leetcode_python | /reverseWords.py | 537 | 4.0625 | 4 | #151
#Reverse Words in a String
#Given an input string, reverse the string word by word.
#
#For example,
#Given s = "the sky is blue",
#return "blue is sky the".
class Solution:
# @param s, a string
# @return a string
def reverseWords(self, s):
s = s.split(' ')
s = [x for x in s if x != '']... |
6757140a93fbc8073e5b55dedb82a8c40cd92261 | AviShah10/ProjectEuler | /Euler037.py | 846 | 3.640625 | 4 | def sieve(n):
primes = [True for i in range(n+1)]
primeList = set()
num = 2
while num * num <= n:
if primes[num]:
for j in range(num * num, n+1, num):
primes[j] = False
num += 1
for i in range(2, n+1):
if primes[i]:
primeList.add(i)
... |
0e7c3feee79cd67a2164f66da4f22138f7f4b422 | AviShah10/ProjectEuler | /Euler049.py | 901 | 3.609375 | 4 | def sieve(n):
primes = [True for i in range(n+1)]
primeList = set()
num = 2
while num * num <= n:
if primes[num]:
for j in range(num * num, n+1, num):
primes[j] = False
num += 1
for i in range(2, n+1):
if primes[i]:
primeList.add(i)
... |
cfd69c33035879dd123244ce865dfb02aa92ad25 | ashutosh65000/GoogleFoobar | /Level 3C/solution.py | 597 | 3.953125 | 4 | # This was my solution submitted and passed all the test cases
'''
@Author: Ashutosh Srivastava
Python3 solution
'''
def solution(x, y):
answer=0
x=int(x)
y=int(y)
while (x!=1 or y!=1):
if (x==1 or y==1):
if (x==1):
return str(answer+(y-1))
if (y==1):
... |
6572fd9172441c539f9c2e529666f48836e01622 | MovieMeter/film-guide | /imdb/db250.py | 1,617 | 3.578125 | 4 | # DataBase class, for communicating with the IMDb 250 database.
import sqlite3
class DataBase:
def __init__(self):
self.conn = sqlite3.connect('/home/mehulagarwal/PycharmProjects/film-guide/imdb/imdb250.db')
self.c = self.conn.cursor()
self.c.execute('''create table if not exists movies... |
0489fbe36747094359433e6575305dd7b16f8127 | IBOIBO111/Rundgang | /Complex.py | 1,408 | 3.90625 | 4 | import math
class Complex():
def __init__(self,_real,_complex):
self.__real = float(_real)
self.__complex = float(_complex)
def getReal(self):
return self.__real
def getComplex(self):
return self.__complex
def getBetrag(self):
return math.sqrt(self.__real**2+self... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.