blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
21e9521d479e4333f3c7fd03443fcb4fa5c40173 | mzrLab/py-practice | /types.py | 516 | 4.09375 | 4 | # this is the python data types :
# first of all print() is a function which will print the result to the output
print("Hi Welcome!")
# strings
myName = 'Ali Sawari'
# whole numbers
myNum = 3.14
# floating numbers
myFlo = 14.6
# booleans
myBool = True
# lists(arrays)
myList = [1,2,'Hello',3.14]
# tuples (constan... |
e8b9b4f806c6db1301b9a5039d7348c673a310d6 | Guslc2010/Financial_Statements-Python | /incomeStatementApplication.py | 54,678 | 3.734375 | 4 | #Developer: Tyler Smith
#Date: 11.06.16
#Purpose: The income statement application is the GUI
# and logic behind the popup that is displayed
# when the user clicks the income button on the
# main program.
from tkinter import * # Import tkinter library
from income... |
d3384541db20794db35c9600dd0ca87a92aa9686 | tyler-england/hangman | /HMan.py | 18,675 | 4.125 | 4 | # Hangman!
# Tyler England
# txt file of words
# fullfilepath = r"/Users/Tyler/Desktop/words.txt" #macbook
# fullfilepath = r"C:\Users\Tyler\Desktop\words.txt" #pc
fullfilepath = r"K:\EnglandT\Misc\Scripts\Python\Hman\words.txt" # BW PC
import random as rand
import collections
with open(fullfilepath) as ... |
0962fd19eebb3ffb3603b9555712146971e1fd3f | PaulWang1905/tint | /stage1/hello.py | 343 | 4.09375 | 4 | # Note that print is a function
print("hello world")
age = 20
name = 'Swaroop'
print('{0} was {1} years old when he wrote this book'.format(name,age))
print('why is {0} playing with that python?'.format(name))
print('{0:.5f}'.format(1.0/3))
print('{0:-^20}'.format('hello'))
print('{0:.3f}'.format(2.0/3))
print('{0:_^1... |
a60e8155cbb18be98c914d9004cb959e6b7a5e82 | KJRG/JBA-SimpleBankingSystem | /Topics/Loop control statements/Palindrome/main.py | 155 | 4.03125 | 4 | word = input()
for i in range(len(word) // 2):
if word[i] != word[-i - 1]:
print("Not palindrome")
break
else:
print("Palindrome")
|
3a958b63bf34600d375debb2a58212d8faf26bba | amansinghgar/Real-Time-Twitter-Sentimental-Analysis | /Real Time Twitter Sentimental Analysis/get_sentiment.py | 1,128 | 3.625 | 4 | import instinct
#It is the main file which runs, when the users click the search button
def getSentiment(query):
try:
#Creating the TwitterClient Object
api = instinct.TwitterClient()
#Getting the 300 tweets from tweepy
tweets=api.get_tweets(query,300)
#Creatig the list of positive and negative tweets
... |
8b66ae4b7dc9f5021359a3ef559e9a7aa8b965c1 | Anoopcb/Iterator_vs_iterable | /Iterator_vs_iterable.py | 245 | 4.0625 | 4 | ## iterator vs iterables
numbers = [1, 2, 3, 4]## iterables
squares = map(lambda a: a**2, numbers)##iterator
print(squares)
for i in squares:
print(i)
for i in numbers:
print(i)
## step call iter function
#nex(iter(numbers))
|
4ab5c3ed3dd7659f450cf06d838e8c478e7e7402 | HzDmS/algorithm_python | /heapsort/heapsort.py | 1,494 | 4.1875 | 4 | """ Heapsort. """
def left(x):
""" Return index left child of node x.
Parameters
----------
x: int, index.
Returns
-------
int, index of left child.
"""
return x * 2
def right(x):
""" Return index right child of node x.
Parameters
----------
x: int, index.
... |
48520243506dab8a017dc0d950b761779d205cdd | ahmedfgad/IntroDLPython | /Ch07/generic-ann-ch07.py | 3,726 | 3.515625 | 4 | import numpy
import matplotlib.pyplot
def sigmoid(sop):
return 1.0 / (1 + numpy.exp(-1 * sop))
def error(predicted, target):
return numpy.power(predicted - target, 2)
def error_predicted_deriv(predicted, target):
return 2 * (predicted - target)
def sigmoid_sop_deriv(sop):
return sigmoid... |
a3a8c6c311d784090cef2d1fb3de5ebe89cb792b | allienson/OSGambs | /fila.py | 4,801 | 3.875 | 4 | ###################
# Modulo de Filas #
###################
class Fila:
# Tamanho da Fila
TAMANHO_FILA = 1000
# Processos executados
todos_processos = list()
# Fila de processos de tempo real
processos_real = []
# Fila de processos de usuario
processos_usuario1 = []
processos_usuari... |
32270473db4e676766497c6262df311cecc9c9f1 | CameronHunt5812/Python_Project | /untitled-3.py | 1,281 | 3.828125 | 4 | string = "hello"
print string[0]
for y in range (len(position)):
for x in range (len(position[y])):
if position[y][x] == lookFore[0]:
for char in (len(lookFore)):
if y == 0 and x == 0:
p = 4,6,7
elif y == 0 and x == (len(position[y])):
... |
ef411a75a5ec15df1f642b72de6c58dcf7ddcd8a | ddahlmeier/code-from-scratch | /python/graphs.py | 5,081 | 3.84375 | 4 | """Graphs in python."""
# Author: Daniel Dahlmeier <ddahlmeier@gmail.com>
from abc import ABCMeta, abstractmethod
import numpy as np
import random
from itertools import chain
from operator import itemgetter
import heapq
def unique(iter):
"""Helper class to return list of unique items in iter"""
return list(... |
708a568e87e8543c6d9dfbae95f5c995f2f37b6f | ap1303/DANDUdacity | /t1p2/bikeshare-2/bikeshare.py | 6,934 | 4.375 | 4 | import time
import pandas as pd
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) city - name of the city to anal... |
d3d172db22c5ee2d6a4eb91fc6499fe476dcd134 | Crkonova76/GMIT_problem_set2019 | /problem_set_1.py | 2,137 | 4.03125 | 4 | # Martina Crkonova, 2019-03-02
# Problem Set 2019, Python sumupto, Programming and Scripting, GMIT
# Program calculating sum of all numbers between given number and one
"""
For solving of this problem I used two different algorithms.
Variable i is by using input function asking for the positive integer.
In both cases... |
20db94dfc9e00f92a330135bd4a00703130d68e2 | xinyuL1/Python-design-project | /edwhryikj.py | 312 | 3.578125 | 4 | import turtle as bob
from random import randint as rint
bob.shape("turtle")
bob.pensize(5)
bob.colormode(255)
bob.bgcolor("black")
bob.tracer(False)
for times in range(500):
bob.color(rint(0,255),rint(0,255),rint(0,255))
bob.circle(2*(1+times/4),5)
bob.speed(20)
bob.tracer(True)
|
50e52c5c17c2db593e5a55432f968de00152c77a | spdkh/quera | /2530.py | 368 | 3.796875 | 4 | word = input()
s = [word]
for letters in ['TK', 'DG', 'LR', 'FR']:
## print(letters)
for new_word in s:
for k in range(word.count(letters[0])):
replaced = new_word.replace(letters[0], letters[1], k + 1)
## print(new_word, replaced, s)
if replaced not in s:
... |
27c837c7d32b0e76088841c52ca2b150c0ae7154 | SunnyMarkLiu/LeetCode | /101-200/189. Rotate Array.py | 866 | 4.09375 | 4 | #!/home/sunnymarkliu/softwares/anaconda3/bin/python
# _*_ coding: utf-8 _*_
"""
@author: SunnyMarkLiu
@time : 18-1-6 下午9:52
"""
class Solution(object):
def rotate2(self, nums, k):
"""
Time Limit Exceeded
:type nums: List[int]
:type k: int
:rtype: void Do not return anythi... |
da50ad143e84953a9fca6a537cef10cfbe150dcd | guo842917077/Exercise | /pythontest/com/crazyorange/python/fortest/fortest.py | 607 | 4.03125 | 4 | """
python 中的迭代可以迭代list,dict ,tuple
如果需要向java一样迭代 需要enumerate
"""
###判断一个对象是否可以迭代
#from collections import Iterable
#print(isinstance('abc',Iterable))
#迭代整个循环
listA = list(range(20))
for x in listA:
print(x)
###迭代字典的key和value
dic = {1: "hha", 2: "hehe"}
for key in dic:
print(key)
for value in dic.values():
... |
be7a62acfa13ff2bfc7707e8bae8ead0d78e93a2 | konradzb/AlgorithmsAndDataStructure | /kolos/kolos2.py | 479 | 3.625 | 4 | def wczytaj_text():
text = ""
try:
file = open("zadanie2.txt")
text = file.read()
except FileNotFoundError:
print("nieznaleziono pliku")
return text
def szyfrowanie_kolumnowe(text, n):
text = text.replace(" ", "")
res = ""
for i in range(n):
for j in rang... |
a290c547ebe11774f1c117568a853d9aa708480c | jascals/homework | /ml/Titanic/file_loader.py | 965 | 3.5625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tkinter
def __main__():
loadData()
def loadData():
dt_train = pd.read_csv('Titanic/train.csv')
dt_train_p = dt_train.drop(['Name', 'Ticket', 'Cabin'], axis=1)
labels = dt_train_p.groupby(['Survived'])
dataSet = dt_tr... |
7f26b1f501a829b1c72c00edbd3544758bbb5b21 | Rabbidon/project-euler | /euler074.py | 1,985 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 2 23:38:04 2019
@author: edwin
"""
# Basically here we just start at each nummber and apply the "factorial sum" function until we hit
# 169, 363601, 1454, 871, 45361, 872, 45362, or any number that is mapped to itself under this function.
# In fac... |
9ad5b43dfeaf50ebd955e7fdc3a2bca976e1a270 | AmorimGabrielCE/TecnicasAvan-adasPython | /Cap04-Colecoes/counter.py | 990 | 4.03125 | 4 | # Usando a classe counter
from collections import Counter
def main():
turma_a = ["Barbara", "João", "Carlos", "Dario", "Priscila", "Ana"
"Kevin", "João", "Marina", "Bianca", "Gustavo",
"Fernanda"]
turma_b = ["Hiro", "Bruno", "Claudia", "Debora", "Fernanda",
"Gabri... |
7bfeaa0f2c1cceced04b466a22a03bdba21aac3a | 13701144549/Demo_SortSearch_Python | /Search/Demo_block_search.py | 2,412 | 3.796875 | 4 | # encoding: utf-8
"""
Author: 沙振宇
CreateTime: 2019-5-28
UpdateTime: 2019-12-5
Info: 分块查找
算法简介--分块查找
要求是顺序表,分块查找又称索引顺序查找,它是顺序查找的一种改进方法。
算法思想
将n个数据元素"按块有序"划分为m块(m ≤ n)。
每一块中的结点不必有序,但块与块之间必须"按块有序";
即第1块中任一元素的关键字都必须小于第2块中任一元素的关键字;
而第2块中任一元素又都必须小于第3块中的任一元素,……
算法流程
1、先选取各块中的最大关键字构成一个索引表;
2、查找... |
70fb7ac79f130a5ab2bc9619297d0725635e9a85 | guportus/python_codes | /TicTacToe.py | 4,390 | 3.9375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
#Milestone project
#TicTacToe
#Use jupyter library to clear output
from IPython.display import clear_output
#Import Random
import random
#import string
import string
#Ask player one if marker is X or O
def player_marker():
marker=''
player1='X'
playe... |
d60699bb303ada43b64ab2b04afa1567414aa773 | southpawgeek/perlweeklychallenge-club | /challenge-153/sgreen/python/ch-1.py | 225 | 3.671875 | 4 | #!/usr/bin/env python
import math
def main():
solutions = [1]
for i in range(1, 10):
solutions.append(solutions[-1]+math.factorial(i))
print(*solutions, sep=', ')
if __name__ == '__main__':
main() |
27226dad508f34dbc2f8c5e00e658e04ba8f6dbd | github-felipe/ExerciciosEmPython-cursoemvideo | /PythonExercicios/ex098.py | 947 | 3.65625 | 4 | from time import sleep
def contar(ini, fim, passo):
if passo == 0:
passo = 1
elif passo < 0:
passo *= -1
print('-=' * 30)
print(f'Contagem de {ini} até {fim}, de {passo} em {passo}')
atual = ini
if ini < fim:
while True:
if atual <= fim:
prin... |
0b40e18a25aa407ef1368af588de7323fa0dbc59 | oalhamedi/Projects | /DataProjects/countries/countries.py | 697 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 7 19:31:33 2020
@author: omar
"""
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv('countries-of-the-world.csv')
gdp = df["GDP ($ per capita)"]
phones = df["Phones (per 1000)"]
percent_literate = df["Population"]
region = df["... |
cf9d0d2d9fb3f96a2b1ce59c7d520dea4f94a701 | sanjkm/ProjectEuler | /p347/two_prime_alt.py | 1,205 | 3.515625 | 4 | # two_prime_integer.py
# Find the largest integer lower than 10 MM divisible by
# exactly 2 primes. Find the suitable integer across all
# pairs of prime and sum them
import sys
home_path = "/home/osboxes/ProjEuler/"
sys.path.insert (0, home_path + "Utilities/")
from factors import gen_prime_list, is_prime
from bise... |
427270c04f64beffd3282a557d9f7f64f1254945 | nguyen1997phuc/python_tut | /class_introspection.py | 464 | 3.515625 | 4 | class SwitchBase:
def switch(self, case):
m = getattr(self, f'case_{case}', None)
if not m:
return self.default
return m
__call__ = switch
class CustomSwitcher:
def case_1(self):
return 'one'
def case_2(self):
return 'two'
def case_42(self):... |
998666918c609ad43ef5e3104c3997399accb9f8 | tasha06/Python-Programs | /Second Largest in array.py | 1,926 | 4.0625 | 4 | """ -------------------- Second Largest in array -------------------------
You have been given a random integer array/list(ARR) of size N. You are required to find and return the second largest element present in the array/list.
If N <= 1 or all the elements are same in the array/list then return -2147483648 or -2 ^ ... |
160c3ca810366ac7cb9ee0b3fdfab4a1b9a67d88 | obidinnc/cdc_corona_project_nate | /corona.py | 5,506 | 4.28125 | 4 | #All of the data we're using to detemrine the risk of severe illness come from the CDC themselves.
#You can find it here at this website: https://www.cdc.gov/coronavirus/2019-ncov/need-extra-precautions/people-at-higher-risk.html
#First, we'll determine the age of the user.
while True:
try:
age = int... |
5e9e4245937fe3bbaaee3b10fcf3fa9e596c02bc | LOG-INFO/PythonStudy | /3_conditional_statement/3_for.py | 1,532 | 3.984375 | 4 | # for문의 기본 구조
# for 변수 in 리스트(또는 튜플, 문자열):
# 수행할 문장1
# 수행할 문장2
# ...
test_list = ['one', 'two', 'three']
i = 0
for val in test_list:
print(str(i) + ") " + val)
i += 1;
print()
# range(a, b) : a 이상 b 미만
for i in range(0, 10):
i = i + 1
print("나무를 %d번 찍었습니다." % i)
if i == 10:
... |
5c8800ab50e0da729c46c3120cedc42d3305a20d | christinemiller-09/CPS3320 | /ScrabbleGame.py | 1,027 | 4.0625 | 4 | # create a function that gives each letter a specific score
# create another function that calculates the score of an entire word
letterOrWord = input("Enter a letter or word to find it's point value:")
letterOrWord = letterOrWord.lower()
score = 0
total = 0
def letterScore(letterOrWord):
if letterOrWord in 'aeilnors... |
263ef2738957f8ee6c9effcff0c8bbb139651e5c | njsss/LeetCode-Python | /tree/binary_tree_inorder_traversal.py | 1,656 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Time: O(n)
Space: O(1)
Given binary tree [1,..., 2, 3],
1
\
2
/
3
return [1,3,2]
1
/ \
2 3
/ \
4 5
return [4,2,5,1,3]
"""
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
... |
f38a12e74a33ad10b878c5e6005bb4bdfcb3d4ee | stefany0907/PrinciplesOfComputing | /zombieapocalypse/zombieapocalypse.py | 8,492 | 3.5625 | 4 | """
Student portion of Zombie Apocalypse mini-project
"""
import random
import poc_grid
import poc_queue
import poc_zombie_gui
# global constants
EMPTY = 0
FULL = 1
FOUR_WAY = 0
EIGHT_WAY = 1
OBSTACLE = "obstacle"
HUMAN = "human"
ZOMBIE = "zombie"
class Zombie(poc_grid.Grid):
"""
Class for simulating zombi... |
74627a5bf0790c246f1f089afa310a1085d00dcd | tsalgie/advent_of_code_2020 | /05/binary_boarding.py | 694 | 3.578125 | 4 | def seat_id(seat):
return int(seat[:7], 2) * 8 + int(seat[-3:], 2)
def binary_boarding(lines):
return max([seat_id(seat) for seat in lines])
def binary_finding(lines):
seat_index = next(i for i in range(len(lines) - 1) if int(lines[i+1], 2) - int(lines[i], 2) == 2) + 1
return seat_id(lines[seat_index]... |
648aff5175dce92b5a6efc43e4296bd5a3f1905b | 525642022/leetCodeArithmetic | /testNum88.py | 835 | 3.890625 | 4 | # 作者 ljc
# 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1中,使得 num1 成为一个有序数组。
# 注意:
# 你可以假设 nums1有足够的空间(空间大小大于或等于m + n)来保存 nums2 中的元素。
# 在 nums1 和 nums2 中初始化的元素的数量分别是 m 和 n。
class Solution(object):
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: ... |
dc824b8b1ab0e720d0b3d7b89ca7e9cf0e47e0fc | keivahn/Assignment3 | /findfollowers.py | 2,215 | 3.796875 | 4 | # Alex Smith
# W205 - Storing and Retrieving Data
# Assignment #3
import pymongo # import the pymongo module to deal with the Mongo databases that we've created
import tweepy # import Tweepy module to help with accessing the Twitter followers
import createmongo # import createmongo class to cre... |
e2edbbdb49f1a3a477db47585ad32788cf00c51c | luluxing3/LeetCode | /lulu/countAndSay.py | 760 | 3.546875 | 4 | class Solution(object):
def say(self, string):
lastNum = ''
count = 0
sayWords = ''
for n in string:
if lastNum == n:
count += 1
else:
if count and lastNum:
sayWords += str(count) + lastNum
la... |
32df63d1a94bec25b2b6a880edc1e8136668ba8f | santoshgawande/PythonPractices | /dict_example.py | 198 | 4.03125 | 4 | #dict trick
d = {True: 'yes', 1: 'no', 1.0: 'maybe' }
print(d)
#It will print {True: 'maybe'}
#why this is happen ? : Because True = 1 = 1.0 are same in python
res = True == 1 == 1.0
print(res)
|
81a3400c71899a3b32048478ac9419ce785c7f03 | dormon/prj | /meanabsolutedifference/nvsn.py | 1,173 | 3.5625 | 4 | from random import *
def mad(x):
res = 0
counter = 0
for i in range(len(x)):
for j in range(i+1,len(x)):
counter+=1
res += abs(x[i]-x[j])
return float(res)/float(counter)
def approx1(x):
res = 0
counter = 0
for i in range(len(x)-1):
counter+=1
... |
bafb7295084df75a85c2e60e34a232d55417aa66 | Grayidea-bit/guess-number0-100 | /basic.py | 678 | 3.84375 | 4 | while True:
from random import randint
unknow = randint(1, 100)
while True:
guess=input("請輸入數字")
guess=int(guess)
if (guess > unknow):
print("小於",guess)
continue
else:
if (guess < unknow):
print("大於",guess)
... |
5c7640338640e13013e2a03c3ea98df656679cfd | jccprev/Nao_abra | /v4.last_tmp.py | 43,143 | 3.890625 | 4 | # campo das variaveis/funções:
from time import sleep
info_colida = {}
v_cabaco = {}
bebedeira = {}
fumante = {}
TB_f = 'Nada'
opc = 's'
d = 'x'
l = 'x'
print(" ")
print("Abrindo o programa")
sleep(1)
print("Carregando as variaveis ...")
sleep(2)
print("..... aguarde ....")
for x in range(1, 100, 18):
print(x, ... |
633e24a93acf3ef3c991627f663ed19cddfc5bed | tomasztuleja/exercises | /practisepythonorg/exLogIn.py | 1,814 | 3.921875 | 4 | #!/usr/bin/env python
# My first try:)
# Take from user @LOGIN and PASSWORD
# Conditions for @LOGIN and PASSWORD
logChar = ('@', '.')
passChar = ()
lowabc = map(chr, range(97, 123))
upabc = map(chr, range(65, 91))
# Defined input variable and type for login and PASSWORD
def logIN():
global l
l = str(input... |
38452504fb19f12bd065765ec67301de68ff9f79 | EPCJC-LP10/Grupo01 | /Projeto/menu.py | 1,026 | 3.609375 | 4 | # -*- coding: iso8859-1 -*-
def principal():
print
print " **** MENU ****** "
print
print " 1. Gesto de Eventos"
print " 2. Gesto de noites "
print
print " 0. Sair"
print
op = raw_input("Opo: ")
return op
def eventos():
print
print " *** Menu Eventos **** "
... |
59a7515f9dc803926f10091139663f169035e258 | Likhit/AntsChallenge | /bots/trained_bots/likhit/nets/netutils.py | 2,310 | 3.53125 | 4 | """
Helpful functions.
"""
import numpy as np
from types import SimpleNamespace
def conv_output_shape(shape, kernel_size=1, stride=1, pad=0, dilation=1):
"""
Utility function for computing output of convolutions
takes a tuple of (h,w) and returns a tuple of (h,w)
"""
if type(shape) is not tuple:
... |
7ffa2868439a3e7e7f1bbdf9f9b98731bb12f505 | Holden4Caulfield/python | /BASE/Draw.py | 839 | 3.515625 | 4 | var = 1
while var == 1: #制作一个循环,可以反复输入数字来判断是不是“快乐的数”
a = eval(input()) #输入一个正整数
while (a != 1 and a != 4): #当a不等于1或者4时,一直计算平方和
num = list(str(a)) #读取输入数字的每位数制成列表
a = 0 #初始化a,用于计算每位平方和。此时a值已保存在num里,无需担心丢失。
for i in num: #遍历... |
a78e01a2f3125aa6d1e9aa7d2f20c7abb8cea8ff | Mpreyzner/tdd_in_python | /test_1_fizz_buzz.py | 997 | 3.6875 | 4 | # Write a program that prints one line for each number from 1 to 100
# For multiples of three print Fizz instead of the number
# For the multiples of five print Buzz instead of the number
# For numbers which are multiples of both three and five print FizzBuzz instead of the number
from fizzbuzz import fizzbuzz
import p... |
5dd04a24f97318f4d43e13982144e6577cfc2633 | grk44/classInheritance | /classes.py | 992 | 3.953125 | 4 | # volume/ area Calculator of some shapes
class Dimensions:
def __init__(self, length, width, height, radius):
self.length = length
self.width = width
self.height = height
self.radius = radius
def areaS(self):
return self.radius**2 * 3.14 *4
def volS(self):
return self.radius**3 * 3.14 *(4/3... |
8433531ba1b03d2ba5303e228ca48c25972ab33e | herbeth98/Backup- | /ALGORI/ALGORITMOS 1/QuestaoOnze.py | 155 | 3.734375 | 4 | base= int(input("Valor da base: "))
altura= int(input("Valor da altura: "))
area = ((base * altura)/2)
print("Área do Triângulo: %s " %(area))
|
cb007337f2e96283a12a5ddbb4c7a88ffb630870 | choidslab/Online-Courses | /Udemy/Python_BootCamp2020/Section4/variables_questions.py | 1,237 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 27 09:30:44 2020
@author: Timchoi
"""
# Q1. Ask the user for the raius of a circle and then print the area
radius = float(input('Enter a radius\n >>> '))
pi = 3.14159
area_of_circle = pi * radius**2
print(area_of_circle)
# Q2. Conver fahrenheit to celsius(화씨 -> 섭씨 온도 변... |
755596da8b7801d422386d25d3d3ec6fb10774b2 | PlamenVasilev/python_cource | /Exams/Exam - 26 August 2018/03. Descriptions.py | 699 | 3.75 | 4 | import re
regex = r"name is\s([A-Z][a-z]+\s[A-Z][a-z]+).*?\s([0-9]{2})\syears.*?on\s(\d\d-\d\d-\d\d\d\d)\."
persons = []
while True:
data = input()
if data == 'make migrations':
if len(persons):
for person in persons:
print(f'Name of the person: {person["name"]}.')
... |
69b55b9cf7998d48d9e33ae7695757c142cbf5e3 | jimgregory/raspberrypi | /scripts/bicolor.py | 695 | 3.9375 | 4 | #! /usr/bin/python
# flashes a bicolor led for 10 seconds
import RPi.GPIO as GPIO
from time import sleep
# pins used for LED
pin1 = 19
pin2 = 26
# set which pin numbering system to use
# BOARD = pin layout on board
# BCM = pins layout on Broadcom chip
GPIO.setmode(GPIO.BCM)
# setup pin as input or outpu... |
65acffe6da3bfa328f3f38ff30574c707fc4b65d | avi527/oops-concept | /class_object.py | 1,584 | 4.6875 | 5 | # Object:- object cantain attributes and behaviours
# class:- class can define attributes and behaviours of all the object
# method:- object have attributes and behaviours these are called method in programming
# Example:-
# class => Human
# attributes => name,age,color
# behaviour => eating
class Humans(... |
d08b43e2bb188f3f5911cd53fa6d023831bd8b88 | mgbo/My_Exercise | /2017/построение_графиков/график_теория/theory_1.py | 622 | 3.578125 | 4 |
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
mpl.use('Agg') # не рисовать на экране
fig,ax=plt.subplots() #будет 1 график, на нем
x=np.linspace(-5,2,100) #от -5 до 2 , 100 точек
y1= x**3 + 5*x**2 + 10
y2= 3*x**2 + 10*x
y3= 6*x + 10
ax.plot(x,y1, color="green"... |
f25f7c6b5b27384bec04e11dcabf2e93b8e4d6aa | ronald0807/Running-python | /python_if_statement_practice1/문제4.py | 637 | 3.609375 | 4 |
# 문제 4.
# 복싱체급은 몸무게가 50.80kg 이하를 Flyweight 61.23kg 이하를 Lightweight, 72.57kg 이하를 Middleweight, 88.45kg 이하를 Cruiserweight, 88.45kg 초과를 Heavyweight라고 하자.
# 몸무게를 입력받아 체급을 출력하는 프로그램을 작성하시오.
# # 입력 예: 87.3
# 출력 예: Cruiserweight
몸무게 = float(input("몸무게를 입력하시오."))
if 몸무게 <= 50.8 :
print("Flyweight")
elif 몸무게 <= 61.23 :
... |
5d50108a04a786cb001d552833134cd216a7b8e6 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4422/codes/1638_2449.py | 341 | 3.90625 | 4 | a = float(input("Valor de a: "))
b = float(input("Valor de b: "))
c = float(input("Valor de c: "))
d = float(input("Valor de d: "))
e = float(input("Valor de e: "))
f = float(input("Valor de f: "))
x = (c * e - b * f)/(a * e - b * d)
y = (a * f - d * c)/(a * e - b * d)
if(x, y >= 0.0):
print(x)
print(y)
else:
pri... |
a0fc078cc905470980f1f3eeb4fa9eea89f8fbb7 | tm2josep/eulerPy | /problem4.py | 279 | 3.671875 | 4 | #Euler problem 4
#Find the largest palindrome from the product of two 3 digit numbers
largestPalim = 0
for i in range(0, 999):
for j in range(0, 999):
n = i*j
if(str(n) == str(n)[::-1] and n > largestPalim):
largestPalim = n
print(largestPalim) |
9ead72b232d6e525ab47315cd5773035d048cf82 | yangrencong/pythonstudy | /3.0/number.py | 275 | 3.734375 | 4 | number1_9 = list(range(1,100))
print(number1_9)
for number in number1_9:
if number == 1:
print(str(number)+"st")
elif number == 2:
print(str(number)+"nd")
elif number == 3:
print(str(number)+"rd")
else:
print(str(number)+"th")
|
02599c34e4b34c924dba15fb1d20bff2bd280109 | GANESH0080/Python-WorkPlace | /MembershipOperator/ExampleOne.py | 504 | 4.3125 | 4 | # These operators test for membership in a sequence
# such as lists, strings or tuples. There are two membership operators that are used in Python. (in, not in).
num = 4
num1 = 8
datalist = [1, 2, 3, 4, 5];
if num in datalist:
print(("Line 1 - num is available in the given list"))
else:
print("Line 1 - num is... |
45bfb3057e4a451eb5ca43e18614143fbb9e5c99 | leraved/prog_Vedernikova | /turtle/turtle_square.py | 388 | 3.734375 | 4 | import turtle
turtle.shape('turtle')
def sq(l:int):
for _ in range (4):
turtle.forward(l)
turtle.left(90)
l = 10
for _ in range (10):
sq(l)
turtle.penup()
turtle.left(180)
turtle.forward(10)
turtle.left(90)
turtle.forward(10)
... |
3420dffce5508c9c9804d3b07fa3a9b06a96ceab | juliaguida/learning_python | /week5/star.py | 274 | 3.84375 | 4 |
# Rewrite this code to use for loop and the range() function:
sign = '~'
for i in range(9):
print(sign * i)
# print(sign * 0)
# print(sign * 1)
# print(sign * 2)
# print('~' * 3)
# print('~' * 4)
# print('~' * 5)
# print('~' * 6)
# print('~' * 7)
# print('~' * 8)
|
760df128ea1283db2be4824f281ae7b8031b8111 | vanesabertero/BIMA-3_Assignment2_VanesaBertero | /ApplicationPolygons.py | 3,316 | 4.15625 | 4 | # The Python program calculates different geometrical characteristics of a polygon shape
import math
print("The Python program calculates different geometrical characteristics of a polygon shape")
print()
numOfPoints = int(input("Enter the number of polygon points: "))
if numOfPoints < 3:
letsGo = 0
print("... |
e4c36dbc7236b503be26552eb8b134b8e14373b6 | RocStone/pat_advanced_level_with_python3 | /1026 Table Tennis/1026 Table Tennis.py | 4,536 | 3.5 | 4 | """
start time: 2019年2月20日23:32:53
放弃,我宁可用c++做模拟,也不会再尝试用python来推排队了
"""
from collections import deque
from copy import copy
from datetime import datetime, timedelta
flag_time = datetime.strptime("22:00:00", "%H:%M:%S")
class Person:
def __init__(self, arrive_time, play_time, vip):
self.arrive_time = date... |
c6f79350237f2a5122438a9b350fc398e666689e | TylerSKull19/Weather-Forcast | /Weather.py | 1,478 | 3.9375 | 4 | weather = [['Sunday'], ['Monday'], ['Tuesday'], ['Wensday'],
['Thursday'], ['Friday'], ['Satturday']]
lows = []
highs = []
def weather_forcast():
l = 0
h = 0
while h != 7:
high = int(input("Enter the highest temperatures for each day: "))
addTemp = weather[h]
... |
924013d63e60c0df593ea3c66cb5601afcca2434 | dudengjin/python.two | /python高级2/多态.py/练习F.py | 425 | 3.578125 | 4 | class Animal(object):
def __init__(self,name):
self.name = name
def Game(self):
print("%s在踢球"%self.name)
class tiger(Animal):
def Game(self):
print("%在草地踢球"%self.name)
class cat(object):
def __init__(self,name):
self.name = name
def Game_cat(self,z):
print("%s和%s在草地踢球"%(self.name,z.name))
boluo... |
0163cc47f58325c4f127f406a329cd2261a7dd6d | geekhub-python/akvarium-2-0-VaShu | /dweller.py | 2,188 | 3.890625 | 4 | #!/usr/bin/env python3
from functools import wraps
from random import randint
DWELLER_PREDATOR_EAT = 'RegularFish'
DWELLER_REGULAR_EAT = 'AquaPlant'
DWELLER_COCHLEA_EAT = 'AquaPlant'
DWELLER_PLANT_EAT = 'Oxygen'
def what_eat(*args):
def eat_decor(f):
@wraps(f)
def wrapper(self, prey):
... |
52fa8b4d96a11dfbdd7b6bfafe3407527ede8df5 | sumeyyeakay/CoronaVirusDataAnalysis | /DataSeries.py | 303 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 27 18:27:59 2020
@author: sumeyyeakay
"""
import pandas as pd
sayılar = [0,1,2,3,4,5,6,7,8,9]
seriler = pd.Series(data=sayılar)
print(seriler[seriler>5])
print(seriler[seriler>seriler.mean()])
print(seriler[seriler==4])
print(seriler[seriler <5])
|
169628c06ae30715bd37c379229cbbb5f9d1fb92 | meawoppl/ndsolver | /symbolic/Equation.py | 1,679 | 3.953125 | 4 | class Equation(dict):
def __add__(self, o_dict):
sum_dict = Equation()
sum_dict.update(self)
for key, val in o_dict.iteritems():
if key in sum_dict:
sum_dict[key] += val
else:
sum_dict[key] = val
sum_dict.zero_... |
589317d9050d7ca1347b531d122c476058fd9df7 | lucipeterson/Pythonball | /pythonball.py | 2,732 | 3.625 | 4 | #pythonball.py
import pygame
import time
import random
pygame.init()
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption("Pythonball") #pygame
white_balls = list(range(1,69))
red_balls = list(range(1,26))
five_balls = []
one_ball ... |
c3963cf084ea76229674cc4912c2282ae623797b | root12321/data-structure | /队列.py | 646 | 3.8125 | 4 | class Queue(object):
def __init__(self,tail=5,head=5):
self.tail=tail
self.S=[]
self.head=head
def Enqueue(x):
T.S.append(x)
if T.tail>=5:
T.tail=0
else:
T.tail=T.tail+1
if len(T.S)>6:
return 'upflow'
if len(T.S)<0:
return 'un... |
1973697f7ab6a3c0faaaf19eba9e6a9477173113 | lirenlin/DSA | /74.py | 476 | 3.625 | 4 | def solution (matrix, target):
m = len (matrix)
n = len (matrix[0])
l, h = 0, m * n -1
while l <= h:
mid = l + (h - l) // 2
if matrix[mid // n][mid % n] == target:
return True
elif matrix[mid // n][mid % n] < target:
l = mid + 1
else:
... |
48a884fa3e2fa3bc4a3827ba481dcde2a076ae60 | chc1129/python_jisen | /06/isClassInst.py | 1,501 | 3.703125 | 4 | # クラス - インスタンスのひな型となるオブジェクト
# クラス変数- クラスオブジェクトが保持する変数
# クラス変数を持つクラスを定義
class Page:
book_title = 'Python Practice Book'
Page.book_title # インスタンスがなくても参照できる
print( Page.book_title )
Page.book_title = 'No title' # クラス変数の更新
Page.book_title
print( Page.book_title )
# クラス変数にはインスタンスからもアクセス可能
first_page = Page()
second_... |
d48e31e7dabab3141da910a170162444243e01c2 | RajatPrakash/Python_Journey | /multiple_plot.py | 275 | 3.5625 | 4 | import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 10, 0.5) # x sample size with every 0.5 interval
size = plt.figure(figsize=(5, 5))
plt.plot(x, x, 'r--', x, x**2, 'bs', x, x**3, 'g^', linewidth=5) # red dashes, blue squares and green triangles
plt.show() |
72d59357b6a3931d6b5f5f0d779901af5c52a847 | timgrossmann/aoc-2019 | /day11/python/beckel/painting_robot.py | 1,275 | 3.9375 | 4 | import math
from computer import Computer
def paint(program, initial_color):
computer = Computer(program, [initial_color])
black = []
white = []
position = [0,0]
direction = 90
while(True):
computer.run()
[color, turn] = computer.get_last_output_values(2)
# pain... |
76edf4b93f99bfd98fc9e7ddd43e3bc2cea9cddb | Aasthaengg/IBMdataset | /Python_codes/p03501/s378742665.py | 130 | 3.640625 | 4 | import re
a = input()
a = re.split(" ",a)
b = int(a[0])*int(a[1])
c = int(a[2])
if(b < c):
print(b)
else:
print(c) |
c0c617c67ae12de09af92a07ca7894be31a88a54 | karzuan/grocery-list | /grocery_list.py | 926 | 4.21875 | 4 | def show_help():
print("""
Enter 'HELP' if you need help
Enter 'DONE' if you want to finish the list
Enter 'LIST' if you want to see the list
""")
grocery_list = []
def add_an_item(an_item):
grocery_list.append(an_item)
print("'{}' has been added to the list. Now you have {} items in your g... |
e385954453c928848b882bc2ab9930ca28c2c14e | FWCoder/personal_sandbox | /mc2_p2/test.py | 376 | 3.515625 | 4 | import numpy as np
from numpy import convolve
import matplotlib.pyplot as plt
def movingaverage (values, window):
weights = np.repeat(1.0, window)/window
sma = np.convolve(values, weights, 'valid')
return sma
x = [1,2,3,4,5,6,7,8,9,10]
y = [3,5,2,4,9,1,7,5,9,1]
yMA = movingaverage(y,3)
#print yMA
pl... |
6b70b9893b1bf96b0cad8c00c95f66775eb66c12 | springuper/algorithm | /subsetsWithDup.py | 590 | 3.578125 | 4 | # @param S, a list of integer
# @return a list of lists of integer
def subsets(S):
ret = []
length = len(S)
# sort
S.sort()
# traverse
def traverse(s, level, flag):
if level == length:
ret.append(s)
return
traverse(... |
fd4b2ec39861aa888dad9ae4d1163faa691dffe5 | spritz-group/miniV2G | /examples/v2g_tcp.py | 1,709 | 3.5625 | 4 | #!/usr/bin/python
import socket
class TCPClient:
'''
TCP Client which can send a messsage and get the response if available.
'''
def __init__(self, addrinfo, client_name = "client", server_name = 'server'):
# Connect to the server
self.client_name = client_name
self.server_name... |
8d09483fe1731126f18a0210a4491b38ec439e5e | chhenning/python_tutorial | /snippets/src/class__test.py | 2,222 | 3.5625 | 4 | # %%
class Gizmo:
def __init__(self):
print(f"Gizmo id: {id(self)}")
a = Gizmo()
dir()
# %%
class Demo:
@classmethod
def klassmeth(*args):
return args
@staticmethod
def statmeth(*args):
return args
print(Demo.klassmeth())
print(Demo.klassmeth('spam'))
print(Demo.stat... |
98de9793e10804e0e8b9cd11cfe2d665adc1b5ef | morshedmasud/52-problem-solution-by-Subeen-python- | /problem-37/solution-37.py | 229 | 3.53125 | 4 | # Taking value of 't' from user for test case
t = int(input())
x = 0
while x < t:
n = int(input())
rev = 0
while n != 0:
rev = rev * 10
rev += n % 10
n = n // 10
print(rev, "\n")
x += 1 |
db9d53809aca025dbf3867c8791c0a99c98dd76f | Duruvan/cs591 | /running_counter.py | 2,350 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 17 22:21:07 2018
@author: durus
"""
import numpy as np
import matplotlib.pyplot as plt
def generate_data(n):
""" Generate initial data
Parameters:
n - size
"""
x = np.random.randint(2, size = n)
running_count = np.cumsum(x) #T... |
af5ae6794a02bc1a625f214663c13bcb8ce71d55 | Nasdin/kaggle-competitions-nasdin | /2017Q4SantaGiftMatchingChallenge/utils.py | 172 | 3.796875 | 4 |
import math
def lcm(a, b):
"""Compute the lowest common multiple of a and b"""
# in case of large numbers, using floor division
return a * b // math.gcd(a, b) |
4061b087d6b8832f080f277ca0b9e05ac38c7ea4 | theGreenJedi/Path | /Python Books/Introduction-to-Programming-Python/pybook/TestContinue.py | 165 | 4 | 4 | sum = 0
number = 0
while number < 20:
number += 1
if number == 10 or number == 11:
continue
sum += number
print("The sum is", sum)
|
107261a3a311001958d70fb5d74ec5a7a89bd60c | TogrulAga/Tic-Tac-Toe | /Tic-Tac-Toe/task/tictactoe/tictactoe.py | 2,770 | 3.8125 | 4 | # write your code here
current_player = "X"
def print_grid(grid: str):
for i in range(0, 3):
if i == 0:
print("---------")
for j in range(0, 3):
if j == 0:
print("| ", end="")
print(f"{grid[i * 3 + j]} ", end="")
if j == 2:
... |
5369cbca1f05060ede2b81ce9f479431d63efeb6 | Lixinran1213/python | /python_practice/4/4-10-lianyilian.py | 270 | 3.953125 | 4 | fun = ['foot ball','score','swim','computer game','bar','sing','dance']
print("The first three items in the list are:")
print(fun[0:3])
print("\nThe first three items in the list are:")
print(fun[2:5])
print("\nThe first three items in the list are:")
print(fun[-3:])
|
fa71dc6d518dca9bdea60ad1917421f354f103a4 | yang-lin94/Row-of-seats | /demo/排座位.py | 710 | 3.640625 | 4 | import tkinter as tk
import random
win = tk.Tk()
win.title("排座位助手")
win.geometry("250x100")
win.resizable(0, 0)
win.config(bg="#323232")
list = []
def random_list():
list = []
n = nub_en.get()
i = 1
sum = 0
while i <= int(n):
sum = sum+1
i = i+1
list.append(sum)
ran... |
b2e6492f1084f09253aa97274b3575a653f57364 | priyamshah112/Basic_Python | /python/python/file programs _ error _ exception handling/shortcut.py | 254 | 3.796875 | 4 | def shortcut():
while True:
try:
x = int(input(" enter num.1 - "))
y = int(input(" enter num.2 - "))
sum = (x/y)
print(sum)
except:
print("something is wrong nigga!")
else:
break;
shortcut()
|
1a79426bf78c707a614da7893af6e143f67a9b33 | Akshay1-6180/OOP-Python | /tic-tac-toe/classes/Board.py | 3,190 | 4.03125 | 4 | class Board:
EMPTY = 0
COLUMNS = {"A": 0, "B": 1, "C": 2}
ROWS = (1, 2, 3)
def __init__(self, game_board=None):
if game_board:
self.game_board = game_board
else:
self.game_board = [[0, 0, 0],
[0, 0, 0],
... |
eb63362a0bddd4407f3026e4a630b1a2a068c5ce | joaopver10/Python-EstruturaDeDados | /Aula 14/aula14.py | 809 | 3.765625 | 4 | class Triangulo:
def __init__(self, lado1, lado2, lado3, base,altura):
self.lado1 = lado1
self.lado2 = lado2
self.lado3 = lado3
self.base = base
self.altura = altura
def area(self):
return (self.base * self.altura) / 2
def tipo(self):
if self.lado1 > s... |
bf7445327e6e36bffed5a05f7ce3132c0bfc4fd3 | OOASE/pythonDatatypes | /main.py | 409 | 3.53125 | 4 |
# k = '''plug logistics is the best logistics compny'''
# print(k)
# G = """Godwin is my friend
# of about 5 years"""
# print(G)
# T ="""Tolu is a good guy"""
# print(T)
# print(T[1:3])
# print(T[6])
# T[2] = 'is'
# print(T2)
x = range(10)
for n in x:
print(n)
dict = {'name': 'kunle','shoesize' :42}
print(typ... |
007549a422f9fc9942ac7f18899b5b920ef5ac4d | a-soliman/python-2019 | /07-milestone_2/app.py | 994 | 4.125 | 4 | from utils.database import Database
USER_CHOICE = """
Enter:
- "a" to add a new book
- "l" to list all books
- "r" to mark book as read
- "d" to delete a book
- "g" to get a book by name
- "q" to quit
"""
db = Database("data.db")
db.create_book_table()
def menu():
user_input = input(USER_CHOICE)
while user... |
80b52aff75195f644b64ed27e47d6f929198423f | kshitijjain91/problem-solving-python-new | /turtle_tree.py | 392 | 4 | 4 | import turtle
from turtle import Turtle, Screen
def tree(branch_len, t):
if branch_len > 5:
t.forward(branch_len)
t.right(20)
tree(branch_len - 5, t)
t.left(40)
tree(branch_len - 5, t)
t.right(20)
t.backward(branch_len)
def main():
t = Turtle()
my_win = Screen()
t.left(90)
t.up()
t.backward(100)
... |
f81b95505cc6c61c90ad5aa5195e6a34f2167eb6 | rmj23/Python-files | /CSC 231 - Intro to Data Structures/Exercise 1/Exercise1_ruben_moralesjr.py | 2,086 | 4.34375 | 4 | # Day 1 Exercise
def do_math():
"""
Create code within this function definition to do calculations below:
What is 2 + 2?
What is 10 / 3?
What if I want integer division of 10 / 3?
How do I compute 2 powers 10? (should be 1024)
Write code to show your answers of those questions.
... |
01d0c44c8881f995a2d23fa0e6dad542fda7020f | IoGza/NumPy | /MyArrays2.py | 3,669 | 4.09375 | 4 | import numpy as np
grades = np.array([[87, 96, 70], [100, 87, 90], [94, 77, 90], [100, 81, 82]])
# ROWS - grades for each students
# COLS - grades for each student
a = grades.sum()
b = grades.min()
c = grades.max()
d = grades.mean()
e = grades.std()
f = grades.var()
# Calculates the mean based on the axis
# Doing i... |
9897f776c9f2c7a2a870d718bb272a83d2f0829b | jxzhn/reversi-ai | /reversi.py | 4,498 | 3.515625 | 4 | from typing import Tuple
import itertools
Coordinate = Tuple[int, int]
SIZE = 8
class Reversi():
def __init__(self):
self.size = SIZE
self.board = [[0 for _ in range(SIZE)] for _ in range(SIZE)]
# 初始时棋盘上有四颗棋子
ii = SIZE // 2
self.board[ii - 1][ii] = 1
self.board[ii... |
e3e748739550b34107baf194173f97c28f1f7a50 | KishoreKaushal/ailab | /week11/genetic_algorithm.py | 4,410 | 3.546875 | 4 | # Genetic algorithm: generating target string from random string
import random
import numpy as np
POPULATION_SIZE = 200
# valid characters(genes)
GENES = '''abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .!@#$%^&*()'''
# target string(genome)
TARGET = 'Madness is like gravity.'
class Individual(object):
'... |
28be6509b0e8d9d7d07ae6aa8515d4d48f3ac06a | nicky1503/Python-Fundamentals | /ex_fundamentals/multiple_lists.py | 131 | 3.8125 | 4 | factor = int(input())
count = int(input())
numbers = []
for num in range(1, count+1):
numbers.append(num*factor)
print(numbers) |
59f9a4b8078e8c311e8ae978838bc844c728ed58 | benben123/algorithm | /myAlgorithm/py/TwoPointer/TwoSumDataStrc.py | 996 | 4.03125 | 4 |
"""
Description
English
Design and implement a TwoSum class. It should support the following operations: add and find.
add - Add the number to an internal data structure.
find - Find if there exists any pair of numbers which sum is equal to the value.
Have you met this question in a real interview? Yes
Problem Corr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.