blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
51f4a11463b9659756d1bfef987ac00ff24ff55a | yajoy/lc-500 | /算法/贪心/621.py | 535 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Author : Joey Wong
@Time : 2021/3/11 19:03
@File : 621.py
@Desc : m
"""
from collections import Counter
def func(tasks,n):
dic = Counter(tasks)
dic = sorted(dic.items(),key= lambda x:x[1],reverse=True)
max_task_num = dic[0][1]
temp = (n+1) * (max_task_... |
2ebdd0937aab90ae2021c7ecc8567a274d21ed31 | yajoy/lc-500 | /算法/分治/241.py | 830 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Author : Joey Wong
@Time : 2021/3/26 14:34
@File : 241.py
@Desc : m
"""
def func(expression):
if expression.isdigit():
return [int(expression)]
res = []
for i,v in enumerate(expression):
if v.isdigit():
continue
left = fu... |
4cc15e1c63099d62df9ecc6810891eb1e9e5509f | Vejusatko/Pyladies_beginners_course | /03/task12_string_playground_02.py | 145 | 3.703125 | 4 | letter = 'x'
magnitude = 5
for row in range(magnitude):
for column in range(magnitude):
print(letter, end=' ')
print(end='\n')
|
337f85be2d88afbc566905d057ce32a7266fd9cc | Vejusatko/Pyladies_beginners_course | /02/task09_Ntagons.py | 376 | 3.75 | 4 | from turtle import forward, left, penup, pendown, setposition, exitonclick
#move
penup()
setposition(-200.0,0.0)
pendown()
#draw for N
for i in [5,6,7,8]:
#an N-shape
for j in range(i):
x = 200/i
angle = 180 - (180 * (1 - 2/i))
forward(x)
left(angle)
#move
p... |
67e7009e26afaba638cae79efb3785cae5fade72 | Vejusatko/Pyladies_beginners_course | /03/task04_domecek.py | 446 | 3.8125 | 4 | #Definition
def draw_house(side):
from turtle import forward, left, right, exitonclick
from math import sqrt
#maths
diagonal = sqrt(2*(side ** 2))
#let's draw
forward(side)
left(135)
forward(diagonal)
right(135)
forward(side)
left(120)
forward(side)
left(120)
forw... |
09728eec55e8c509be17e70043d1dbc3a2f1967b | Vejusatko/Pyladies_beginners_course | /04/lokalni.py | 472 | 3.546875 | 4 | '''
pi = 3.1415926
def obsah_kruhu(polomer):
return pi * polomer ** 2
print(obsah_kruhu(100))
'''
'''
def nastav_x(hodnota):
x = hodnota # Přiřazení do lokální proměnné!
print('V ramci funkce je x ',x)
nastav_x(40)
print('x =', x)
'''
from math import pi
obsah = 0
a = 30
def obsah_elipsy(a, b):
obsa... |
7b5f4e2e19ebd956e6570f19e8f787cf24d5d907 | jeffstewart/BlackJack | /probabilities.py | 7,131 | 3.921875 | 4 | #Jeff Stewart
#1/25/12
#Jan 047
def player_cards_for_hit (total):
"""Counts the number of cards that are possible for a player to accept from hitting without causing the player to bust.
Returns an integer value of the number of cards which will not cause a player to bust.
"""
max_val = 21 - total #ma... |
5f552e161d83154478e8d1b54be01c20ea61c783 | farhadjava/Tkinter | /Self adjusting widgets.py | 231 | 3.984375 | 4 | from tkinter import *
root = Tk()
label1 = Label(root,text = "First",bg = "Red",fg = "white")
label1.pack(fill = X)
label2 = Label(root,text = "Second",bg = "Blue",fg = "Green")
label2.pack(side = LEFT,fill = Y)
root.mainloop()
|
15e33c3d556df6195ed7e245b4068df7dd79c6e5 | matthew-huber/bme590hrm | /fileReader.py | 2,210 | 3.5625 | 4 | import csv
import logging
def load_csv(filename):
"""
loads data from filename, returning it as a list of times and voltages
:param filename: (string) csv file to load
:return:
times: (list) array of times read from file
voltages: (list) array of voltages read from file
"""
t... |
9a3aeb8260935d11d03d3b26f14eccc22d059b4b | grandq33769/llh | /Python/graphic/demo.py | 290 | 3.75 | 4 | '''Demo script for using matplotlib to plot graph'''
import matplotlib.pyplot as plt
import numpy as np
X = np.arange(0, 360)
Y = np.sin(X * np.pi / 180.0)
plt.plot(X, Y)
plt.xlim(-30, 390)
plt.ylim(-1.5, 1.5)
plt.xlabel("x-axis")
plt.ylabel("y-axis")
plt.title("The Title")
plt.show()
|
42ff4b8a55a5a8ada46acd378036a34296a7d445 | bittybueno/OOAD-Project2 | /Behaviors/RoamBehavior.py | 479 | 3.6875 | 4 | import abc
from abc import ABC, abstractmethod
import random
############# Using a RoamBehavior Interface to customize the behavior ###############
class RoamBehavior(object):
def roam(self):
pass
class ZoomiesRoam(RoamBehavior):
def roam(self):
print("ZOOOOOMIES. ZOOOOOOOOOM.")
class... |
0d75a6be9dc92e3a33d7439e6ebc56f0985229ef | sa-proj/proj-learn-python | /conditions.py | 191 | 4.1875 | 4 | _get_age = input("How old are you?")
if int(_get_age) > 19:
print ("You are an adult")
elif 12 <= int(_get_age) <= 19:
print ("You are a teenager")
else:
print ("You are a kid")
|
baedc0b0deb8898cb99ee0d3357c6bc8d69c8e04 | sa-proj/proj-learn-python | /pirple/basic-loops-pirple.py | 779 | 4.25 | 4 | # Function to find if number is prime
def isPrime(num):
flag = False # flag to decide later to return is prime number true or false
if num == 1:
flag = True # return not a prime number
if num > 1:
for i in range(2, num):
if (num % i) == 0:
flag = True
... |
8f137d6a3f7f81d7b6109c9cc9e54473d06b3e8b | dzikriqalampacil/Project-Dzikri | /calculator_tkinter.py | 4,623 | 3.546875 | 4 | import tkinter
window = tkinter.Tk()
window.title("Calculator Ku")
window.geometry('400x300')
masukin = tkinter.Entry(window, width=60, borderwidth=5)
masukin.grid(row=0, column=0, columnspan=4, padx=10, pady=10)
def myClick(number):
current = masukin.get()
masukin.delete(0, tkinter.END)
... |
df99aa152a898a5fa2d66fd402448654cb56fb72 | iqzar/Marksheet-assignment1 | /Task13.py | 310 | 4.03125 | 4 | #Python program that will return true if the two given integer values are equal or their sum or difference is 5.
f_num =int(input("Enter first number: "))
s_num =int(input("Enter second number:"))
if f_num == s_num or f_num+s_num == 5 or f_num-s_num == 5 :
print("True")
else :
print("Fasle")
|
dbb6a057a7b41f04f72850eccfb5459ac6e4f7ac | iqzar/Marksheet-assignment1 | /Task12.py | 190 | 4.09375 | 4 | #Calculate area of triangle :
H =int(input("Enter height : "))
B =int(input("Enter baase : "))
#Formula for area of triangle is height*base/2
A =H*B/2
print("Area of triangle is:", A)
|
538dd7ed1afb68115b6101a8b1a5c509d6fa791b | gabssluc/untitled5 | /exrepet.py | 150 | 4.09375 | 4 | a = int(input("digite um numero de 0 a 10\n"))
while a <= 0 or a >= 10:
a = int(input("ENTRADA INVÁLIDA! digite novamente\n"))
print("parabens")
|
d1e23c7c63ed25b88f39104b8129fbf37c58aeeb | gabssluc/untitled5 | /exrepet2.py | 237 | 3.984375 | 4 | a = str(input("digite seu nome\n")).upper()
pas = str(input("digite sua senha\n")).upper()
while a == pas:
pas = str(input("ERRO! Sua senha não deve ser igual ao seu nome, digite outra seenha: \n")).upper()
print("conta realizada")
|
94c59cb9cd6b7131a6431a8198d67c53b024aa6c | JanNoszczyk/cracking_the_coding_interview | /palindrome_permutation.py | 1,368 | 4.28125 | 4 | # Given a string, write a function to check if it is a permutation of a palindrome.
# A palindrome is a word or phrase that is the same forwards and backwards.
# A permutation is a rearrangement of letters.
# The palindrome does not need to be limited to just dictionary words.
# EXAMPLE
# Input: Tact Coa
# Output: True... |
48f7f5f69d384f76061de64356a372dfe793b773 | zspo/MyKaggleLearning | /TianChiMatch/src/test/pytest.py | 897 | 3.5 | 4 | # -*- coding: utf-8 -*-
'''
Created on 2018年3月6日
@author: zwp
'''
import numpy as np;
# 特征数,输入张量的shape
feature_size = 4;
# 标签数,输出张量的shape
label_size = 4;
# 输入向量调整,尺寸
cnn_input_size=int(np.ceil(np.sqrt(feature_size)));
# 输入向量调整,深度
cnn_input_deep=1;
def change_to_cnn_input(x):
'''
将[None,feature_size]的输入... |
192969de2434606352514ea9436153a3bf5a98df | cinnabarmoth/scrollphat | /morseFlasher.py | 2,088 | 3.921875 | 4 | #!/usr/bin/env python
"""asks user to enter a message and displays it in the terminal window converted into Morse code. The user is then prompted to enter the message again (or a new message) which is displayed using the LED panel to flash the dots and dashes"""
import scrollphat
import time
#incomplete dictionary f... |
9e60ee7d82f04df33f5ed9257a5bb991915642ba | gaya-/hpn_cram | /toy_hpn/world_state.py | 7,167 | 3.5 | 4 |
import copy # for creating world state equivalents for real-world objects
from toy_fetch_place.world import Item, Robot, Environment, World
class WorldStateItem(Item):
def __init__(self, name, item_type):
Item.__init__(self, name, item_type)
@classmethod
def to_world_state(cls, item):
... |
0581bd27a1afe9b0a5ce72be2362c13aaca5f8c4 | sander-skjulsvik/IN1910 | /lectures/2019.09.10/line.py | 815 | 3.796875 | 4 | import numpy as np
class Parabola:
def __init__(self, c0,c1,c2):
self.c0, self.c1, self.c2 = c0, c1, c2
def __call__(self, x):
return self.c0 + self.c1*x + self.c2*x**2
def table(self, L, R, N):
t = np.linspace(L, R, N)
s = f'{self.__class__.__name__} \n'
for x in... |
47a52e8ded41065dc9704b416c5e41da823e9f8a | sander-skjulsvik/IN1910 | /tasks/week3/Exercise1_Checking_primes.py | 996 | 4.21875 | 4 |
def is_prime(n):
# print(f'n = {n}')
'''
Returns a boolean value, True if prime or false if not a prime.
1st check right input, 2nd check if
'''
#1st
if not (isinstance(n, int) and n > 0):
raise TypeError(f"input must be a int and bigger than 0, n = {n}, type(n) = {type(n)}... |
bf4530c2a5831aa09f4195e029bb98eff3fd9403 | sander-skjulsvik/IN1910 | /lectures/2019.09.13/L7/abstract_classes.py | 462 | 4.09375 | 4 | from abc import ABC, abstractmethod
class Animal(ABC):
def __init__(self, name):
self.name = name
@abstractmethod
def sound(self):
pass
def make_sound(self):
print(f"{self.__class__.__name__} {self.name} sais {self.sound()}")
class Dog(Animal):
def sound(self):
... |
f6b802ed3391cceebdb69b311c98af60055e7dd1 | LeoGalda/Simulacion | /Guia1/ejercicio6.py | 74 | 3.828125 | 4 | x = 5
for i in range(10):
print(x, end=" - ")
x = (3 * x) % 150
print() |
22721ed6fe60dcb5aefd7682370aab3b136c9654 | exploring-curiosity/DesignAndAnalysisOfAlgorithms | /Assignment1/q2_5sel_sort.py | 445 | 3.8125 | 4 | def read_array():
a = input("> ").split()
return a
def minimum(a, low, high):
mini = int(a[low])
pos = low
for i in range(low + 1, high):
if int(a[i]) < mini:
pos = i
mini = int(a[i])
return pos
def sel_sort(a):
for i in range(0, len(a) - 1):
mind ... |
63d80afaa007e1643021f54140ada66caf4d61c6 | exploring-curiosity/DesignAndAnalysisOfAlgorithms | /Assignment2/q1_2power_itr.py | 195 | 4.21875 | 4 | def power(a,n):
x=1
for i in range(0,n):
x*=a
return x
a=int(input("Enter the value of x : "))
n=int(input("Enter the value of power : "))
print("The result is ",power(a,n)) |
b65bc341d574efe6469b4705521a88a59ab5eaa5 | exploring-curiosity/DesignAndAnalysisOfAlgorithms | /Assignment1/q3_7powersof2.py | 323 | 3.953125 | 4 | def preordering(a):
n=len(a)
for i in range(0,n-1):
if a[2**i]<a[2**(i+1)]:
break
else :
a[2**i],a[2**(i+1)]=a[2**(i+1)],a[2**i]
a={}
n=int(input("enter the number of terms : "))
for i in range(0,n):
a[2**i]=int(input("Enter number : "))
preordering(a)
print(a.values... |
aad846a557a4c3ab05df086fb5f3770e0d40e931 | exploring-curiosity/DesignAndAnalysisOfAlgorithms | /Assignment1/Fibonacci-recursive.py | 173 | 3.84375 | 4 | def fibr(n):
if(n==0):
return 0
elif(n==1):
return 1
else:
return fibr(n-1)+fibr(n-2)
inp=int(input("Enter number :"))
fib=fibr(inp)
print("result is " + str(fib))
|
0d01c8c0d7c732b885889ff706caa220a88e1adf | randytqw/web_robot_simulator | /web_robot_parser.py | 1,505 | 3.75 | 4 | commands = ['PLACE', 'MOVE', 'LEFT', 'RIGHT', 'RESET']
directions = ['NORTH', 'SOUTH', 'EAST', 'WEST']
def parse(line, robot):
input = line.split()
if input[0] not in commands:
print('invalid command')
return robot
if input[0] == 'PLACE':
try:
params = input[... |
f5d06f35ddd8a40a25eb1d5784081ee342c1535d | drcdev/euler-offline | /inProgress/euler034.py | 463 | 3.59375 | 4 | import sys
from time import clock
def factorial(num):
if num == 0: return 1
f = 1
for i in range(num, 1, -1):
f *= i
return f
def solve():
facts = []
ans = 0
for i in range(10):
facts.append(factorial(i))
for i in xrange(10, 2540161):
sumf = 0
num = i
while num > 0:
d = num % 10
num //= 10
... |
73f81bcc44fe2e0ee19fac461c6019a781ad32a6 | HalforcNull/GoogleFoo | /Fuel_Injection_Perfection.py | 3,035 | 4.1875 | 4 | """
Fuel Injection Perfection
=========================
Commander Lambda has asked for your help to refine the automatic quantum antimatter fuel injection system for her LAMBCHOP doomsday device. It's a great chance for you to get a closer look at the LAMBCHOP - and maybe sneak in a bit of sabotage while you're at it ... |
7cf41bc73948eeea8412eec7bc19a8e1813119da | RPCodeBox2/07_Python_TimeSeries | /01_Python_TimeSeries.py | 1,723 | 3.546875 | 4 | # In[1] - Documentation
"""
Script - 01_Python_TimeSeries.py
Decription - Sample Timeseries graphs
Author - Rana Pratap
Date - 2021
Version - 1.0
https://www.datacamp.com/community/tutorials/time-series-analysis-tutorial
"""
print(__doc__)
# In[2] - Import packages and Data
import pandas as pd
import matplotlib.pyplot... |
ef572c643b1fff7ae79fad606c3939a8bf0cfd01 | DeathNapalm/Curseach_New_Order | /gui/gui_main.py | 660 | 4.1875 | 4 | from Tkinter import *
root = Tk()
def Hello(event):
print "Yet another hello world"
btn = Button(root, #родительское окно
text="Click me", #надпись на кнопке
width=30,height=5, #ширина и высота
bg="white",fg="black") #цвет фона и надписи
btn.bind("... |
a45df5d09c2f528d208bed24b7b30db72d490617 | blackmamba22/python | /software-eng-concepts/projects/FirstSteps.py | 2,193 | 4.1875 | 4 | # -*- coding: utf-8 -*-
import sys
class FirstSteps:
"""Basic python programs to get started."""
def __init__(self):
pass
@staticmethod
def richter_scale(r_value=None):
"""
Prompt user to enter a richter scale # and perform calculations to
display equivalent amount of ... |
28f0475d10e17f9fdc26f52b042d75f35c75d12e | blackmamba22/python | /code_wars/python/pascal_case_to_snake_case.py | 530 | 4.375 | 4 | """
Description:
Complete the function/method so that it takes CamelCase string and returns the
string in snake_case notation. Lowercase characters can be numbers. If method
gets number, it should return string.
"""
def to_underscore(string):
string = str(string)
result = ""
for i in range(len(string)):
... |
dbdf245acdac888f7866467dca1a778cfcb64d17 | rajarameshmamidi/NLP | /nlp_text_generation.py | 2,023 | 3.765625 | 4 | # Read in the corpus, including punctuation!
import pandas as pd
#Build a Markov Chain Function
from collections import defaultdict
#Create a Text Generator
import random
data = pd.read_pickle('corpus.pkl')
data
# Extract only Ali Wong's text
ali_text = data.transcript.loc['ali']
ali_text[:200]
print('da... |
4f623065c7c921ddbcb292e230be92e2bcfcf0cd | vikash5247/CODING-NINJA-INTRODUCTION-OF-PYTHON | /Number Pattern 3.py | 439 | 3.5 | 4 | """
5
1 1
12 21
123 321
1234 4321
1234554321
"""
num=int(input())
i=1
while num>=i:
j=1
while j<=i:
print(j,end="")
j+=1
space=1
spaces=1
while spaces<=(num-i):
print(" ",end="")
spaces=spaces+1
spaces=1
while spaces<=(num-i):
print(" ... |
a1ea022e4c85337b70d9c38dc194360c41ae31bc | vikash5247/CODING-NINJA-INTRODUCTION-OF-PYTHON | /Code : Diamond of stars.py | 427 | 3.71875 | 4 | """
7 Number is always odd
*
***
*****
*******
*****
***
*
"""
n=int(input())
firstHalf = (n+1)//2
secondHalf=n//2
currentRow=1
while currentRow<=firstHalf:
spaces=1
while spaces<=(firstHalf-currentRow):
print(" ",end="")
spaces=spaces+1
currentCol=1
while currentCol<=(... |
03c7616773ebfbd6f4bad8f7c288e197e3bf9cfb | vikash5247/CODING-NINJA-INTRODUCTION-OF-PYTHON | /Palindrome.py | 98 | 3.96875 | 4 | num=input()
x="".join(reversed(num))
if num == x:
print("true")
else:
print("false")
|
7806d5654ca99786c850bdca92c065ca5f754a90 | vikash5247/CODING-NINJA-INTRODUCTION-OF-PYTHON | /Sum of even & odd.py | 355 | 3.953125 | 4 | """
Digits mean numbers, not the places! That is, if the given integer is "13245", even digits are 2 & 4 and odd digits are 1, 3 & 5.
Input format :
Sample Input 1:
1234
Sample Output 1:
6 4
"""
a=input()
b=list(map(int,a))
even=0
odd=0
for i in range(0,len(b)):
if b[i]%2 ==0:
even=even+b[i]
else:
... |
3eb5b65ed507c9e9932b222cd832f1099a50a3ac | rohanr07/Picture-Processor | /PictureProcessor.py | 3,559 | 3.9375 | 4 | #RohanRenganathan
from PIL import Image
from PIL import ImageOps
def chooseFilter(img) :
print ("Available Filters:")
print ("-----------------")
print ("1. Invert Colour")
print ("2. Gray Scale")
print ("3. Rotate image")
print ("4. Flip image")
print ("5. Exit\n")
userChoice = int(... |
7e3ee4526602881cb9671d7ae060d4babbe4d6a8 | SmartRiver/leetcode-exercise | /95.不同的二叉搜索树-ii.py | 1,185 | 3.859375 | 4 | #
# @lc app=leetcode.cn id=95 lang=python3
#
# [95] 不同的二叉搜索树 II
#
# https://leetcode-cn.com/problems/unique-binary-search-trees-ii/description/
#
# algorithms
# Medium (59.98%)
# Likes: 225
# Dislikes: 0
# Total Accepted: 14.3K
# Total Submissions: 23.7K
# Testcase Example: '3'
#
# 给定一个整数 n,生成所有由 1 ... n 为节点所组成的... |
cd22d9683ba3dee9e4505482272ef3cd529a7228 | hevervie/Python | /date.py | 274 | 3.96875 | 4 | #!/usr/bin/env python
# encoding: utf-8
import datetime
today=datetime.date.today()
print 'today:'
print today
oneday=datetime.timedelta(days=1)
#print oneday
yesterday=today-oneday
tomorrow=today+oneday
print 'yesterday:'
print(yesterday)
print 'tomorrow:'
print(tomorrow)
|
8ab2b8c0a2e4cb37e3278b10e60a353f8c96e4cb | hevervie/Python | /sort.py | 310 | 3.5625 | 4 | #!/usr/bin/env python
# encoding: utf-8
list=[]
for i in range(0,5,1):
x=input('请输入第'+str(i+1)+'个元素')
list=list+[x]
for i in range(0,5,1):
for j in range(0,5-i-1,1):
if(list[j]>list[j+1]):
k=list[j]
list[j]=list[j+1]
list[j+1]=k
print list
|
26e0b6179586309694b9456d7d54ce91598dd1fb | hevervie/Python | /countchar.py | 520 | 3.546875 | 4 | #!/usr/bin/env python
#coding=utf-8
# File Name: countchar.py
# Author: ZhouPan / github:dreamer2018
# Mail: zhoupans_mail@163.com
# Blog: blog.csdn.net/it_dream_er
# Function:计算文件字符个数
# Created Time: 2016年02月04日 星期四 17时13分42秒
import sys
if len(sys.argv) <2 :
print "Usage countchar.py file_name"
exit()
file_na... |
197f99618368781d0b0552bee35449e4385379bd | morenoh149/deeplearning | /optimization.py | 1,718 | 3.59375 | 4 | import itertools
import math
import numpy as np
def run_iterations(iterator, max_iterations, abs_tol=1e-20):
""" Run iterative optimization method such as gradient descent. Stop early if cost doesn't change. """
previous_cost = None
limited_iterator = itertools.islice(iterator, max_iterations)
for i,... |
62201d5a13c1400566601a4ff730e195c5391c55 | MarekMyjak/anomaly-detection | /ex1/solution1.py | 290 | 3.59375 | 4 | import numpy as np
def detect(train_data: np.ndarray, test_data: np.ndarray) -> list:
mean = np.mean(train_data)
std = np.std(train_data)
mean_min = mean - 3 * std
mean_max = mean + 3 * std
return [1 if data < mean_min or data > mean_max else 0 for data in test_data]
|
78f29b6a47a6cdaf8fbab0163fe8ec610ff687d5 | NehaJ007/python-lab | /nh.py | 101 | 4.0625 | 4 | s=raw_input("enter the string")
if(s==s[::-1]):
print "palindrome"
else:
print "not a palindrome"
|
10a28e12a2287821a99ab1aa4155de2cc8096857 | CMPUT291F18P2/Project2 | /fileparser.py | 6,673 | 3.59375 | 4 | # -*- coding: utf-8 -*-
'''
NOTE: I do not recommend touching anything in this file currently
It works, and all we need to extract from it is dataDict which is
a dictionary that has all the information from the file we had to
read
'''
''' Given a line, find the next tag
... |
1ea2f67b67aa38b7cd1de30432874910f302cec0 | larebskhan/finalGradeCalculator | /gradeCalculator.py | 1,618 | 3.9375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tues Nov 17 2020
@author: Lareb Khan
"""
#TODO: Add comments
def main():
moreGrades = 0
moreSubCat = 0
weightIndex = 0
print("Enter the name of the course, followed by an enter, and the number of different sub-sections (projects, homeworks,... |
bc4b53a42a9947b8acae4a80cedcaf4b9c72c309 | msferreira-prof/ead_python | /aula1/6_repeticao.py | 311 | 3.703125 | 4 | # for
nome = "Marcos da Silva Ferreira"
lista = [1, 2, 3, 4, 6]
numero = range(0, 30)
for letra in nome:
print(letra)
print("\n")
for n in lista:
print(n)
print("\n")
for n in range(0, 10):
print(n)
print("\n")
for n in numero:
print(n)
print("\n")
for n in range(0, 10):
print(f'Imprimindo ... |
ff6cf70bce154c8381fbf1093026611b8091d182 | ernawulandarii/SIPENULIS | /Sipenulis/User.py | 415 | 3.5 | 4 | class User:
def __init__(self, id, role, name, username, password, time):
self.id = id
self.role = role
self.name = name
self.username = username
self.password = password
self.time = time
def to_dict_set(self):
return {"id_user": self.id, "role": self.ro... |
f424a849feca52c61c484bf4473e0ce20a37880b | ghoshtiyasha/first_project | /calc2.py | 913 | 3.859375 | 4 |
def calculator(sum, num):
#exp_split(num)
if (num[0] == '*'):
sum = sum * float(num[1:])
elif (num[0] == '/'):
sum = sum / float(num[1:])
else:
sum = sum + float(num)
#print("sum is the following")
#print(sum)
return sum
def exp_split(exp):
plus= exp.split(... |
b722ca63e7c5880750a8876b5f69b25c81195a9c | Tracy219/coinGuessingGame | /coinGuessingGame.py | 1,237 | 4.46875 | 4 | #!/usr/bin/env python
# This project is a easy guessing game. Users will guess the side of the coin and the game
# can keep the highest score.
from random import choice
def coin_flip():
coinSide = choice(["heads", "tails"])
return coinSide
# --------------------- Main Program Below ------------------------
f = ope... |
fdb44d10ca062cb960fe02675fe572ec8bc0d2d6 | itarvin/leetcode | /python/386lexicalOrder.py | 354 | 3.765625 | 4 | from typing import List
class Solution:
def lexicalOrder(self, n: int) -> List[int]:
res = []
for i in range(1, n+1):
res.append(str(i))
res.sort()
res = [int(x) for x in res]
return res
if __name__ == '__main__':
solution = Solution()
result = solution.l... |
58dbf92272fa5e11be6d594862f3f696341426bb | canberkturan/PythonProjects | /Romarakamları.py | 940 | 3.65625 | 4 | #!usr/bin/python3
#-*-coding:utf-8;-*-
import imza
imza.imza("Canberk Turan","Roma Rakamları")
rakamlar={0:'',
1:'I',
5:'V',
10:'X',
50:'L',
100:'C',
500:'D',
1000:'M'}
sayi={0:(0,0),
1:(1,0),
2:(1,1),
3:(1,1,1),
4:(1,5),
5:(5,... |
326dbcf8a5b9fb62587e638cef3131c253b0e102 | sirxqyang/wbb | /bed_divide.py | 9,110 | 3.5 | 4 | #! /usr/bin/env python
"""this script was used to divide wig file into 24 wig files (24 chromosomes).
positive sense strand
Date: 1-9-2013
Steven Yang @ Tongji University"""
# Gather My code in a main() function
def wigdivide(inputbed):
# open 24 wig files put each row into corresponding files
import os
... |
c8de3810e828d1b0f9c2f7ac3dd4214a32c554c5 | nishantsahoo/APT-Assignment-3 | /Q1.py | 1,149 | 3.859375 | 4 | import random
indices = list(range(0, 100))
userDictionary = {} # empty dictionary
intCount = 0
stringCount = 0
counter = 0
while 1:
value = str(input('Enter a value: '))
ans = input('Want to enter another value? y/n: ')
if value.isdigit():
intCount += 1
if not value.isdigit():
stringCo... |
cbbde08cb1d8dd474a184c0580918748e9d917d3 | FuturaeVisionis/HelloWorld | /HelloWorld/HelloWorld.py | 1,100 | 4.09375 | 4 | #this is a comment
#and I can add a lot of cool stuff
print ("The monkey eats nuts\n and drinks water from the river")
print(3+6)
print(6*9)
#try using \n! Nifty, an't it?
print("I like oranges\ and bananas to")
#to print the backslash when the next word starts with a n
print("what i I wanted is \\news")
name = input("... |
bac988491ed639f2ffa714a9052c929fed011044 | jenskutilek/TypoLabs2016 | /08 Draw Polygon In Glyph.py | 1,306 | 3.78125 | 4 | # MenuTitle: 08 Draw Polygon In Glyph
from mojo.roboFont import CurrentGlyph
from math import cos, pi, radians, sin
def draw_polygon(pen, x, y, diameter=50, n=8, phi=0.0, clockwise=False):
"""
pen: a RoboFab pen.
(x, y): center coordinates
diameter: diameter of the polygon
n: num... |
173ac1d63b6f0b6b8e059e935abfbae2d39967bf | yot777/Python-Primary-Learning | /Chapter8/8.1Python类和对象举例.py | 768 | 4.15625 | 4 | #类名:Dog(类名的第一个字母一般是大写)
class Dog:
#定义一个构造方法要包含类所拥有的全部属性,构造方法的第一个参数必须是self不能变,接下来是各个属性名
def __init__(self,types,name,age):
self.types=types
self.name=name
self.age=age
#方法:intro (方法名的第一个字母一般是小写,只有一个参数self)
def intro(self):
print("我是一只%s,名字是%s,年龄是%d岁" %(self.types,self.name,self.age))
... |
7258460893ff624ff5d8c6b2c87d8b55589b3a9a | yot777/Python-Primary-Learning | /Chapter6/6.1Python条件判断——if语句举例.py | 345 | 3.859375 | 4 | dog_age = int(input('Age of the dog: '))
human_age=0
if dog_age == 1:
print('This dog is about 14 human years old.')
elif dog_age == 2:
print('This dog is about 22 human years old.')
elif dog_age > 2:
human_age = 22 + (dog_age -2)*5
print('This dog is about '+str(human_age)+' human years old.')
else:
... |
74d2ff1440564efda479d82bf999f75e0478e867 | yot777/Python-Primary-Learning | /Chapter7/7.4Python函数返回值——yield.py | 127 | 3.78125 | 4 | def func(n):
for i in range(2,n):
print("i=",i)
print("i*i=",i*i)
yield i*i*i
for s in func(5):
print("s=",s)
|
14788f1f7b881da45d38991cdf8c2c52c916b859 | sezasurita/Exercicios-phyton | /Exercícios/Ex04.py | 165 | 3.734375 | 4 | a=input('Digite algo:')
print('O tipo é:',type(a))
print('É uma letra?:',a.isalpha())
print("É numérico?:",a.isnumeric())
print('Está maiúsculo?:',a.isupper()) |
2f0803b60dbf6317f2e4d4a99a2aa940e8902200 | ojayo/blogly | /models.py | 1,170 | 3.515625 | 4 | """Models for Blogly."""
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def connect_db(app):
""" Connect to database """
db.app = app
db.init_app(app)
class User(db.Model):
"""" User """
__tablename__ = "users"
id = db.Column(db.Integer,
primary_key=True,
... |
330e92dfebe08d19960c328edf48722378297639 | hanhmai/BTLapTrinh2 | /prefixcodetree.py | 1,746 | 3.5 | 4 | class Node:
def __init__(self, value):
self.left = None
self.right = None
self.value = value
class Tree:
def __init__(self):
self.root = Node(None)
self.current = None
def add(self, codeword, symbol):
self.current = self.root
for i in ra... |
b9f7cfecd9e480cae5c54fc87e9fa06b3ff70eb4 | kamath/Factorizr | /caesar.py | 567 | 3.71875 | 4 | #Uses sieve of Eratosthenes to compile list of primes and add them to the database
import sqlite3 as lite
import sys
con = lite.connect('primes')
dd = 0
number = 9999999
def sieve(n):
np1 = n + 1
s = list(range(np1))
s[1] = 0
sqrtn = int(round(n**0.5))
for i in xrange(2, sqrtn + 1):
if s[i]... |
378016a066283a73b9de4f546151c22944368106 | imprabhusk/Python | /Exercise/For Loops/BinaryToHexadecimalConverterApp.py | 3,558 | 4.78125 | 5 | """ Description:
You are responsible for writing a program that will generate binary and
hexadecimal values from 1 up to a specified user value. Recall that decimal is
a base 10 number system, binary is a base 2 number system, and hexadecimal is
a base 16 number system. Your program will use list slicing to first only... |
05dd31b6abe7c71b1b9e6671308b1c3cf15e0ac2 | imprabhusk/Python | /Exercise/While Loops/EvenOddNumberSorterApp.py | 3,810 | 4.5625 | 5 | """ Description:
You are responsible for writing a program that sorts a list of comma separated
numbers as either even or odd. Upon sorting the numbers into two groups, your
program will then sort each group numerically and display the results.
Step by Step Guide:
● Print a welcome message.
● Create an active flag v... |
162b93ecc0f47261a1dc28905408d3e43a540bfc | imprabhusk/Python | /Exercise/Conditionals/GuessMyNumberApp.py | 2,210 | 4.5625 | 5 | """ Description:
You are responsible for writing a program that will play the classic “Hi Low”
game. Your program will randomly pick a number between 1 and 20. Users will
then guess the number. With each guess, your program will respond that the
user’s guess is either too high or too low. When the user guesses correct... |
46ed0e86a9303b867dbe162f69e5503c0a49f406 | imprabhusk/Python | /Exercise/Conditionals/VoterRegistrationApp.py | 2,788 | 4.84375 | 5 | """ Description:
You are responsible for writing a program that will simulate registering to
vote. If a user is 18 or older, your program will present them with a list of
potential political parties to register for. Upon choosing a party, your
program will confirm that the user has registered and print a specific mess... |
3e1054d18cea8d00a60847ce51720c706a96ad99 | aasifbkhan/pyPrograms | /primefromrange.py | 240 | 3.96875 | 4 | a = int(input("Enter starting point : "))
b = int(input("Enter ending point : "))
print("Prime numbers in between {} to {}".format(a,b))
for n in range(a,b+1):
if n>1:
for i in range(2,n):
if n % i == 0:
break
else:
print(n) |
f7f701d7ad4980a7385e7ce52f1e20a511c73309 | cabudies/Python---Introduction | /for-loop.py | 786 | 4.34375 | 4 | # use this for loop to execute the result in the following manner
# 011222
for i in range(0,3):
for j in range(0,3):
print(i)
# use this for loop to execute the result in the following manner
# 000111222
for i in range(0,3):
for j in range(0,3):
print(i, end='')
# use this for loop... |
259db131a0285d756d13c265567d14ff15659490 | bsdtux/exercism_io | /python/grains/grains.py | 307 | 3.734375 | 4 | def square(number):
if not (number > 0 and number < 65):
raise ValueError("square must be between 1 and 64")
total = 1
for _ in range(1, number):
total += total
return total
def total():
total = 0
for i in range(1, 65):
total += square(i)
return total
|
597b1fa3daf29ca7447bf9b3fb0c173a2905d68e | Sewi1808/ISA_KursPython3KRK | /day_13/test_TTD.py | 512 | 3.6875 | 4 | import unittest
from .person import Person
class TestPerson(unittest.TestCase):
def test_if_person_exist(self):
p = Person()
self.assertIsInstance(p, Person)
def test_if_person_has_name_and_surname(self):
p = Person()
self.assertTrue(hasattr(p, 'name'))
self.assertT... |
9cf7aac4c9654f7a577ce3595628716cfd7f3228 | jocelo/rice_intro_python | /practice_excercises/week_3b/05_challenge.py | 729 | 3.703125 | 4 | # Reflex tester
###################################################
# Student should add code where relevant to the following.
import simplegui
total_ticks = 0
first_click = True
elapsed = 0
# Timer handler
def tick():
global elapsed
elapsed += 1
# Button handler
def click():
global elapsed
global ... |
a238e4217cb44fa8ad6c62d6e4e55b91d7193490 | jocelo/rice_intro_python | /practice_excercises/week_5a/05_ball_grid.py | 610 | 4.0625 | 4 | # Ball grid slution
###################################################
# Student should enter code below
import simplegui
BALL_RADIUS = 20
GRID_SIZE = 10
WIDTH = 2 * GRID_SIZE * BALL_RADIUS
HEIGHT = 2 * GRID_SIZE * BALL_RADIUS
# define draw
def draw(canvas):
for i in range(GRID_SIZE):
for j in range(GR... |
4a42e2c865b83cd6d08e6e5752efd23f96f8ffdc | jocelo/rice_intro_python | /practice_excercises/week_5b/04_image_click_template.py | 811 | 3.578125 | 4 | # Image positioning problem
###################################################
# Student should enter code below
import simplegui
# global constants
WIDTH = 400
HEIGHT = 300
IMG_SIZE = (95, 93)
IMG_ORG_POS = [IMG_SIZE[0]/2,IMG_SIZE[1]/2]
img_pos = [WIDTH/2, HEIGHT/2]
# load test image
img = simplegui.load_image("h... |
e032c34d4ecc80a0b135bff12058e1f2dc8631e2 | jocelo/rice_intro_python | /practice_excercises/week_0b/03_perimeter_of_rectangle.py | 246 | 3.75 | 4 | #width = 4
#height = 7
#width = 7
#height = 4
width = 10
height = 10
perimeter = (width*2)+(height*2)
print "A rectangle " + str(width) + " inches wide and " + str(height),
print "inches high has a perimeter of " + str(perimeter) + " inches." |
26bccd5055ddcce5f383614a20121d1989db84ad | KaylaZhou/PythonStudy | /PPy/Set.py | 1,200 | 3.84375 | 4 | # set 无序,不重复的集合
# set1 = set([123, 456, 789])
# print(set1)
# 添加新元素
# set1 = set([123, 456, 789])
# print(set1)
# set1.add(100)
# print(set1)
# set1.add(100)
# print(set1)
# set1 = set([123, 456, 789])
# set1.remove(456)
# print(set1)
set1 = set('hello')
set2 = set(['p', 'y', 'y', 'h', '0', 'n'])
print(set1)
print... |
677abe51e1b0faeee4ff0a598ff2a814da419210 | KaylaZhou/PythonStudy | /PPy/demo.py | 4,583 | 3.796875 | 4 | #num=1
#string='1'
#num2=int(string)
#print(num+num2)
#words='words' * 3
#print(words)
#word='a loooooong word'
#num = 12
#string ='zhurui!'
#total =string*(len(word)-num)
#print(total)
#name ='My Name is Mike'
#
#print(name[0])
#print(name[-4])
#print(name[11:14])
#print(name[11:15])
#print(name[5:])
#print(name... |
54fd96a20ec942b209556c23ef14e99d037512fa | larkspur78/Dungeon | /dungeon.py | 3,344 | 3.953125 | 4 | # key
# ------------------------------------------------------------------------------
# 0 Hall 1 Kitchen
# 2 Armory 3 Cellar 4 Treasury
# ---------
# | 0 | 1 |
# -------------
# | 2 | 3 | 4 |
# -------------
import sys
def room_0():
# description
description = "Welcome to the Hall in the Dung... |
1845af4889434b4b139ef58599ea6e8e3d77948b | StevieLawrence/DataStructures | /hashing/HashTableChaining.py | 2,024 | 4.15625 | 4 | """
Author: Steven Lawrence
Date: 6/13/17
Purpose: Create a hash table that uses chaining with a linked list to solve collisions
"""
# imports
from SingleLinkedList import myList
from Student import Student
class HashTableChaining(object):
"""Chaining hash table class"""
def __init__(self, size = None):
... |
c54bc50f24e025258878bb63cda52ec36ccd7fd2 | StevieLawrence/DataStructures | /recursion/search.py | 1,062 | 4.125 | 4 | """
Author: Steven Lawrence
Date: 5/31/17
Purpose: This program tests recursion to find a value in a list
"""
# imports
import random
def main():
N = 100
myList = [random.randint(-100, 100) for i in range(N)]
print(myList)
print(mySearch(myList, 2))
if 2 in myList:
print(myList.index(2))
... |
bfe6639c0357dd4edefba7a6746094040334f0a2 | StevieLawrence/DataStructures | /recursion/minimum.py | 697 | 4.15625 | 4 | """
Author: Steven Lawrence
Date: 5/31/17
Purpose: This program tests recursion to find the minimum value on a list
"""
# imports
import random
def main():
N = 100
myList = [random.randint(-500, 500) for i in range(N)]
print(myList)
print(myMin(myList))
print(min(myList))
def my... |
502d8354aa82fd0b52dc0c5d5dfcc22bd1c60bf0 | FlarrowVerse/PythonCodes | /TicTacToe/gamePlay.py | 2,105 | 4 | 4 | import random
board = []
row = 0
column = 0
seed = 'X'
def initBoard():
num = 9
for i in range(3):
board.append([])
for j in range(3):
board[i].append(' ')
num -= 1
def showTheBoard():
print "The Board:"
print "--------------"
for i in range(3):
pr... |
178e2c16e11bc483a35b93f53e6adebdfa8cc572 | brandoncb9906/distribuidora | /main.py | 7,313 | 3.5625 | 4 | from seccion import Seccion
from producto import Producto
from categoria import Categoria
from bodega import Bodega
from bodega_alquilada import BodegaAlquilada
lista_productos = []
lista_categorias = []
lista_bodegas = []
def main_menu():
print("***Menu***\n",
"1) Productos\n",
"2) Categorias... |
9e582c9b3dc902ea110637e4e0153ed094e16ea6 | channinghurley/data-structures | /trees/binary_tree.py | 3,360 | 4.1875 | 4 | """Author: Channing J. Hurley
Module: Trees.BinaryTree -- Defines the Node class, which makes up the structure of a binary tree.
Notes:
* This is not necessarily a binary search tree as this class itself enforces no node order.
TODO:
* update docstring
* make data the first arg fo... |
ca0e8d894c486a3aeda50702f37365b58dde9d8b | GitCode-adarsh/Project-148 | /PICNIC_BAG_LIST.py | 927 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 18 17:09:20 2021
@author: Adarsh
"""
from tkinter import*
import random
root = Tk()
root.title("Random Number List")
root.configure(background = "red")
root.geometry("600x400")
List1 = ["Pencil","NoteBook","Chips","Chocolates","Tickets","Hanky","IdCard","T... |
597e7744f2d6a3dcf926593ed09acb7ab9ee5f46 | vyjayanthi03/Python | /Basic_py_prog/def_func.py | 561 | 3.9375 | 4 | # def welcome(name):
# print(name)
# welcome('python')
def value(num,num1):
return num+num1
print(value(1,3))
def evenodd(no):
if(no % 2==0):
print ("even no")
else:
print ("odd")
evenodd(8)
evenodd(87)
def valu(nos):
for i in nos:
print(i)
lis=[1,2,... |
95f4c4b7f272d9814b6660211d31e6e654cbb510 | Saga305/Python | /challenge.py | 310 | 3.796875 | 4 | #Reverse string by word.
def rev_by_word(str):
l = []
l2 = []
s=""
for i in str:
if(i.isalpha()):
s = s+i
else:
l2.append(i)
l.append(s)
s=""
n = len(l) -1
i = 0
while(n > -1):
s += l[n]
s += l2[i]
n -= 1
i += 1
return s
str= "Welcome#to@my2class!"
print (rev_by_word(str))
|
9737532d771ebd29be2eae10b23964c31cdde746 | Saga305/Python | /mat_trans.py | 330 | 4 | 4 | #Matrix transpose using list.
m = [[1,2,3],[4,5,6],[7,8,9]]
for row in m :
print(row)
res = []
for i in range(len(m[0])):
new=[]
for j in range(len(m)):
new.append(m[j][i])
res.append(new)
for row in res:
print(row)
'''
Input:
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
Output:
[1, 4, 7]
[2, 5, 8]
[3, ... |
be16e63a4b9fe73d4f219f16ccce495c19c2c640 | nd974/EdTPeguy | /Eleve.py | 7,080 | 3.546875 | 4 | ## Importations
# module Tkinter et ses collections
from tkinter import *
from tkinter.messagebox import *
# module de données tabulaires
import csv
# module qui permet de lancer de nouveaux processus
from subprocess import call
# Methode pour importer les objets 'Etablissement' et 'Elev... |
dfbba70af60ddaf5b82cc36f486ac9dc413d21e2 | qtau/bigdata-challenge2 | /exercise_2.py | 5,380 | 3.78125 | 4 | # Library importation
import sqlite3
import time
import numpy as np
import pandas as pd
import re
import json
# Definition of the functions used in the process
def create_count_pairs(all_sub):
# Create the dictionary that stores the number of authors in common for each pair of subreddits
# Size of the dictiona... |
844aa76a6779f38a402c3c754f631921956b2a79 | AlexRITIAN/CheckIO_Answer | /ELEMENTARY/Fizz_Buzz.py | 534 | 3.71875 | 4 | def checkio(number):
return "Fizz Buzz" if number%3 == 0 and number%5 ==0 else "Fizz" if number%3 == 0 else "Buzz" if number%5 ==0 else str(number)
def checkio_vol2(number):
if number % 15 == 0:
return "Fizz Buzz"
if number % 5 == 0:
return "Fizz"
if number % 3 == 0:
return "Buz... |
f99980351ce131cebcf8e3f4397edb8976d5e7fe | AlexRITIAN/CheckIO_Answer | /ELEMENTARY/Even_last_last.py | 440 | 3.84375 | 4 | def checkio(array):
sum = 0
for index in range(0,len(array),2):
sum += array[index]
return sum * array[len(array) - 1]
def checkio_vol2(array):
if len(array) == 0:
return 0
return sum(array[i] for i in list(range(0,len(array),2))) * array[len(array) - 1]
def checkio_vol3(array):
... |
c78dd7219d1edde06b690b0372f27d2bc1d06004 | aso4/dsp | /python/q5_datetime.py | 611 | 3.65625 | 4 | # Hint: use Google to find python function
####a)
# date_start = '01-02-2013'
# date_stop = '07-28-2015'
date_start = date(2013, 1, 2)
date_stop = date(2015, 7, 28)
delta = date_stop - date_start
print(delta.days) # 937
####b)
# date_start = '12312013'
# date_stop = '05282015'
from datetime import date
date_start = ... |
b6317f0055b0e91335e930ffb2889c41a6406adc | bgmichael/Past-Projects | /Simulated Annealing/SimulatedAnnealing Test.py | 14,385 | 3.875 | 4 | import random
import time
import math
def generate_random_problem(n):
'''
Creates a list filled with "n" random numbers
between -10*n and 10*n.
:param n: The size of the generated list.
:return: A list.
'''
extent = 30
problem = []
for i in range(n):
num = ra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.