blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
0b88d1c82575483d6d4ea8ae1d404e35892f408a | anandsingh88/Mygit | /sample.py | 518 | 4.34375 | 4 | st = 'my NAme is ANANd singh aND TOdaY is MONDAy'
def uprlorcase():
lcount = 0
ucount = 0
"""this function calculate the total number of upper and lower case letters by
using their ASCII values"""
for itm in st:
if ord(itm)>=97 and ord(itm)<=122:
lcount+=1
# tlcount=... |
1f8f26fed08b9d220bdd02e46f5971420cc59c3d | intisarhaque/Learning-Python | /Flow/FlowCtrl.py | 1,288 | 3.625 | 4 | # ipAdd=input("Enter an ip address ")
# print(ipAdd)
# count = 0
# for i in range(0,len(ipAdd)):
# #print(ipAdd[i], end=' ')
# if ((i==0) & (ipAdd[i]=='.')) or ((i==len(ipAdd)-1) & (ipAdd[i]=='.')):
# continue
# elif (ipAdd[i]=='.'):
# count +=1
# if (ipAdd!=''):
# print(count+1)
#
... |
77d0e2eb07c06aa3b936713ab9fdd246f0a381de | yyaadet/mealing | /mealing/mealing/ranks/bayesian.py | 1,168 | 3.53125 | 4 | #!/bin/env python
# coding=utf-8
"""Bayesian average
>>> bay1 = Bayesian(100, 300, 2.5)
>>> bay2 = Bayesian(50, 300, 2.5)
>>> print bay1.score > bay2.score
True
"""
__author__ = 'yyaadet <yyaadet2002@gmail.com>'
__status__ = 'Product' # can be 'Product', 'Development', 'Prototype'
from base import Base
import math... |
7441c720adbadae40adbbe87c810338497d772a5 | qqqclark/Python-Foundation-Suda | /苏大上机代码/python_project/03_历年真题期末期中/algorithm/py09_midterm1.py | 372 | 3.671875 | 4 | # -*- coding: utf-8 -*-
def allsum(n):
nl = list(str(n))
res = 0
for e in nl:
res += int(e)
return res
def allMul(n):
nl = list(str(n))
res = 1
for e in nl:
res *= int(e)
return res
def fun1(num):
nsum = allsum(num)
nmul = allMul(num)
... |
ece499460a9b3e4779f9210cfdf8a28dab0e47af | void-memories/APS-Code-Base | /Assignment/66_heap.py | 442 | 3.65625 | 4 | #max heap
def heapify(arr,n):
for i in range(n//2,0,-1):
k = i
v = arr[k]
heap = False
while not heap and 2*k<n+1:
j = 2*k
if(j<n):
if(arr[j]<arr[j+1]):
j += 1
if(arr[k]>arr[j]):
heap = True
else:
arr[k] = arr[j]
k = j
... |
a8dd59019a6491f3f7841275e1a7fb28f1ed4ee1 | tharunnayak14/python | /assignment_4.6.py | 375 | 4.0625 | 4 | hours = input("Enter Hours:")
try:
h = float(hours)
except:
print("Enter numeric input")
rate = input("Enter rate:")
try:
r = float(rate)
except:
print("Enter numeric input")
def computepay():
if h < 40.0:
return h * r
elif h > 40.0:
return 40 * r + (h - 40.0) * r... |
d97d80d8ae3bf9077093a47b4a97411a81721f10 | GunjanPande/tutions-python3 | /Challenges/Basics/023.py | 1,123 | 4.21875 | 4 | # 023
# Ask the user to type in the first
# line of a nursery rhyme and
# display the length of the string.
# Ask for a starting number and an
# ending number and then display
# just that section of the text
# (remember Python starts
# counting from 0 and not 1).
# NOTE - some escape characters
#
... |
34d7e4d49bd023ef7de8fb2b529e5f1ae34844ed | axnchat/Study | /AlgoDataStruct/SearchAlgo.py | 623 | 3.9375 | 4 | mylist = [1, 3, 4, 5, 7, 9, 13, 15, 16, 17, 19]
# mylist = [1,3,4,5,7,9]
def binSearch(arr, start, end, num):
print("start:" + str(start))
print("end:" + str(end))
print("num:" + str(num))
mid = int((end + start) / 2)
print("mid:" + str(mid))
print("indexNum:" + str(arr[mid]))
if (arr[mid... |
78bedc04aa3e40f15ebd87e20954789c80683dbe | anderson-0812/Python-Random | /Practicas Python/ramdoom ordenamiento.py | 931 | 4.03125 | 4 | diccionario = {'v':24, 'a':135, 'b':-56}
lista = [1,4,6,2,'kfjsd','aafs']
print 'Lista Ordenada de mayor a menor',sorted(lista, reverse=True) #se ordena en reversa de menor a mayor
#ordenar diccionario x valor y con reverse
#ojo l,a funcion lambda es con una variable de valor anonimo
#aqui trabaja q a lambda es var... |
6aeb9067a3c02be8377c95e81bd37fc57f6c5453 | alexlikova/Python-Basics-SoftUni | /7. Python Basics - More Exercises/2. Conditional Statements - More Exercises/05. Firm.py | 592 | 4.09375 | 4 | import math
needed_hours = int(input())
days_for_project = int(input())
employees_working_overtime = int(input())
total_working_hours = 8 * days_for_project
project_working_hours = total_working_hours * 0.9 # 10% are for training
overtime_hours = employees_working_overtime * 2 * days_for_project
total_project_worki... |
d3ad8655691e2b35180f8e034a3a581220717c42 | JeanFraga/lambdata_DS8_JF | /test/dataframe_manipulators.py | 1,222 | 3.546875 | 4 | """
lambdata - a collection of data science helper functions
by:Jean P Fraga
"""
import pandas as pd
import numpy as np
class Dataframe_manipulators:
"""
In version 0.1.4 added support for classes.
At this moment Dataframe_manipulators only supports 2 methods.
Built in a dataframe that c... |
2c88bae48b6e9b5cb246f61a1affee92e6dc74cd | yuki67/Figure | /Gallery2D/JumpRope.py | 479 | 3.65625 | 4 | from Figure2D import point_2d, Circle, Circloid
class JumpRope(Circloid):
""" 縄跳びをスローシャッターで撮ったときの模様に似てる """
def __init__(self, circle, n=256):
def f(i, j):
k = self.n**0.25
if -k < (j + i) % self.n < k or (j + i) % self.n > -k % self.n:
return True
... |
0b97a710ccab0ede58d4887466e2cbbf20cd730f | upendraBthapa/workshops | /Prac05/wordCount.py | 267 | 3.875 | 4 | __author__ = 'jc437345'
string = input("Text: ")
list_string = string.split()
repeat = {}
for i in list_string:
repeat[i]=list_string.count(i)
for count in repeat:
print("{}: {}".format(count,repeat[count]))
print("number of words:",list_string.__len__())
|
9c84af807cd032d6a0d9818b1336eb6927123bf9 | Cauenumo/Python | /Curso Python Completo - Udemy/Teste/core/range.py | 161 | 3.84375 | 4 | # r = range(0, 10, 1)
# list(r)
print('preparar')
for i in range(0,11):
print(i)
if i ==5:
print('apontar')
continue
print('FOGO!!!!!!!') |
c43428969760f9d6116c8084b47633d3b39184d2 | Zipopasha/Hillel | /Homework6_Korotnian_Pavel.py | 5,647 | 3.921875 | 4 | from lib import *
from random import randint
"""Задание 1. В отдельном файле (пусть будет lib.py) написать функцию, которая требует от пользователя ответить да
или нет ( Y/N ) и возвращает True/False в зависимости от того, что он ввел. В основном файле (пусть будет
Homework6_Korotnian_Pavel.py) попросить пользова... |
e09db8aa97f1a314e1c23f81d708a53c99257336 | Sometimes-tang/lifeisshortyouneedsp | /数字求和.py | 395 | 4.125 | 4 |
# coding: utf-8
# In[15]:
# https://m.runoob.com/python3/python3-add-number.html 实例
num1 = input('输入第一个数字')
num2 = input('输入第二个数字')
sum = float(num1) + float(num2)
multiplicative = float(num1) * float(num2)
print('数字{0}和{1}相加结果为:{2}'.format(num1, num2, sum))
print('数字{0}和{1}相乘结果为:{2}'.format(num1, num2, multiplicat... |
db0daa234cf1eaffe3ca261c45db180c1a8b2b25 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/gregdevore/lesson09/donor_models.py | 6,126 | 4.125 | 4 | #!/usr/bin/env python3
"""
Module with classes for all donor data
Donor class: Encapsulate all data for a single donor
DonorCollection class: Encapsulate all data for handling multiple donors
"""
class Donor():
"""
Class representing an individual donor
Args:
name (str):
Donor's name
... |
611a13075929d4775ade664271b40b5433f1d862 | IracemaLopes/Data_manipulation_with_pandas | /pandas_adding_subsetting_sorting_selecting.py | 624 | 3.90625 | 4 | # Import pandas using the alias pd
import pandas as pd
df=pd.read_csv("homelessness.csv")
# Create indiv_per_10k col as homeless individuals per 10k state pop
df["indiv_per_10k"] = 10000 * df["individuals"] / df["state_pop"]
# Subset rows for indiv_per_10k greater than 20
high_homelessness = df[df["indiv_per_10k"]>20... |
894b4f86a93594a4f72e15c221c47d2162b49577 | n1e2h4a/AllBasicProgram | /Numpyy/ElementsOfFloatingWithPrecision.py | 296 | 3.53125 | 4 | import numpy as np
sample=np.array([ 0.26153123, 0.52760141, 0.5718299, 0.5927067, 0.7831874, 0.69746349,
0.35399976, 0.99469633, 0.0694458, 0.54711478])
print("Previous array elements:")
print(sample)
print("Print array values with precision 3:")
np.set_printoptions(precision=3)
print(sample) |
f947c2e1f969cd80f9bf02fd6a66e0c9e75680ce | ndf14685/python_apiconsume | /api_consume.py | 2,515 | 3.53125 | 4 | #This an python application that consume an API from https://jsonplaceholder.typicode.com/
import requests
#Method that checks if connection is working
def check_connection():
url = "https://jsonplaceholder.typicode.com/users"
response = requests.get(url)
return response.status_code
#Method to get the us... |
eb90f0c6b353b577a79ca4464d8b98893bc92da8 | samuelmjn/ddp0-batch-2 | /week-1-latihan/piramid_2.py | 818 | 3.875 | 4 | # n = 3, 3 baris
# ...*
# ..***
# .*****
# *******
# Wafi
n = int(input("Piramida berapakah yang anda inginkan? "))
print()
#setangah bintang
for i in range(1, n+1):
print("*" * i)
print()
#jumlah bintang terakhir
s = n//2
for i in range(1, n+1, 2):
print (" " * s + "*" * i)
s -= 1
print()
#... |
ab78932d0cb815b3760d65ae91e8245a8d74284e | saiBodireddigari/To-Do-List | /Problems/Students/task.py | 342 | 3.734375 | 4 | class Student:
def __init__(self, name, last_name, birth_year):
self.name = name
self.last_name = last_name
self.birth_year = birth_year
# calculate the id here
self.id = self.name[0] + self.last_name + str(self.birth_year)
stu = Student(str(input()), str(input()), int(inp... |
5ced02de5c31c0be451156abf6ed341808e9a485 | UsairimIsani/adm | /python/binary_search.py | 583 | 3.734375 | 4 | import unittest
def binary_search(arr, key, low, high):
if low > high:
return None
mid = (low + high) // 2
if arr[mid] == key:
return mid
if arr[mid] > key:
return binary_search(arr, key, low, mid-1)
return binary_search(arr, key, mid+1, high)
class TestBinarySearch(unitt... |
3b469e356420904dae3809e826cb2c216834b8ff | OtakuYao/pythonStudy | /demos/print.py | 723 | 3.9375 | 4 | # print 输出相关练习
x = "中国"
y = "北京"
print(x)
print(y)
print("----------分割线-----------")
print(x, y) # sep 用于在字符串之间插入字符,默认为空格
print(x, y, sep=",") # sep 用于在字符串之间插入字符,默认为空格
print("----------分割线-----------")
print(x, y) # end 用于在末尾添加字符。默认为换行
print("** 无用的空行 **")
print(x, y, end=" 王府井 ") # end 用于在末尾添加字符。默认为换行
print("** 无... |
aabb3022d2391989015000579dd1ef3b63bd95b1 | rajatbhansali01/100-days-of-code | /code/day-4/leap.py | 113 | 4 | 4 | x=int(input("enter two year"))
if (x%4)==0:
print("year is leap year")
else:
print("Not leap Year")
|
bcb91bb253718d7643e0a6a515addfe5e3ff942c | HuzaifaSaifuddin/python-is-easy | /importing/importing.py | 1,510 | 4.15625 | 4 | # IMPORTING
"""
SYNTAX:
import LibraryName
"""
# NOTES
# import random
# random.randint(0,10) -> Gives a random integer within the given range.
# random.random() -> Gives a random float value between 0 & 1.
# random.uniform(1,11) -> Gives a random float value within the given range.
# import time
# time.clock() ... |
d2979b8df2bf761647dd088dbea99ea74952f02a | dspen/pyhard | /intc_reverse_words.py | 979 | 3.78125 | 4 | def reverse_words(arg):
# if len(arg)%2==0:
# midpoint = len(arg)/2;
# else:
# midpoint = len(arg)/2 - 1;
# stor = arg[0];
# arg[0] = arg[-1];
# arg[-1]=stor;
# print(midpoint);
#
# for ii in range(1,int(midpoint)):
# stor = arg[ii];
# arg[ii] = arg[-ii-1]... |
def06e476298917944331cba52c26c80849f072c | Alex-Criwer/Chess | /ai.py | 4,684 | 3.515625 | 4 | from random import shuffle
from itertools import product
class AI():
def __init__(self, player_num):
self.player = player_num
self.piece_strength = 10
self.king_strength = 50
self.side_strength = 20
self.wall_strength = 10
def get_possible_moves(self, board):
mo... |
ad3f05b160d5a7cad541a43ae2084f3e0ec99dbd | vishal-1408/Echo-server | /serverapp.py | 838 | 3.546875 | 4 | import socket
HOST = "127.0.0.1"
PORT = 3000
with socket.socket(socket.AF_INET,socket.SOCK_STREAM)as socket:
socket.bind((HOST,PORT))
print("SOCKET BINDED SUCCESFULLY WITH THE SERVER")
socket.listen()
print("Socket status ====== listening")
connection, address = socket.accept()
... |
2ca5574b50e827eefc3f1fad303b83918263f2e5 | Iskan9/Game | /Game.py | 9,841 | 3.703125 | 4 | import random
from tkinter import Frame, Label, Button
size = 400
N = 4
# цвет клеток
color_cell = {2: "lavender blush", 4: "lemon chiffon", 8: "sandy brown", 16: "coral", 32: "salmon1",
64: "tomato", 128: "orange", 256: "dark orange", 512: "gold2", 1024: "gold3",
2048: "gold", 4... |
cdbb269223b5c35d9e81046865784296bc042654 | SCollinA/python104 | /triangle2.py | 1,452 | 4.28125 | 4 | # ask user for height. print a triangle with user height using * chars
# ask user for height repeatedly until they give good input
BAD_INPUT = True # set flag for asking for user input
ERROR_MESSAGE = "Bad user input." # message if bad input received
while BAD_INPUT: # continue to ask for input until is is int
tr... |
da64dfe4776579b867cfb0695c06ec03530bc8ec | AyushN2000/pygame-codes | /start_game.py | 877 | 3.625 | 4 | import pygame
import random
import time
#pygame initializations
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((480,480))
clock = pygame.time.Clock()
#colour rgb values
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
green = (0,255,0)
cyan = (0,255,255)
purple = (255,0,255)
colour = [white ,... |
9534b3658449de0b950407db9d71cd69bca1d1dd | mcsmithers/Encoder | /encoder.py | 2,620 | 4.1875 | 4 | ''' This application is in Python 3.
and created by Christina Smithers.
The first half of the program encodes
numbers and the latter half decodes.
The final output is stored in a text file.
'''
from struct import pack
# Going to use lists to store all the values through various points
input_integers_list = [61... |
00f25e12c80aa073340a8118f90c71bd2678fca7 | anitrajpurohit28/PythonPractice | /python_practice/Dictionary_programs/23_frequency_of_all_char_same_off_by_1.py | 551 | 3.890625 | 4 | # 23 Python dictionary, set and counter to check if frequencies can become same
str1 = "xxxxyyzz"
str2 = "xxyy"
from collections import Counter
def freq_of_char_all_same_off_by_one(input_str):
freq_dict = Counter(input_str)
value_list = list(set(freq_dict.values()))
print(value_list)
if len(value_list)... |
d7d845b0f0181eb04ede906f06a7fa6bf3101d5e | lucyhattersley/6001x | /Week_2/L4_Problem8.py | 463 | 3.671875 | 4 | #def square(x):
# return x * x
#
#def fourthPower(x):
# return square(x) * square(x)
#
#def odd(x):
# return x % 2 != 0
#def isVowel(char):
# vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
# count = 0
# while count < len(vowels):
# if char == vowels[count]:
# re... |
57ce9d6bf470370150df0a37c754d9776a7b5790 | Aasthaengg/IBMdataset | /Python_codes/p03698/s130327490.py | 76 | 3.59375 | 4 | S=str(input())
t=set(S)
ans="no"
if len(S)==len(t):
ans="yes"
print(ans) |
18e6baa5687a89883becb6be14d90e9bf573bcee | youngerous/algorithm | /etc/Sortings/MergeSort.py | 1,721 | 4.21875 | 4 | class MergeSort:
"""
Standard Recursive Algorithm
Complextiy: O(NlogN)
- O(N) for merging
- Height of recursive tree is (1+logN)
This algorithm needs O(N) auxiliary space for copying sub-arrays.
"""
def sort(self, arr):
length = len(arr)
if length > 1:
midPoint = length //... |
2062a5fd1f4b328b4dee9c9b7f7f55a24aa1f4a9 | ZanataMahatma/Python-Exercicios | /Repetições em Python (while)/ex063.py | 846 | 4.28125 | 4 | '''Exercício Python 63: Escreva um programa que leia um número N inteiro
qualquer e mostre na tela os N primeiros elementos de uma Sequência de Fibonacci. Exemplo:'''
#correção 0-1-1-2-3-5-8
print('-='*30)
print('Sequência de Fibonacci')
print('-='*30)
n = int(input('QUantos termos você quer mostrar ? '))
t1 = 0
t2 ... |
42525e4cf5e7d61a3372885e2292b51b1cfa6a37 | Anahit2018/ASUE-P4E-Homeworks | /Homework3/problem1.py | 915 | 3.90625 | 4 | #SOLUTION APPROACH
# (1) sort entered elements
# (2) slice sorted list, leave only last (largest) item
# (3) slice sorted list, leave only first (smallest) item
# (4) translate largest(smallest)_num [list] with single item into an integer using 'sum' function
# (5) calculate the difference
list_of_nums = list(map(int,... |
d1581351009f91af6db10fbe7f2e570370f53d27 | python-13/homework | /01/宫祥瑞/gongxiangrui_homework_week1.py | 1,876 | 3.828125 | 4 | user = {'bob': {'age': 23, 'tel': 123456}, 'mike': {'age': 20, 'tel': 789456}, 'lisa': {'age': 25, 'tel': 456123}}
lst1 = []
# print(user)
def delete():
usr = input('please input a name:')
flag = user.pop(usr, 'notfind')
if flag == 'notfind':
print('{} is not find.'.format(usr))
else:
p... |
9ad4872d7cd81e3de5d14915faabe5f6878c6318 | turbobin/LeetCode | /分治/diff_way_compute.py | 1,311 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
241. 为运算表达式设计优先级
给表达式加括号,输出不同的结果(链接:https://leetcode-cn.com/problems/different-ways-to-add-parentheses)
示例:
输入: "2-1-1"
输出: [0, 2]
解释:
((2-1)-1) = 0
(2-(1-1)) = 2
输入: "2*3-4*5"
输出: [-34, -14, -10, -10, 10]
解释:
(2*(3-(4*5))) = -34
((2*3)-(4*5)) = ... |
5e90083c82e04d122cd2502accc22adb34b95bb4 | Mo-Official/PySnake | /src/states/base.py | 880 | 3.578125 | 4 | import pygame as pg
class BaseState(object):
"""A Base class for the state machine.
How to use
----------
* Set self.done to True to switch to self.next_state
* Set self.quit to True to quit the game.
* handel events in get_event the same way you would handel them in a basic event loop
... |
dfbec898a76f0b465f822a2d8515327fbc163a9b | nzomobrian/holbertonschool-higher_level_programming | /0x02-python-import_modules/2-args.py | 411 | 3.765625 | 4 | #!/usr/bin/python3
if __name__ == "__main__":
import sys
argnum = len(sys.argv)
# Prints the number, then argument(s) followed by a colon if at least one
# argument, '.' otherwise
print("{} ".format(argnum - 1) +
("arguments" if argnum != 2 else "argument") +
("." if argnum == 1... |
43b8821b938087eedd241c16454c6a02a8fb3b32 | Ramya199/codekata | /even.py | 77 | 4.09375 | 4 | n=int(input("enter the number"))
if(n%2)==0:
print'even'
else:
print'odd'
|
e89de7c4fe7523e9b89114b5246268d192a766dc | godls1650/BytePy | /개별/이전/Module_200203/FuncLib.py | 786 | 3.796875 | 4 | #FuncLib.py
# 매개변수와 인수 f(x) = y x: 매개변수 parameter
# y: 인수 (결과값)
# 함수의 매개변수나 함수 내부에서 사용되는 변수
# 들은 전부 Local 변수 라고한다.
cnt = 0 # global 변수
def func() :
global cnt
cnt = cnt + 1
print('test', cnt)
def add(x, y) : # 매개변수 : x, y
global cnt
cnt = cnt + 1
return x + y ... |
9667a50ed2bf40adc6c8f23026773acb992b2838 | Siam1123/python-study | /class Member.py | 370 | 3.796875 | 4 | class Member:
def __init__(self, no: int,name: str, weight: float) -> None:
self.no = no
self.name = name
self.weight = weight
def print(self) -> None:
print("{}: {} {}kg".format(self.no, self.name, self.weight))
yamada = Member(15, "山田太郎", 72.7)
sekine = Member(37, "関根信彦", 65... |
c1493eab27f8a14edb7f60171c3f899355e14e6d | christianalves/python | /media2.py | 500 | 4.03125 | 4 | #!/usr/bin/python3
print("Sistema de Nota")
aluno = input("qual o nome do aluno:")
nota1 = int(input("digite a nota do primeiro bimestre:"))
nota2 = int(input("digite a nota do segundo bimestre:"))
nota3 = int(input("digite a nota do terceiro bimestre:"))
nota4 = int(input("digite a nota do quarto bimestre:"))
media = ... |
73f6ad282cf0f694362986e1de6eafb52af0afb0 | brendapc/studies.py | /tuplas2.py | 428 | 4.03125 | 4 | num = (int(input('digite o primeiro num: ')), int(input('digite o segundo num: ')), int(input('digite o terceiro num: ')), int(input('digite o ultimo num: ')))
print(f'voce digitou os numeros {num}')
count9 = 0
pares = ''
pos3 = 0
for n in num:
if n % 2 == 0:
pares += f'{n}, '
print(f'ha {num.count(9)} nume... |
5bea7dd242593b7b1b76b3b512a7c59251a0ab5d | HarryWang1/TicTacToe | /TicTacToeMain.py | 2,061 | 3.59375 | 4 | import turtle
t=turtle.Turtle()
m = [['-','-','-'],['-','-','-'],['-','-','-']]
a = 1
b = 1
def getNumberOfClicks(a=[0]):
a[0]+= 1
return (a[0])
def drawBoard():
"This function will draw a tic tac toe board"
t.up()
t.ht()
t.goto(0,0)
t.down()
t.forward(240)
t.right(90)
t... |
0f89febf6539c5c1ea9f8157afa2e1167e65d83c | jrbecker16/GitTestrepo1 | /text_sphere3.py | 3,157 | 3.703125 | 4 |
#this program is to create a sphere at some location and then to add a text
#label to it using vtkBillboardTextActor3D. Purpose is learn how to use
#vtkBillboardTextActor3D
from vtk import * #imports all of vtk
renderer = vtkRenderer()
def sphere_create():
sphere = vtkSphereSource()
sphe... |
1bc9e1c15544c3804ca1e51a1938ed1e754c1097 | a421101046/-python | /ex25_1.py | 592 | 3.671875 | 4 | # --coding: utf-8--
from ex25 import * # 导入ex25文件中所有的变量
sentence = "All goods things come to those who wait"
# 分割句子中的单词
words = break_words(sentence)
print(words)
# 数组中单词排序
print(sort_words(words))
# 打印第一个单词
print_first_word(words)
# 打印最后一个单词
print_last_word(words)
# 打印变量
print(num)
"""
在shell中如何导入别的.py文件
... |
a8e97e8ee28983626411330896a15a0ea4e480d4 | yuvapriya/GeneralCoding | /powerSet.py | 281 | 3.5625 | 4 | def powerSet(arr):
l = 2 ** len(arr)
for i in range(l):
print generateSet(i, arr)
def generateSet(i, arr):
genSet = []
for x in range(len(arr)):
if ( i >> x) % 2 == 1:
genSet.append(arr[x])
return genSet
powerSet(['a','b','c']) |
497d96400b36ac4fe7cac8bf70cb1f92682050d3 | metehangelgi/python-Repo | /exercises/dictionary.py | 1,089 | 3.984375 | 4 | # MONTHS
# As a TUPLE
months_tuple = (
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November',
' December')
print(months_tuple)
print(' - ' * 20)
# As a LIST
months_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'Oct... |
aed79985457a066bbacf59654c402340456c343f | hardik25/LeetCode | /flatten_binary_tree_to_linked_list.py | 2,135 | 4.1875 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
'''
Recursive Solution, most intuitive
Time Complexity: O(n)
Space Complexi... |
e82277fdba921ba459741b8fedd0474d8719c47e | renanaquinno/python3 | /#ATIVIDADES_FABIO/#Atividade_Fabio_04_Repeticao_While/#Atividade_Fabio04_Repeticao_21_multiplicacao_sem_operador.py | 483 | 4 | 4 | #entrada
numero_a = int(input())
numero_b = int(input())
#processamento
def multiplicacao (numero_a, numero_b):
multiplicador = 0
resultado = 0
if numero_a > numero_b:
maior = numero_a
menor = numero_b
else:
maior = numero_b
menor = numero_a
while... |
3f9a4f22a2e3d3df4063269c8cbd29fef8a6c0aa | ColemanMitch/Harvard-CS50 | /pset6/vigenere.py | 670 | 3.828125 | 4 | from cs50 import get_int, get_string
import sys
if len(sys.argv)!= 2 and sys.argv[1].isalpha():
sys.exit("Usage: python vigenere.py str")
#n = int(sys.argv[1])
#n%=26
pt = get_string("plaintext: ")
print("ciphertext: ", end="")
for c in pt:
if ord(c) >= 65 and ord(c) <= 90:
if ord(c) + n > 90: # fo... |
197c778fcd88b4d4ef3e0c4ca578c294b18ec321 | stsana/Project-ULB | /INFO-F106/Part2/set.py | 2,472 | 3.78125 | 4 | """
INNOCENT ANTOINE
PROJET D'ANNEE Partie 2
Informatique BA1
"""
import datetime
from setFunctions import *
###################Variables#############################
elements={0:1,1:2,2:3}
symbols={0:9762,1:9822,2:9806}
fillings={0:"P",1:"L",2:"V"}
colors={0:31,1:32,2:34}
##########################Main########... |
e396f7a08aa46fc5230b6dae261aae11c2926dbe | syrkis/orkney | /bin/read.py | 1,136 | 3.546875 | 4 | ####################################################
## Getting the data
from influxdb import InfluxDBClient # install via "pip install influxdb"
import pandas as pd
client = InfluxDBClient(host='influxus.itu.dk', port=8086, username='lsda', password='icanonlyread')
client.switch_database('orkney')
def get_df(result... |
b06036d82ad45b317cf6b16c1e4567fd3b34510a | gokuljs/python-rev | /listcomp.py | 300 | 3.890625 | 4 | import random
import math
evenlist=[i*2 for i in range(10)]
# evenlist=[i*2(action we are going to perform) for i in range(10)]
print(evenlist)
numlist=[1,2,3,4,5]
#we are going to perform power of the all the element in the list
newlist=[math.trunc(math.pow(m,2)) for m in numlist]
print(newlist)
|
b5cff997b000c833e540de4308d41eb9ed13efb1 | matthewrgunn/office_test | /model.py | 1,551 | 3.796875 | 4 | from collections import Counter
def most_frequent(list):
occurence_count = Counter(list)
return occurence_count.most_common(1)[0][0]
def determineChar(answer):
if answer == "1":
return "Michael"
elif answer == "2":
return "Pam"
elif answer == "3":
return "Dwight"
... |
ac3ff49e0db1324d62d7d659f87caab1e5417099 | dymfangxing/leetcodelintcode | /leetcode_py/jiuzhang_py_Ladders/daily_checkin/7_subset.py | 1,088 | 3.9375 | 4 | #coding=utf-8
#S = [1,2,3]
"""
solution:
[
[3],
[1],
[2],
[1,2,3],
[1,3],
[2,3],
[1,2],
[]
]
"""
class Solution:
"""
@param nums: A set of numbers
@return: A list of lists
"""
def subsets(self, nums):
# write your code here
if nums is None:
return None
... |
ce9bc4157be957cb0619eff7c77a9e8af1e6515e | CMDeMaio/hangman | /hangman.py | 2,974 | 3.84375 | 4 | ##############################
""" Hangman - Chloe DeMaio """
##############################
import sys
from random import randint
from hangmanPics import pics
# Fetch random word from the English dictionary
def randomWord():
with open("words_alpha.txt") as word_file:
englishWordList = word_file.read().sp... |
dc2278c3b4f124f72186eace7a045a4ceca33a91 | JoseBalbuena181096/python_course | /lesson_11/lesson_11-3.py | 178 | 3.71875 | 4 | #problema debug
año = int(input('¿En qué año naciste ?\n'))
if año > 1980 and año < 1994:
print('Eres millennial.')
elif año >= 1994:
print('Eres generación Z.') |
072eb0145c03edfa3053f8ef04b564435297ba2a | PriceHardman/think_python | /chapter_12_tuples/12-6_reducible_words.py | 2,934 | 4.15625 | 4 | # Exercise 12-6.
# Here’s another Car Talk Puzzler (http://www.cartalk.com/content/puzzler/transcripts/
# 200651):
# What is the longest English word, that remains a valid English word, as you remove its
# letters one at a time?
# Now, letters can be removed from either end, or the middle, but you can’t rearrange any
#... |
a3e1db366c8ffccd7b687a0c3357c35979a4b0bd | MilanApegaonkar/255934_Mini_Project | /search.py | 860 | 3.640625 | 4 | import csv
student_fields = ['roll', 'name', 'age', 'email', 'phone']
student_database = 'students.csv'
def search_student():
global student_fields
global student_database
print("--- Search Student ---")
roll = input("Enter roll no. to search: ")
with open(student_database, "r", encoding="utf-8")... |
1b8aaff3341e7f24de01c093082d11e72a0474ce | lajapathy/python-practice | /pycharm_programs/Chop/riverbed2.py | 186 | 3.75 | 4 | import itertools
import pdb
def combination(list1, list2):
pdb.set_trace()
return [zip(x,list2) for x in itertools.permutations(list1,list2)]
print(combination([1,2], [3,4,5])) |
7f7dce8848fee1f06c8c795211da36084f3087e5 | italonerd/Python | /BasicPythonProject/src/samples_tuples.py | 291 | 4.21875 | 4 | #You can't change a tuple after its creation
#To change a tuple one must change to a list then again to a new tuple
pi_tuple = (2,5,0,6,1,99,0)
new_tuple = list(pi_tuple)
new_list = tuple(new_tuple)
print pi_tuple
print "len %s max %s min %s" % (len(pi_tuple),max(pi_tuple),min(pi_tuple)) |
62741f0409a58ffdc3ad5a969e054beec968933d | lyndsiWilliams/Data-Structures | /stack/stack.py | 2,331 | 4.3125 | 4 | from singly_linked_list import LinkedList
"""
A stack is a data structure whose primary purpose is to store and
return elements in Last In First Out order.
1. Implement the Stack class using an array as the underlying storage structure.
Make sure the Stack tests pass.
2. Re-implement the Stack class, this time us... |
e38c5fe7f27c4ed4fb9d98c6d1f50c9f4ed8edd9 | haodayitoutou/Algorithms | /LC200/lc164.py | 1,710 | 3.515625 | 4 | """
Given an unsorted array, find the maximum difference
between the successive elements in its sorted form.
Try to solve it in linear time/space.
Return 0 if the array contains less than 2 elements.
You may assume all elements in the array are non-negative integers
and fit in the 32-bit signed integer range.
"""
... |
43b8235ca82478fb7a15f4542a26368dd989d9e7 | lixiang2017/leetcode | /explore/2020/october/Rotate_List.1.py | 985 | 4.03125 | 4 | '''
You are here!
Your runtime beats 94.82 % of python submissions.
'''
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def rotateRight(self, head, k):
"""
:type h... |
bd7aca116289a82479d4a28761b5257cfa41f13c | davidpjohnson/exercises | /checkio/checkio/ex1.py | 285 | 3.703125 | 4 | #!/usr/bin/python
#This exercise is the Fizz buzz test
#This was the top ranked for clarity
def checkio(number):
if number % 15 == 0:
return "Fizz Buzz"
if number % 5 == 0:
return "Buzz"
if number % 3 == 0:
return "Fizz"
return str(number)
|
a6bdf87ebc37036f6d3f2bad83a0620dd851b615 | leiz2192/Python | /exercise/remove-duplicates-from-sorted-array/remove-duplicates-from-sorted-array.py | 893 | 3.734375 | 4 | #!/usr/bin/python
# -*- coding:utf-8 -*-
class Solution:
"""
@param: nums: An ineger array
@return: An integer
"""
def removeDuplicates(self, nums):
if nums is None: return 0
nums_len = len(nums)
if nums_len == 0: return 0
if nums_len == 1: return 1
# elem = ... |
c1c0332dc140badd2fde0cdd5c105c312db2b324 | Daniyar321/chapter1part2task15 | /task15.py | 177 | 3.734375 | 4 | age = int(input())
a = -1
b = -2
if age % 2 != 0:
while a != age:
a = a + 2
print(a)
if age % 2 == 0:
while b != age:
b += 2
print(b) |
db43216d211edc56d858b64ee1192523ed4fe269 | quanysq/study | /Python/Sample 100/029.py | 575 | 3.9375 | 4 | '''
题目:
给一个不多于5位的正整数,
要求:一、求它是几位数,二、逆序打印出各位数字。
程序分析:
学会分解出每一位数。
'''
# !/usr/bin/python
# _*_ coding: UTF-8 _*_
x = int(input('Please enter one number: \n'))
a = int(x / 10000)
b = int(x % 10000 / 1000)
c = int(x % 1000 / 100)
d = int(x % 100 / 10)
e = int(x % 10)
if a != 0:
print('5 位数:', e,d,c,b,a)
elif b != 0:
p... |
31d2ddfa1b47db704aade90b70128ad19d148c42 | nik24g/Python | /random lib.py | 316 | 3.5 | 4 | import random
a = random.randint(0, 10) # random.randint() gives you random integer
print(a)
b = random.random() * 10 # random.random() gives you random number
print(b)
lst = ['Nitin', 'Love', 'Shayna']
ns = random.choice(lst) # random.choice() gives you random value from list, tuples or dictionary
print(ns)
|
a2f19bc6c41d45b85b5e91131b841367a6983e84 | GabrielYamashita/HackerRank-Exercicios | /Python/7. PrintNúmeros.py | 153 | 3.84375 | 4 | # -*- coding: utf-8 -*-
n = 3
def printalgo(n):
i=1
txt=""
while i < n+1:
txt+=str(i)
i+=1
print(txt)
printalgo(n) |
26d42918595b16ef8a6bf98a01b6100e6d44911b | Shin-jay7/LeetCode | /0059-Spiral_Matrix2.py | 977 | 3.828125 | 4 | from __future__ import annotations
class Solution:
def generateMatrix(self, n: int) -> List[List[int]]:
"""
Start with the empty matrix, add the numbers in reverse order
until we added the number 1. Always rotate the matrix clockwise
and add a top row
"""
ans, low =... |
cc3bcc71e66117d30f28597d1fce8bf643773910 | Sergunia/prog_Bakumenko | /Turtle/Bakumenko_4_CrowdOfSquare.py | 269 | 3.59375 | 4 | import turtle
t = turtle.Turtle()
t.shape('turtle')
L = 50
for step in range(10):
for i in range(4):
t.forward(L)
t.left(90)
t.left(180)
t.penup()
t.forward(10)
t.left(90)
t.forward(10)
t.left(90)
t.pendown()
L += 20 |
2e091e2ac80c0938938cc6e017d5045fa5ffbea4 | saurabhsisodia/Articles_cppsecrets.com | /sum_each_level.py | 1,492 | 4.1875 | 4 | # Python program to find sum of values in each level of binary tree
# importing double ended queue
from collections import deque
# class to create a new node
class new_node(object):
def __init__(self,value):
self.value=value
self.left=None
self.right=None
class Level_Sum(object):
def __init__(self,root):
s... |
96e7dde124685381902a7d37d1ade2c8fdf64b45 | stankevo/Python_Essentials | /Chap2_functions.py | 490 | 3.9375 | 4 | def is_prime(n):
if n <= 1:
return False
for x in range(2,n):
if (n % x == 0):
return False
else:
return True
def list_all_primes(a = 100):
for i in range(2, a):
if is_prime(i) == True:
print(i, end = ' ', flush = True)
print()
... |
ef64662b1a93d3325bd9af0d51d9f3283ef6018c | jrecuero/pyos | /grafo/cli/parser/_parser.py | 1,798 | 3.546875 | 4 | """parser module provides all character parsing functionality in order to
parse any lexical language.
version: 2.0
"""
from ._scanner import Scanner
from ._token import Token
class Syntax(object):
__slots__ = ["command", "arguments", "tokens"]
def __init__(self, command=None, argos=None, tokens=None):
... |
b0937545fb309bc8e5b95f4474e1afb26fc1aea8 | fatmazaman/Python | /file_read.py | 288 | 3.78125 | 4 | # Reading file
from sys import argv
script , filename = argv
txt = open(filename)
print " here is your file %s:" % filename
print txt.read()
print "Type the filename again:"
file_name = raw_input("type the file name please:-> ")
txt_again = open(file_name).read()
print txt_again
|
168ab0616aae2043738a98f14ab75add933e0122 | yred/euler | /python/problem_042.py | 1,187 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Problem 42 - Coded triangle numbers
The n-th term of the sequence of triangle numbers is given by, t(n) = ½n(n+1);
so the first ten triangle numbers are:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
By converting each letter in a word to a number corresponding to its
alphabetical posi... |
12e62dfeccaab72b4116b5ffa6da7a483dad64d4 | griffgudge/Card-Engine | /card_engine.py | 3,236 | 3.875 | 4 | import random
from cards import *
class CardEngine:
"""Allows the creation of a deck. Able to customize whether cards are removed from the deck, the cards in the deck, the sets in the deck and the names of the sets."""
def make_deck():
deck = []
for i in range(0, 4):
for o in range(... |
b0d75d35e5501729d384433c0755ddc430bfb086 | majard/prog1-uff-2016.1 | /Selection Sort.py | 529 | 3.765625 | 4 | list = [0] * 10
iterations = 0
for i in range(10):
list[i] = eval(input('Insert number {} of the list: '.format(i + 1)))
for i in range(10):
smallest = i
for j in range(i + 1, 10):
#each if is one comparison
iterations += 1
if list[smallest] > list[j]:
small... |
ff5dc59dd604565dae07862d300bf94bc2c16119 | cglwn/DictionaryList | /DictionaryListFile.py | 1,744 | 3.515625 | 4 | import urllib2
from sys import argv
from Tkinter import *
import tkFileDialog
#This version takes words from a file input
def getDefinition(wordArg):
"""
Returns the definition of the word wordArg.
"""
#Get the page from an online dictionary
req = urllib2.Request('http://dictionary.reference.com/... |
703e3ecbd9d986562ecb9a927cb01d3ce1f4e140 | Sivaraj03/problem-solving- | /Sherlock and the Valid String.py | 663 | 3.71875 | 4 | from collections import Counter
def isValid(s):
# get frequencies
c=Counter(s)
# case 1 same freq
if len(set(c.values())) == 1:
return("YES")
# case 2 more than 2 freq
elif len(set(c.values())) > 2:
return("NO")
#case 3 unique 2 freq
else:
for key in c:
c[key] -= 1
... |
7ac594ea1919dfa17e75aba68100b764d6d6e199 | Hanabiraa/ds-way | /algorithms-way/tasks/bishop_moves.py | 953 | 4.34375 | 4 | """
Заданы координаты слона, стоящего на клетке шахматной доски (номер строки и номер столбца).
Напишите цикл (или циклы) для вывода координат всех клеток, находящихся под ударом.
Слон ходит на любое число полей по диагонали.
"""
from typing import Final
MIN_SIZE: Final = 1
MAX_SIZE: Final = 8
def bishop_moves(x, y)... |
8d6c5acfd84ddf1433ab7c4c19901159f35a940b | pixlalchemy/lpthw | /lpthw/ex15.py | 864 | 4.21875 | 4 | # Imports argument variable from system module
from sys import argv
# Unpacks the variables passed from the command line into their own variables
script, filename = argv
# opens the file stored in filename and stores it in txt
txt = open(filename)
# Print's a string "Here's your file %r:" and takes the name of the file... |
6832afafc0f5c16e3222c3ce6051b5585bd7710d | General-Gouda/PythonTraining | /Training/Lists.py | 713 | 4.25 | 4 | student_names = [] # Empty List variable
student_names = ["Mark","Katarina","Jessica"] # List variable with 3 entries
print(student_names)
student_names.append("Homer") # Adds Homer into the List
print(student_names)
if "Mark" in student_names: # Checks to see if the string "Mark" is in the List student_names
... |
d593c226d0cc5feb4046642be5c2c2f6fb1c1d60 | cladams0203/Passed-Coding-Challenges | /hackerRank/warmup/jumping_on_clouds.py | 1,048 | 3.609375 | 4 | # input is the number of clouds that can be jumped on
#
def jumpingOnClouds(c):
jumps = 0
current = 0
print(len(c))
length = len(c) - 1
while current < length:
if current + 2 < length:
if c[current + 2] == 0:
current += 2
jumps += 1
el... |
a06b8cec4b71d62236af63ee0e31406df9d68491 | sengeling/python-challenge | /PyBank/main.py | 2,605 | 3.921875 | 4 | # import the dependencies
import os
import csv
# define the path to the csv
budget_data_csv = os.path.join("budget_data.csv")
# set months to 0
total_months = 0
# make an empty list to put the difference between prices
diff_list = []
#set the first price
first_price = 867884
# set the last price
last_price = 67109... |
a9ee400d35d04d96ef1eafb02afd14ad302501df | Koperfild/TMDB-IMDB-to-WordPress-uploader | /argparser.py | 3,439 | 3.765625 | 4 | """Argparsers creation for movies and shows. Reads movie or show names from some file, then reads wordpress sites with
their credentials where to upload."""
import argparse
def argparser_movies():
parser = argparse.ArgumentParser(
description="Fetch data from TMDB and post it on WordPress website"
)
... |
0c3b0f27b682436e179c4fad98a7d2519d960114 | s0513/python_basic | /answer/210616_買醉多禮物_90min(暴力破解).py | 2,443 | 4.21875 | 4 | '''
題目:
給定一個整數串列,找到其中任意兩個元素之間的差距小於或等於 1 的最長子集。
Example:
a = [ 1, 1, 2, 2, 4, 4, 5, 5, 5 ]
有兩個子集滿足該標準:[1, 1, 2, 2] 和 [4, 4, 5, 5, 5]。 最大長度子集有 5 個元素。
限制:
1. 2 ≦ n ≦ 100( 給定一串列的長度)
2. 0 < a[i] < 100( 串列中每個元素的大小 )
3. 答案自少要 ≧ 2.
sample input
6 -----------------------n
1 2 2 3 1 2 --------------a[i]
Sample Output
5-----... |
691113505fd352b16aaec17ea1f2e4106d317894 | yanivn2000/Python | /Syntax/Module6/08_quote.py | 409 | 3.59375 | 4 | import re
def find_match(pattern, string, index):
x = re.search(pattern, string)
if x:
print(f"{index} - Match")
else:
print(f"{index} - No Match")
#period here is new line
find_match('^.', '.a', 1) # Y
find_match('^.', 'ab', 2) # Y
#period here is period
#\ is a special caracter therefor... |
416c711b60abc0c2447feb71d552e4ef6f068f4b | luosch/leetcode | /python/Strobogrammatic Number II.py | 604 | 3.65625 | 4 | class Solution(object):
def findStrobogrammatic(self, n):
self.n = n
return self.helper(n)
def helper(self, current):
if current == 0:
return ['']
elif current == 1:
return ['0', '1', '8']
res = []
for num in self.hel... |
b5fde2c2068368dad6f643b042392e00ed2bfdca | mangei/adventofcode2016 | /13_2.py | 3,510 | 4.15625 | 4 | # Advent Of Code 2016 - http://adventofcode.com/2016
# python 13_2.py
# correct answer: 127
# --- Part Two ---
#
# How many locations (distinct x,y coordinates, including your starting location) can you reach in at most 50 steps?
import os
from queue import PriorityQueue
from time import sleep
__author__ = "Manuel ... |
424a6600c5a4b2d1d332118a8e36a6f13b1cdd84 | jtlai0921/AEL022000 | /AEL0220_SampleFiles/Python 程式設計技巧(EL0220)-範例/串列 list.py | 126 | 3.921875 | 4 | list1=[2,4,6,8,10]
print(list1)
for i in range(5):
print(list1[i],end=' ')
print()
for i in list1:
print(i,end=' ')
|
13a7c7f982a1076815b195f4346b2720b15a09ef | xzpjerry/learning | /Coding/playground/general/recurrsive/making_change.py | 493 | 3.9375 | 4 | #!/usr/bin/env python3
'''
Author: Zhipeng Xie
Topic:
Effect:
'''
def min_coins(coin_list, change):
if change in coin_list:
return 1 # 1 coin
current_min = change
for coin in coin_list:
if coin < change:
numCoin = 1 + min_coins(coin_list, change - coin)
if numCoin... |
ebdc735222b6a751d8ea475f896f9857294269f2 | zantelope/variableName | /variableName.py | 878 | 3.96875 | 4 | def variableName(name):
# list of char values that are acceptable (uppercase values ignored)
charValues = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]
# make a list ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.