blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b4e86a5c5f714067933f5fb86933862a09aeccbc | DaI07/challenge | /part1/07/challenge_7_3.py | 221 | 3.65625 | 4 | list = ["ウォーキング・デッド", "アントラージュ", "ザ・ソプラノズ", "ヴァンパイア・ダイアリーズ"]
for i, text in enumerate(list):
print("{}. {} \n {}".format(i, text, list[i]))
|
aca5532953b1231cc7749edb556d09c0b90d570d | brendandwyer/Assignment3 | /tests/test.py | 1,195 | 3.625 | 4 | from src.seater import Seater
'''
Created on 24 Feb 2016
'''
def test_pattern():
# test the pattern matching is parsing the line correctly
seater = Seater()
res = seater.get_cmd("occupy 957,736 through 977,890")
assert res == ('occupy', 957, 736, 977, 890)
def test_occupy():
# tests whether the... |
193d870a3654d327f97bab9fd9b0c61d301880fc | guilhermedonizetti/Sendex | /functions/casosdeuso.py | 7,949 | 3.578125 | 4 | from tkinter.filedialog import askopenfiles
#FUNCAO PARA SELECIONAR ARQUIVOS PARA ANEXO EM E-MAIL
def SelecionarArquivo(self):
x = []
conteudo = []
arq = askopenfiles()
if arq:
qtd = str(arq).split(",")
if len(qtd)==1:
nome = str(arq).split("'")
conteudo.append(n... |
6efc4b57761786787d087b2b9dbdc7d6c70ce308 | josevill/rmotr-exercises-advanced-python | /tasks/truncate_str.py | 506 | 3.953125 | 4 | def truncatechars(text, truncate_after):
# If it's not a string, throw error
if not isinstance(text, (str)):
raise ValueError
else:
# If the value of truncate_after is greater than the
# length of the text variable, return input as it is.
if truncate_after > len(text):
... |
4bfb79ad5bc5a4e14cd6865b6ac9ffde5026cea0 | SlowerthanMOST9/Dawg-s-Gotta-Eat | /dawg.py | 1,632 | 4.03125 | 4 | import random
Chinese = ["General Tso", "Dumplings", "Sweet and Sour Chicken"]
Mexico = ["Taco", "Enchillada", "Gyro"]
Ohio = ["Maxican Food", "A Hot Dog", "BEANS"]
Kentucky = ["Popeyes", "Fried Chicken", "KFC"]
def what_to_eat():
place = input("What would you like to eat?" + "\n" + "1) Chinese" + "\n" + "2) Mexic... |
6e45a35648630314264f228aa75bc72e3a6e30a3 | arunabhdas/challenge | /pychallenge/two.py | 1,556 | 3.875 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
from extratypes import Tree # library with types used in the task
def solution(T):
# write your code in Python 3.6
nodesRemoved = 0
node_count = countNodes(T)
index = 0
while (not isComplet... |
ef250d370f56588ad4e08d474f11697d9814d7ee | Vaild/python-learn | /homework/20200707/62_给字符串加东西诚信的字符串.py | 167 | 3.6875 | 4 | #!/usr/bin/python3
# coding = UTF-8
string = 'abc'
n = len(string)
str = ''
for i in range(0,n-1):
str = str + string[i] + ','
str = str + string[n-1]
print(str) |
07d2e0a425c03ff6843a55a36931423ba83083a3 | ArifSanaullah/Python_codes | /169.Function returning function - Python tutorial 167.py | 405 | 4.1875 | 4 | # 169.Function returning function - Python tutorial 167
def o_func():
def i_func():
print("its inner function")
return i_func
var = o_func()
var()
def o_func2():
msg = 'this is returnd by o_func2'
def i_func2():
msg2 = 'this is returned by i_func2'
print(f"{msg2}")... |
7b682768ac0dadabe081f24d13dac4dae2a47464 | jigarshah2811/Data_Analytics_ML | /DataAnalyticsWithPython-Training/student_files/ch06_database/task6_1_starter.py | 3,382 | 4.28125 | 4 | """
task 6_1_starter.py - This task reads from the database using
Pandas APIs to find the maximum baseball salary
ever and the player who earned it.
Your task is to determine the max salary from
... |
3062deac73a15b1151ba45509a7035566702a852 | steven-snelling/Python-Exercises | /observer_demo/observer_toy_demo.py | 1,818 | 3.6875 | 4 | from abc import ABCMeta, abstractmethod
class Subject(metaclass=ABCMeta):
def __init__(self):
self.observers = []
def attach(self, observer):
self.observers.append(observer)
def detach(self, observer):
self.observers.remove(observer)
def notify_observers(self):
count... |
4666e905176b83118ca1465aa3f05c2459d9a27c | SaxenaTarun/PythonCode | /clndr.py | 477 | 4.15625 | 4 |
import calendar
def display(x):
if(x==1):
print("Monday")
if(x==2):
print("Tuesday")
if(x==3):
print("Wednesday")
if(x==4):
print("Thursday")
if(x==5):
print("Friday")
if(x==6):
print("Saturday")
if(x==7):
print("Sunday")
... |
944fbe44387e5abf7ac5c09469b0f2bcf36ca2d8 | IvayloSavov/Advanced | /file_handling/5.py | 772 | 3.5625 | 4 | import re
# with open("word.txt") as words_fh:
# words = words_fh.read().split()
#
# with open("input.txt") as input_fh:
# text = input_fh.read()
with open("word.txt") as words_fh, open("input.txt") as input_fh:
words = words_fh.read().split()
text = input_fh.read()
words_occurrences = {}
for word i... |
abb7820654c100ab203e0c3c3de4fffbb14ad9da | AlbertZJ/snackGame | /snack1.py | 7,891 | 3.515625 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import pygame
from os import path
from time import sleep
from random import choice
from itertools import product
from pygame.locals import QUIT, KEYDOWN
from pygame.constants import K_ESCAPE, K_q
def direction_check(moving_direction, change_direction):
directions = ... |
d4be14784c57a4caea1c78e8627cc81de3dfcf04 | fakdora/leetcode | /amz/bst_to_sum_tree.py | 1,744 | 3.921875 | 4 | #Given a Binary Search Tree (BST), convert it to a
# Greater Sum Tree such that every key of the original
# BST is changed to the original value plus sum of all
# values greater than the original key in BST.
# https://leetcode.com/problems/convert-bst-to-greater-tree/description/
'''
in order
left, root, right
pr... |
33781dce523fed408fa252ab46dae95ea3745847 | BhupendraHada/python_programs | /python_programs/python/2_no_exchange_without_temp.py | 298 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
Problem Description:
The program takes both the values from the user and swaps them without using temporary variable.
"""
a=int(input("Enter value of first variable: "))
b=int(input("Enter value of second variable: "))
a=a+b
b=a-b
a=a-b
print("a is:", a, " b is:", b)
|
22ff064788b0a095f7bc82b01062f44d57b016c8 | consumerike/mongoDB_primer | /querying.py | 553 | 3.5 | 4 | from pymongo import MongoClient
client = MongoClient()
db = client.test
#cursor for querying all documents in collection:
cursor = db.resturants.find()
for document in cursor:
print(document)
query by top_level field:
cursor = db.resturants.find({"borough": "Long Island"})
for document in cursor:
print(d... |
ece7f7f384ca4a495be83a9d151388dda4ec0100 | chuck1/python | /personal/gui.py | 2,657 | 3.515625 | 4 | #!/usr/bin/env python
import numpy as np
import pygtk
pygtk.require('2.0')
import gtk
class HelloWorld:
# This is a callback function. The data arguments are ignored
# in this example. More on callbacks below.
def hello(self, widget, data=None):
print "Hello World"
n = np.zeros(3)
y = np.zeros(3)
s =... |
47d3616fd16fac694b9bc72c34d2524ff97cf8d3 | 1070988/UPS-P56 | /intervalos de edad.py | 723 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 23 12:19:23 2020
@author: Fernando
"""
apellido=input("introduce tu apellido: ")
nombre=input("introduce tu nombre: ")
edad=int(input("ingresa tu edad que sea menos a 100 años: "))
if edad>=1 and edad<=9:
print("usted aun es un niño")
elif edad >=10 and eda... |
0b4f62ec2dc3a0c13b7383f8dd7e76484d7645e9 | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /students/rusty_mann/Session04/mailroom_session04.py | 4,164 | 3.796875 | 4 | #!/usr/bin/env python3
#Dictionary: keys are donors and values are lists of donations
donor_data = {"Allen, Paul": [1000000.00, 50000.00, 300000.00],
"Gates, Bill": [5000000.00, 80000.00, 700000.00],
"Bezos, Jeff": [30000.00],
"Musk, Elon": [1000000.00, 3... |
7a9ce1fadac8508ff69b949b75cb823b1e9fa520 | reginaldbadua/FSDI-111-Intro-Pythone-Lab-1 | /menu.py | 987 | 3.9375 | 4 | print('Welcom to myCalc')
num1 = input('Please type a number: ')
num2 = input('Please type another number: ')
# parse a string to floats
float1 = float(num1)
float2 = float(num2)
# math operations
print("Sum: ", float1 + float2)
print("Sub: ", float1 - float2)
print("Mul: ", float1 * float2)
print("... |
315316b0fc5f8950a8b1aa2b00f44689ddab2425 | ladykillerjason/leet | /二叉树反转.py | 928 | 3.625 | 4 | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def mirror(root):
if not root:return None
stack = [root]
while stack:
root = stack.pop()
if root:
stack.append(root.left)
stack.append(root.rig... |
b2ae40b1e94467f012bb819c0747603105c08f28 | fosuoy/project_euler | /python/problem_037.py | 1,828 | 4.09375 | 4 | #!/usr/bin/env python3
import time
def blurb():
print("""
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
Find the... |
3b9065467a6c6cb3b8078431789b9360f2fcf1cc | tomoyk/atcoder | /abc058/abc058c.py | 922 | 3.609375 | 4 | #!/usr/bin/env python
n=int(input())
min_charas={}
# 入力の選択
for i in range(0, n):
charas={}
# 文字の選択とカウント
for k in input():
try:
charas[k] += 1
except KeyError:
charas[k] = 1
# 文字の最小数をカウント
if(i==0):
# 最初のみ最小文字数カウンタをそのまま代入
min_charas = char... |
ea79f57c96c5cde9a865f61a969385e2659b4e30 | zuoxiaojun/pythonstudy | /login.py | 349 | 3.796875 | 4 | # Author ='zuoxi'
#date =2018/1/3
_user = "zuoxiaojun"
_passwd = "abc123"
for i in range(3):
username = input("Username : ")
passwd = input("passwd : ")
if username == _user and passwd ==_passwd :
print("Welcome %s login......" %_user)
break #跳出,中断
else:
print("Invalid usernam... |
f619f63fe0714354d4430d45998f0e171d6f9d70 | VicGanoh/AdvancedPYTHON | /Classes.py | 479 | 3.8125 | 4 | #CLASSES
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def get_age(self):
return self.age
def get_name(self):
return self.name
def speak(self):
print ("Hello")
def walk(self):
print ("Walking away")
... |
261e3c8deef628fb548f3ea799aee1e06904e1bd | UCMHSProgramming16-17/file-io-dblechingerslocum | /class-exercises/makelist.py | 285 | 3.859375 | 4 | # open file called list.txt in write mode
file = open('list.txt','w')
x = 0
# add user input to the file
while x < 10:
file.write(input("What fruits would you like to add to the file? ") + ' \n')
x += 1
file.close()
file = open('list.txt','r')
file.seek(0)
print(file.read()) |
1cef051e6789229a4677e2605916059bbe0b80f1 | predavlad/projecteuler | /projecteuler.net/33.py | 541 | 3.609375 | 4 | import time
start_time = time.time()
def check_fraction(a, b):
if b % 10 == 0 or b % 11 == 0 or (a / b) >= 1 or str(a)[1] != str(b)[0]:
return False
x = float(str(a)[0])
y = float(str(b)[1])
return x / y == a / b
def get_fractions():
results = []
for i in range(11, 100):
for... |
978c0bc4aef9ee157e30169e15ad0db1cd3df442 | dialex52/HomeWork | /task_3.py | 1,793 | 3.9375 | 4 |
# Создать список, состоящий из кубов нечётных чисел от 0 до 1000 (куб X - третья степень числа X):
#
# 1) Вычислить сумму тех чисел из этого списка, сумма цифр которых делится нацело на 7.
# Например, число «19 ^ 3 = 6859» будем включать в сумму, так как 6 + 8 + 5 + 9 = 28 – делится нацело на 7.
def div_by_seven(some... |
efb4155063ff4635216a3ecfcc6b31bb4249c7f5 | BaldvinAri/Python_verkefni | /Vika 07/assignment12_4.py | 489 | 4.0625 | 4 | def get_numbers():
numbers = input("Enter elements of list separated by commas: ")
return numbers.split(",")
def isdigit_list(n_list):
for i in n_list:
if not i.isdigit():
return False
return True
num_list = get_numbers()
if isdigit_list(num_list):
check_count = input... |
e44db78df62131c1f938848c488809cc58c068cf | ksdfg/mit-stuff | /t8/daa/quicksort.py | 1,863 | 3.5625 | 4 | from random import choice
from time import time
def _qsort(array, low, high):
arr = array.copy()
if low < high:
i = low
j = high
while i < j:
while i <= high and arr[i] <= arr[low]:
i += 1
while j >= low and arr[j] > arr[low]:
j ... |
f8d313eff662451224e18d5700b2a594f80b6c45 | akshitasawhney3008/Algorithms-in-computational-biology | /acb_assignments/fibonacci.py | 168 | 3.875 | 4 | #n=0
#def fibo(n):
sum=0
n=int(input("Enter the range of fibonacci series"))
a=0
b=1
print(a)
print(b)
while n>0:
sum=a+b
a=b
b=sum
print(sum)
n=n-1 |
c0305833d072c6b73ff11d7ef474f2266e2a1edb | depecik/-rnekler | /PythonTemelleri/IDLEOrnek.py | 441 | 3.609375 | 4 | a = input("1. Sayıyı Giriniz")
b = input("2. Sayıyı Giriniz")
a = int(a)
b = int(b)
c = a+ b
print(c,a,b,sep="\t",end="\n")
##print(bin(2))
##print(oct(2))
##print(2)
##print(hex(2))
print("Merhaba")
var1 = 12345678910
# deneme = type(var1)
var2 = 5.5
var3 = 5.9j
var4 = "str"
var5 = []
var6 = ()
var7 = {}
print(typ... |
2dea3213cc8917e9518567cefcc7bf6060ed7385 | Jandeh7/coderbyte-solution | /coderbyte-AlphabetSoup.py | 509 | 4.03125 | 4 | '''
Have the function AlphabetSoup(str) take the str string parameter being passed and return the string with the letters in alphabetical order (ie. hello becomes ehllo). Assume numbers and punctuation symbols will not be included in the string.
Use the Parameter Testing feature in the box below to test your code wit... |
a1bddf17d79807ecd1f1eea7f21e0cdf4caf1aa8 | vpiyush/SandBox | /python-samples/TupleTest.py | 66 | 3.828125 | 4 |
myTuple = ("1", "2", "3")
for elem in myTuple:
print(elem)
|
768dbeea2749cfaf90d9b7dc64e150e7fcd4204c | vpistola/project_euler | /euler30.py | 861 | 3.75 | 4 | '''
Project Euler 30: Find the sum of all the numbers that can be written as the sum of fifth powers of their digits
We need an upper bound if we don’t want to continue in eternity. So finding the upper bound is the secret to solving this problem. We need to find a number x*95 which gives us an x digit number. We can... |
4f1c2666d37ecec8f4d3217e47dc7c9b8c84ac9d | ShubhamPnd/Python_Practice | /ALGO/Ispalindrome_Naive_approach.py | 485 | 3.8125 | 4 |
def isPalindrome(x):
return x == x[::-1]
def minPalPartion(string, i, j):
if i >= j or isPalindrome(string[i:j + 1]):
return 0
ans = float('inf')
for k in range(i, j):
count = (
1 + minPalPartion(string, i, k)
+ minPalPartion(string, k + 1, j)
)
ans = min(ans, count)
return ans
def main():
stri... |
ead765ee38e4b1c6308e2d8b34a9d18fe1f39133 | Cassieyy/LeetCode | /2.AddTwoNums.py | 1,402 | 3.53125 | 4 | class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
'''
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.
'''
class Solution:
def addTwoNumbers(self, l1, l2):
val1 = 0
val2 = 0
cof1 = 0
cof2 = 0
... |
0467738db35ed5ca2691ef68cd5aef653bea2ee1 | cameronrw-nz/DailyProgrammer | /Challenges371-380.py | 1,708 | 3.890625 | 4 |
from collections import defaultdict
# Challenge 371 (easy)
# Takes in single numerical input and figures out additive persistence, ie add digits together until you get to a single digit.
# https://www.reddit.com/r/dailyprogrammer/comments/akv6z4/20190128_challenge_374_easy_additive_persistence/
def Challenge371E():
... |
bbe538dcbcbda8bd88c67646cc4418d1ef79f075 | guilhermepirani/think-python-2e | /exercises/cap04/ex-4-2.py | 771 | 3.859375 | 4 | ''' Code for 4.12.2
Write an appropriately general set of functions
that can draw flowers as in Figure'''
import math
import turtle
def arc(t, r, angle):
'''Draw curved lines'''
length = 2 * math.pi * r * angle / 360
n_length = length / 10
n_angle = angle / 10
for _ in range(10):
t.fd(n_length... |
7f88be82138ba8cd23c0188aa969269b80c07b42 | m-samik/pythontutorial | /python_basics/patternprinting.py | 292 | 3.796875 | 4 | # Pattern Printer
while(1):
def getdate():
import datetime
return datetime.datetime.now()
print(getdate())
n=int(input("Enter The No of Rows to be Printed\n"))
for i in range(1,n+1):
for j in range(1,i+1):
print("*",end="")
print()
|
37208173621faf5372a9bc13069072ad398bb054 | MarvinKweyu/PythonChallenges | /GradedExercises/Level1/Question2.py | 383 | 4.4375 | 4 | #!/bin/python3
# Write a program which can compute the factorial of a given numbers.
# The results should be printed in a comma-separated sequence on a single line.
# Suppose the following input is supplied to the program:
# 8
# Then, the output should be:
# 40320
from math import factorial
number = int(input("Enter... |
39d76e930f16ceda050911a959ef3c03f6e52883 | noemiefedon/foobar | /foobar-2-1.py | 380 | 3.84375 | 4 | # -*- coding: utf-8 -*-
def solution(x, y):
"find the solution of the exercise 1 at level 2 of the foo.bar challenge"
value = 1
for ind_row in range(y):
value += ind_row
rate = y + 1
for ind_col in range(x - 1):
value += rate
rate += 1
return str(value... |
ad8c9f04c08cd2edfff7aed656a90c8d2cea8899 | vigaea/ml | /learnPy/basic/func5.py | 433 | 4.125 | 4 | # 参数定义的顺序必须是:必选参数、默认参数、可变参数、命名关键字参数和关键字参数
def f1(a, b, c=0, *args, **kw):
print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'kw =', kw)
def f2(a, b, c=0, *, d, **kw):
print('a =', a, 'b =', b, 'c =', c, 'd =', d, 'kw =', kw)
f1(1,2)
f1(1,2,c=3)
f1(1,2,3,'a','b')
f1(1,2,'a','b')
f1(1,2,3,'a','... |
131cdbfa2e6f413e933fcc07cccb5e9442324a51 | Osama-Khan/bscs-na | /Labs/Lab 7 - Ch 6/Ex14.py | 310 | 4.09375 | 4 | # Write a program that asks the user to enter their name in lowercase and then
# capitalizes the first letter of each word of their name.
name = input("Enter name: ").split()
for i in range(len(name)):
name[i] = name[i][0].capitalize() + name[i][1:]
for i in range(len(name)):
print(name[i], end=" ")
|
7a3a691546a4cd770c008e0181ecf6f910e579ec | hung135/dbdifftest | /jython_scripts/objects/database.py | 1,301 | 3.578125 | 4 | import os
class Database(object):
"""
Python database object that will map to Java object
Attributes
----------
key: str
Identifier for tasks (i.e: sys-dev)
dbtype: str (DbConn.Enums)
Database type
host: str
Database host
port: int
Database port
user:... |
56ac7a9deb451b7e4b5f22c1141329003fe47616 | LCQ622/Python_project | /39.py | 599 | 4 | 4 | # self 的使用 及析构函数
# 析构函数就是对象被销毁时执行的函数
class Person(object):
__name=None
__age=0
__gender=None
def __init__(self,name,age,gender):
self.__age=age
self.__name=name
self.__gender=gender
def __str__(a):
return "姓名:{0},年龄:{1},性别:{2}".format(a.__name,a.__age,a.__gender... |
76af3e8b713e6492a3f1151082a6e76f85514870 | MariaEduardaBattisti/TrabalhoLogicaPrograma-o1 | /Exercicio7.py | 442 | 3.90625 | 4 | numero = int(input('Digite um número: '))
resultado = 0
for c in range(1, n1 + 1):
if numero % c == 0:
print(' \033[34m' , end='')
resultado += 1
else:
print(' \033[31m' , end='')
print(f'{c}', end='')
print(f'\n\33[mO número {numero} foi divisivel {result} vezes!')
... |
a07a1f773c4f15ae063c37f22436c2ab9149d685 | simranjmodi/cracking-the-coding-interview-in-python | /chapter-08/exercise-8.5.2.py | 906 | 4.0625 | 4 | """
8.5 Recursive Multiply
Write a recursive function to multiply two positive integers without using
the * operator (or / operator). You can use addition, subtraction, and bit
shifting, but you should minimize the number of those operations.
Solution 2
"""
def min_product(a, b):
if a < b:
bigger = b
... |
0ea804a00641320453b98d338934a15d161039d7 | Giorc93/PythonCourse | /Serialization/serialization1.py | 681 | 3.703125 | 4 | # Encoding an object on binary to make easier its distribution
# Pickle library its needed
import pickle # Contains the needed methods to serialize the file
namesList = ['Gio', 'Andres', 'Liz', 'Natalia']
# Creating the binary file, the second argument especifies the binary writing mode
binaryFile = open('NameList'... |
d44f2037baf7b87d7941546b7c262e14b1e8425b | Murega14/holbertonschool-higher_level_programming | /0x0A-python-inheritance/4-inherits_from.py | 200 | 3.59375 | 4 | #!/usr/bin/python3
"""subclass checker"""
def inherits_from(obj, a_class):
"""returns subclass yes"""
if type(obj) == a_class:
return False
return issubclass(type(obj), a_class)
|
5dc74244d956b104d0f12a895020c6bdc0dfbda5 | edramir18/42_python_bootcamp | /day00_ml/ex00/vector.py | 979 | 3.578125 | 4 | class Vector:
def __init__(self, data):
self.values = []
if (isinstance(data, list)
and all(isinstance(v, (int, float)) for v in data)):
self.values = [float(v) for v in data]
elif (isinstance(data, tuple) and len(data) == 2
and all(isinstance(v, i... |
7d9a55321752900c5dea765b4c323decbaf6dd39 | alexlikova/python | /challenges/week_1/bus_fare_challenge.py | 944 | 4.59375 | 5 | from datetime import date
import calendar
# 1. gets today's date and stores it in a variable 'date'
date = date.today()
"""
2. uses today's date to get the name on the day of the week written in a short
form with the first letter capitalized eg. 'Fri' if today were Friday and assigns
it a variable 'day'
"""
day = ca... |
8abffe8cf4c10fd3cf8266576b6fbb26d0a39232 | charygao/pycograph | /pycograph/schemas/basic_syntax_elements.py | 2,313 | 3.84375 | 4 | """Basic syntax elements the output of the parsing by ast.
These objects should contain only properties and simple methods.
"""
from abc import ABC
from typing import List, Optional
from pydantic import BaseModel
ABSOLUTE = "absolute"
RELATIVE = "relative"
class SyntaxElement(BaseModel, ABC):
"""The base clas... |
40569994265fb2cf673daf0d4dd918b8f9c5c45b | skycreaper/Estructura-de-datos | /7.py | 472 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: David Santos
version: 3.7.3
"""
print (" *** Dada una tupla de tuplas de 2 enteros genere numeros complejos con la tupla de tuplas *** \n")
enteros = ((2, 1), (15, 3), (22, 8), (13, 4), (1, 1), (78, 225) )
print("La tupla de tuplas de 2 numeros enteros es: {}".... |
7be64a6b0c186df1f94238a8db8fbfe8ad2b8163 | Jishasudheer/phytoncourse | /oops/inheritence/parent_teacher.py | 784 | 3.953125 | 4 | class Parent:
def __init__(self,name,age):
self.name=name
self.age=age
def printValues(self):
print("name :",self.name)
print("age :",self.age)
class Teacher(Parent):
school="SN"
def __init__(self,tname,id,sal,name,age):
super().__init__(name,age)
s... |
19ec38c31dbbad5adb3b024b0ec4818b4113dcb7 | DamianPetryk/lab | /lab 2 lista.py | 2,339 | 4.3125 | 4 | from cs50 import get_int
from math import *
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
#0 Use alternative way of reading inputs - using library (0.5p)
x = get_int("x: ")
y = get_int("y: ")
#1 Perimeter & field of circles with given radius X for the first circl... |
8f711f0e65fd473e5e253147a3891d60becd3a9e | shedolkar12/DS-Algo | /LinkedList/partition.py | 1,160 | 3.984375 | 4 | # Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
# You should preserve the original relative order of the nodes in each of the two partitions.
# For example,
# Given 1->4->3->2->5->2 and x = 3,
# return 1->2->2->4->3->5.
class ListNode:
... |
d9965ca277a3609fb60a2fc7c1052ff18698c46f | dennisberg13100/cs50 | /pset6/mario.py | 441 | 3.84375 | 4 | from cs50 import get_int
def main():
n = get_size()
for i in range(n):
for j in range(n-i-1):
print(" ", end="")
for k in range(i+1):
print("#", end="")
print(" ", end="")
for l in range(i+1):
print("#", end="")
print()
def get_si... |
e3fabf5ca9bc28a5e12d424a7bbd2835d2a1d964 | SetiaP/workshop_python | /00_pertemuan_05/src/Input.py | 145 | 3.921875 | 4 | x = input("something:")
something:10
x
'10'
x = input("something:")
something:'10' #entered data treated as string with or without ''
x
"'10'" |
59d5812778598e2afa4860cec04cda829f698dc9 | hirokitnk/python_online_judge | /book_algorithm_solution/4-2.py | 345 | 3.640625 | 4 | #T0=0,T1=0,T2=1, TN = T(N-1) + T(N-2) + T(N-3)
memo = {}
def func(N):
if N == 0 or N == 1:
return 0
elif N == 2:
return 1
if not N in memo:
memo[N] = func(N-1) + func(N-2) + func(N-3)
return memo[N]
def main(N):
if N < 3:
return 0
print(func(N))
if __name__ == ... |
bf791bd2a0e8e25a72c831431db69e072e977c1e | JASTYN/pythonmaster | /datastructures/arrays/maxlen_contiguous_binary_subarray/__init__.py | 1,187 | 4.0625 | 4 | from typing import List
def find_max_length(nums: List[int]) -> int:
"""
Finds the maximum length of a contiguous sub array in a binary array. Makes use of a hashmap to store the entries in
the form of (count, index). We make an entry for a count in the map whenever the count is encountered first and
... |
c19118516a8ecdf3528532c9b5ae3028027807ed | runchal/ADOTRUN | /Emily Protests/smallmachines04.py | 213 | 3.5 | 4 | # Emily Protest
from random import choice
first = ["Stop", "Oppose", "Support"]
joiner = ["The", "--", "Some", "A"]
punctuation
second = ["Troops", "War", "Presidents"]
for items in range(10):
print (choice(first))
|
9710da6474b6d6d5d785a7e975ab71728517a2d2 | ondergetekende/lazy_sort | /lazy_sort/insertion_sort.py | 565 | 4.125 | 4 | def insertion_sort(unsorted):
unsorted = list(unsorted)
insertion_sort_inplace(unsorted)
return unsorted
def insertion_sort_inplace(unsorted):
if len(unsorted) <= 1:
return
for idx in range(1, len(unsorted)):
# The array before idx is sorted. Now insert unsorted[idx] into it
... |
30e8e21200d9565ade0cbcad6b1936606b0cced3 | ULLIEL/COMP9021_Principle_of_Programming | /quiz_2.py | 2,018 | 3.9375 | 4 | # COMP9021 19T3 - Rachid Hamadi
# Quiz 2 *** Due Thursday Week 3
import sys
from random import seed, randrange
from pprint import pprint
try:
arg_for_seed, upper_bound = (abs(int(x)) + 1 for x in input('Enter two integers: ').split())
except ValueError:
print('Incorrect input, giving up.')
sys.exit()
se... |
4521a3bea4e592aaf70bbaa3a4abfdd2ba14c026 | stark276/tweetgenerator | /dictonary_words.py | 756 | 3.546875 | 4 | import random
import sys
file_content = []
with open("/usr/share/dict/words", "r") as f:
for line in f:
file_content.append(line.strip())
# print(file_content)
def random_sentence(words_list, length):
choosen_words = []
for _ in range(length):
random_index = random.randint(0, len(words_... |
949dcfac19aca0550ec46d158bcd39d8fd816f3d | tanayz/ProPrac | /ip2.py | 830 | 3.71875 | 4 | '''http://stackoverflow.com/questions/12232930/finding-out-the-minimum-difference-between-elements-in-an-arrays'''
import time
#import numpy as np
#input=np.arange(20000)
#np.random.shuffle(input)
"""Find the minimum difference between elements in an array"""
input = [5,13,8,1,17,23,28,36,42,50,55]
mx=10
mn=10
t=ti... |
6c1880746c70b813e8f6e9eae847ed9328aa37aa | analylx/Py_script | /combind.py | 662 | 3.515625 | 4 | from itertools import combinations, permutations
ne_name = ['1800 1t', '1800 2t', '1250', '1300', '1200i', '1050i']
version = ['7.5', '7.6', '8.0']
feature = ["IPv6 interface", "IPv6 ping&TR", "IP BFD"]
if __name__ == "__main__":
print(ne_name, version, feature)
result = []
for i in ne_name:
for j... |
460dcb5e408d4b6cf2bef6faea14a806bad01e43 | dtliao/Starting-Out-With-Python | /chap.7/04 p.334 ex.4.py | 338 | 3.9375 | 4 | list=[]
total = 0
average = 0
for i in range(20):
numbers=float(input('Enter a number in integer:'))
list.append(numbers)
total += numbers
average = total/20
highest = max(list)
lowest = min(list)
print('Total:', format(total, ',.2f'))
print ('Average:', format(average, ',.2f'))
print ('High:', high)
print... |
c9568b2135cab523f54459f556cb7e9151c6bfd5 | jsacane/ProjectEuler | /Problem_4/Problem4_noString.py | 690 | 4.125 | 4 | """
Problem 4:
A palindromic number reads the same both ways. The largest palindrome made
from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
from math import floor
def isPalindrome(x):
num = x
reverse = 0
while num > 0... |
bc490c49507b0efe51c6869c08d14732ebbbd8f2 | ArtemchikovaV/Structures | /binary_tree_python.py | 2,636 | 3.828125 | 4 | """Binary tree structure"""
class TreeNode():
def __init__(self, value):
self.value = value
self.leftChild = None
self.rightChild = None
class BinaryTree():
def __init__(self):
self.root = None
self.size = 0
def add(self, value):
self.root = self._add(valu... |
16a66f02a475e12857114163169cdd5b7350d9cb | jonasht/CursoEmVideo-CursoDePython3 | /mundo2-EstruturasDeControle/055 - Maior e menor da sequência.py | 352 | 3.890625 | 4 |
maior = menor = 0
for i in range(0, 5):
peso = float(input('qual é peso da pessoa {}:'.format(i+1)))
if i == 0:
menor = maior = peso
else:
if peso > maior:
maior = peso
if peso < menor:
menor = peso
print('o maior peso foi {}Kg'.format(maior))
print('o menor... |
a1286c74a46bf901fd5c4b8feb28db393debe371 | gsmcclellan/project_euler | /Amicable_numbers.py | 1,439 | 3.9375 | 4 | """ Amicable Numbers
Greg McClellan
9/7/2013
Problem:
Let d(n) be defined as the sum of proper divisors of n (numbers less than
n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair
and each of a and b are called amicable numbers.
For example, the proper di... |
32003a887576ec263cf2a3fa378e8abcd655cd5e | zjwyx/python | /骑士计划day16/02_作业讲解.py | 3,342 | 3.625 | 4 |
# 1.完成以下功能
# 1.1创建一个人类Person,再类中创建3个静态变量(静态字段)
# animal= '高级动物'
# soul = '有灵魂'
# language = '语言'
# 1.2 在类中定义三个方法,吃饭,睡觉,工作
# 1.3 在此类中的__init__方法中,给对象封装五个属性:国家,姓名,性别,年龄,身高
# 1.4实例化四个人类对象:
# 第一人类对象叫p1属性为:中国,alex,未知,42,175
# 第二人类对象叫p2属性为:美国,武大,男,35,160
# 第三人类对象叫p3属性为:你自己定义
# 第四人类对象叫p4属性为:p1... |
c6a4d8909763d347d7dff40219a76f561cac1739 | ariqrafikusumah/Tugas | /Chapter 2/D4 TI B/Syabriena Putri Veriane(1184094)/src/2err.py | 257 | 3.578125 | 4 | var1 = input("Variable String: ")
var2 = input("Variable Integer: ")
string = str(var1)
integer = int(var2)
try:
jml = string+integer
except Exception:
print("String tidak bisa dijumlah dengan integer, string harus di casting menjadi integer dulu") |
ab62740561571ec6ee9b23d8262f8c561481bb90 | eHonnef/python-snakes | /Snake.py | 3,726 | 3.875 | 4 | import tkinter as tk
from Objects import MovableObject
"""
Classes concerning the snake body and movement
"""
class Body:
def __init__(self, canvas):
self._canvas = canvas
self._body = []
self._current_direction = "right"
# create initial given the x and y position
self._create_initial(20, 20)... |
40bcadfa1a536962646c565e3e6c70747aea2800 | anu-bioinfo/rosalind-4 | /7b.py | 1,507 | 3.546875 | 4 | #! /usr/bin/env python
from __future__ import print_function
from collections import defaultdict
def trie(patterns):
adj_list = defaultdict(list)
root = 1
last_node = root
for pattern in patterns:
current_node = 1
for ch in pattern:
node = next((node for (node, letter)
... |
a71788020b4f3fb954314330c388705e504a56dc | SuryaNMenon/Python | /Other Programs/whileCountdown.py | 192 | 4.21875 | 4 | #Program to print a countdown using user input range and while loop
high = int(input("Please enter the upper limit of the range"))
i=high
while i>-1:
print(i)
i-=1
print("Blast off!")
|
4a8dac6fb4dd4de3fcbb6995c5f2a96970e83b4c | mlrice/DSC510_Intro_to_Programming_Python | /temperatures.py | 1,208 | 4.46875 | 4 | # DSC510
# Week 6
# 6.1 Programming Assignment
# Author Michelle Rice
# 10/8/20
# The purpose of this program is to obtain temperatures from the
# user and determine the number of temps, largest and smallest temp
def main():
while True:
temperatures = []
n = (input("Enter number of temperatures y... |
3d8f1b1f6af02285948366d86de9372fe0df600a | goosebones/spellotron | /missed.py | 1,760 | 3.75 | 4 | """
author: Gunther Kroth gdk6217@rit.edu
file: missed.py
assignment: CS1 Project
purpose: check if a misspelled word was a missed key press
"""
# required modlues
import word_check
import string_modify
def missing_key_press(word):
""" trys to correct a word by inserting letters
for each letter in the... |
bab30960db944b2b81615b212ad9d775221d687b | GoYMS/localhost_python | /爬虫/案例/v34.py | 639 | 3.53125 | 4 | """
通过webdriver操作百度进行查找
"""
from selenium import webdriver
import time
#通过Keys模拟键盘
from selenium.webdriver.common.keys import Keys
#操作哪个浏览器就对那个浏览器建一个实例
#自动按照环境变量查找相应的浏览器
#如果浏览器没有在相应的环境变量中,需要指定浏览器的位置,例如下边一行
#driver = webdriver.PhantomJS(executable_path=r'E:\Anaconda3\phantomjs-2.1.1-windows\bin\phantomjs.e... |
da5d362570c16dbcdc1ce0fd3982802987ff3c1f | giinie/CSBootcamp | /src/learn_python_the_right_way/unit_33/global_local_variable.py | 476 | 3.953125 | 4 | ##################################################
# 전역 범위(global scope)
x = 10 # 전역 변수(global variable)
def foo():
##################################################
# 지역 범위(local scope)
x = 20 # foo 의 지역 변수(local variable)
print(x) # foo 의 지역 변수 출력
#
#####################################... |
d95c3ce9b7c95cb1d4e554a40fe57ea212a70e25 | NicHagen/censor_dispenser | /censor_dispenser.py | 4,476 | 3.703125 | 4 | # These are the emails you will be censoring. The open() function is opening
# the text file that the emails are contained in and the .read() method is
# allowing us to save their contexts to the following variables:
email_one = open("email_one.txt", "r").read()
email_two = open("email_two.txt", "r").read()
email_three... |
bf030d421191efa1a0cf0e2b14a12e0f0497c216 | CiteKanaumi/Python | /2018Python/sample2.py | 97 | 3.640625 | 4 |
week = ['mon','tue','wed',
'thu','fri','sat','sun']
print(len(week)) #listの要素数
|
be5a761f2ccee6d2ee0ff1026a8ba0048e800633 | Talleth/PythonLists | /exercise.py | 2,025 | 4.46875 | 4 | #===================================================================
# Purpose: Demonstrate basic Python programming in
# for Lists and Functions
#===================================================================
# Function to to display temperatures
def DisplayTemperatures(HourlyTemperatures, Av... |
72fc3837eb7394bf7f88db967dc2b65befb75c02 | Aishwarya-260180/260180_daily_commits | /if-else-if-2.py | 286 | 4.03125 | 4 | string=input("Enter the Short-Form:")
if(string=='lol'):
print("Laugh Out Loud")
elif(string=='rofl'):
print("Rolling On The Floor Laughing")
elif(string=='lmk'):
print("Let Me Know")
elif(string=='smh'):
print ("Shaking My Head")
else :
print("INVALID")
|
bf01d0eede6ebe82939dfe685d9743d2bf7cde92 | rahulsrma26/csglitz_python_examples | /tutorial 03/weather.py | 154 | 3.890625 | 4 | temperature = int(input('Enter outside temperature in celsius: '))
if temperature < 15:
print("Take a plain jacket")
print("Have a nice day")
|
b7209af7fce33145f18b6be1c42e4a08042c93cd | hundyoung/LeetCode | /leetcode/Q850_Rectangle_Area_II.py | 2,377 | 3.53125 | 4 | from typing import List
class Solution:
def rectangleArea(self, rectangles: List[List[int]]) -> int:
if len(rectangles)==0:
return 0
else:
# x_left,y_left,x_right,y_right = rectangles.pop(0)
# current_size = (x_right-x_left)*(y_right-y_left)
total_si... |
1abea71be689a269a2a2a2389263d58678b7e8ea | etsvetanov/python-course | /session_5/class_method.py | 197 | 3.546875 | 4 | class MyClass:
def __init__(self, name):
self.name = name
def print_name(self):
print(self.name)
my_obj = MyClass('John')
my_obj.print_name()
MyClass.print_name(my_obj) |
71b23e04241be08192aaff17cb9597a4e71858eb | jeffzhao35/CapitalOne | /api_client.py | 588 | 3.53125 | 4 | import json
import requests
API_KEY = "X35RriQxgbDSeCGrBTNoOPnbwTbV4FYsKyz2YgH8"
BASE_URL = "https://developer.nps.gov/api/v1/"
class ApiClient:
def parks(park_name, state, designation, keyword):
params={'api_key':API_KEY, 'limit':'50'}
# validates whether or not user entered specific query field
if park_name:... |
af4312a6782340d019a88c61e687d57bd02a4ff3 | vmms16/MonitoriaIP | /ProjetoIP - Modelo.py | 3,645 | 3.71875 | 4 | class Assento:
def __init__(self, numero , preco=20.00, disponivel=True):
self.__numero=numero
self.__preco=preco
self.__disponivel=disponivel
def getNumero(self):
return self.__numero
def getPreco(self):
return self.__preco
def getDisponivel(self):... |
6acdfec850d34b04b750d260a2acf5d39c4227d3 | LINKEIHAMM/PRAC06 | /guitars.py | 831 | 3.65625 | 4 | from guitar import Guitar
def main():
print("My guitars!")
guitars = []
guitars.append(Guitar("Fender Stratocaster", 2014, 765.40))
guitars.append(Guitar("Gibson L-5 CES", 1922, 16035.40))
guitars.append(Guitar("Line 6 JTV-59", 2010, 1512.9))
for i, guitar in enumerate(guitars):
... |
9068c5ab02d6b716e2a5dd59489be4e14625078e | jorgenmsilveira/python | /Terceiraimplementacao_Ficheiro.py | 6,041 | 3.953125 | 4 | """Este programa simula um robô de serviços, num restaurante com uma mesa de forma, tamanho e posição
aleatórios. Quando o utilizador clica na área da mesa, o robô inicia o serviço para essa mesa,
consistindo numa ida à mesa para receber um pedido, regresso ao balcão para preparar o pedido,
entrega do pedido à mesa,... |
c96ca10bc7c933b15a4cb0c03317566f6a1c8151 | tel49131/2019Algorithm-learning | /作業繳交/108DSA第一次作業 04123036 quick sort (python版).py | 2,702 | 4.03125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#第一次嘗試
a = [2,8,4,5,9]
def quicksort():
piviot = a[1]
for i in a:
if i< piviot:
x[j] = x[j-1]
# In[2]:
#第一次嘗試
quicksort(a)
# In[3]:
#第二次嘗試
a = [2,8,4,5,9]
def quicksort():
for i in a:
key = a[1]
left_point = a[i+1]... |
662ab55b03bbfbc6a20088ead2393f6d8b0419b1 | Irokanade/python_dictionary_print | /python_dictionary_print.py | 407 | 3.921875 | 4 | dict = {
"mathematics": "jiaoxue",
"dog": "gou",
"father" : "baba",
"news" : "xinwen",
"god" : "shen",
}
#find the longest string in dictionary
keyList = list(dict.keys())
longestKey = keyList[0]
for i in keyList:
if len(i) > len(longestKey):
longestKey = i
#printing the dictionary
for i in ke... |
ea69b8596ffcbef8dbdcc782834a3d6feb0ced12 | ashibaev/python | /Sort/utils/file_generator.py | 1,712 | 3.640625 | 4 | from random import randint
def generate_random_string(length):
answer = ""
for i in range(length):
answer += chr(33 + randint(0, 90))
return answer
def gen_tuple(types):
return tuple(str(randint(0, 100)) if t == "n" else generate_random_string(20) for t in types)
def gen_str(... |
fd372ae270139412f6d35e0f4c882823d4b59d71 | lilyandcy/python3 | /leetcode/canPlaceFlowers.py | 408 | 3.671875 | 4 | class Solution:
def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:
if n == 0:
return True
newBed = [0] + flowerbed + [0]
for i in range(1, len(newBed) - 1):
if newBed[i-1] == 0 and newBed[i] == 0 and newBed[i+1] == 0:
newBed[i] = 1
... |
d7a06d98499a5fd5872b51864cf504f9fec49991 | snowdj/Econometrics-1 | /HW2/HW2part5.py | 2,412 | 3.53125 | 4 | from __future__ import division
import numpy as np
from numpy import random
from uniformRV import uniformRV
import statsmodels.api as sm
from monte_carlo import monte_carlo
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import pylab as py
import npkde
'''
cd ~/Economics/Econometrics/Homework/HW2
Projec... |
6ceb74843ececfb4fb1b963d568a3390f0b1563e | jdarangop/holbertonschool-machine_learning | /supervised_learning/0x04-error_analysis/0-create_confusion.py | 695 | 3.75 | 4 | #!/usr/bin/env python3
""" Create Confusion """
import numpy as np
def create_confusion_matrix(labels, logits):
""" creates a confusion matrix.
labels: (numpy.ndarray) one-hot matrix containing the correct labels.
logits: (numpy.ndarray) one-hot matrix containing the predicted labels.
Retu... |
c9ab0c94432ddea0075d28d56e22aa4c69e1029b | rakamoviz/rank-clubs | /match_data_processor.py | 3,769 | 3.921875 | 4 | import argparse
import sys
import re
import functools
import os
def _calculate_points(score_1, score_2):
'''
Calculate the points associated to each score in the parameters
Parameters:
score_1 (str):First score
score_2 (str):Second score
Returns:
points_tuple (int, int):Returns the points... |
063d0a7e8804fce30ad5dcc5075a1ce070cd27fe | xvy5166/homework3-python | /main.py | 272 | 3.71875 | 4 | #Author: Xinyi Yang xvy5166@psu.edu
def digit_sum(n):
if n == 0:
return 0
else:
return n%10+digit_sum(n//10)
def run():
i = int(input("Enter an int: "))
num_sum = digit_sum(i)
print(f"sum of digits of {i} is {num_sum}.")
if __name__ == "__main__":
run()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.