blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
1f83f0b92532b57e37076d6d33600d3e887d32e0 | agahkarakuzu/spinalcordtoolbox | /spinalcordtoolbox/utils.py | 1,095 | 4.3125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8
# Collection of useful functions
from __future__ import absolute_import
import re
def parse_num_list(str_num):
"""
Parse numbers in string based on delimiter: , or :
Examples:
'' -> []
'1,2,3' -> [1, 2, 3]
'1:3,4' -> [1, 2, 3, 4]
'1,1:4' -... |
232842d4389b193d185f5451705906c58fe322ef | maridigiolo/python-exercises | /objexe/basics.py | 1,745 | 4.59375 | 5 | # Given the following Person class:
#
# class Person(object):
# def __init__(self, name, email, phone):
# self.name = name
# self.email = email
# self.phone = phone
#
# def greet(self, other_person):
# print 'Hello {}, I am {}!'.format(other_person.name, self.name)
# Write code t... |
78bbb3cf0cb5ba99bc21dc72f4cd1cfa594c26b9 | p-lothaller/Python_Exercises | /Tic-Tac-Toe, part 2.py | 2,776 | 3.75 | 4 | class TicTacToe:
def __init__(self):
self.turn = "X"
self.board = [[None for i in range(3)] for j in range(3)]
def mark_space(self, row, column):
# TODO
if 0 <= row <= 2 and 0 <= column <= 2:
if self.board[row][column] is None:
if self.turn =... |
904c9c33359008e76bd3c89361e92714a6f69710 | gaudibr/datasci_course_materials | /kaggle/python/train_stats.py | 2,870 | 3.71875 | 4 | """ This simple code is desinged to teach a basic user to read in the files in python, simply find what proportion of males and females survived and make a predictive model based on this
Author : AstroDave
Date : 18th September, 2012
"""
import csv as csv
import numpy as np
import math
#calculate entropy for the d... |
a39b8194fd0497659b2d37e1da8a9f7c614142b6 | chuckwondo/dsp | /math/matrix_algebra.py | 1,546 | 4.15625 | 4 | #!/usr/bin/env python
"""Answers to linear algebra questions.
Each test yielding an error means the answer is "not defined."
>>> A.shape
(2, 3)
>>> B.shape
(2, 2)
>>> C.shape
(3, 2)
>>> D.shape
(2, 3)
>>> u.shape
(4,)
>>> w.shape
(4, 1)
>>> print(u + v)
[ 9 7 -4 9]
>>> print(u - v)
[ 3 -3 -2 1]
>>> print(6 * u)
[... |
b7d161191e461aaab8d3dd78d716c282ff6c3402 | Roshni-Sahoo/LeanIn-ML-Circle | /assignment_problems/return_sum.py | 125 | 3.59375 | 4 | #Sum of numbers
limit=int(input())
ans=0
for i in range(0,limit+1):
if(i%3==0):
ans+=i
elif(i%5==0):
ans+=i
print(ans) |
cc71e4a7db15ac5ea2740c4b3e85898edbabc1ec | puguptal/democode1 | /exercise.py | 4,049 | 4.1875 | 4 |
# write a program to capture the string and the output in terms of list.
# enter any list : perl, unix, spark,scala
#List output - ['perl;, 'unix', 'saprk', 'scala']
# length of list - 4
#-----------------------------------------------------------
a = input('first string - ')
b = input('second string - ')
c = inp... |
e4c28047e1058db782a2923bd364aad8d132fbf7 | Zhylkaaa/qap-project | /QAP/objective.py | 1,275 | 3.84375 | 4 | import numpy as np
def naive_objective(dist: np.ndarray, costs: np.ndarray,
permutation: np.ndarray) -> int:
"""Naive objective calculation.
Args:
dist: matrix that represents distances between places
costs: matrix that represents cost per unit of distance for facilities
... |
d5b4d839ea3298523366374f3326b03565b1fbcd | KickItAndCode/Algorithms | /LeetCode/LongestContinuousIncreasingSubsequence.py | 1,677 | 4.0625 | 4 | # 674. Longest Continuous Increasing Subsequence
# Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).
# Example 1:
# Input: [1,3,5,4,7]
# Output: 3
# Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3.
# Even though [1,3,5,... |
60e039e35d823c1c626d33d12902e26b054a7e2f | gtr/kings-corner | /main.py | 8,824 | 3.640625 | 4 | from objects.Stack import Stack
from objects.Board import Board
from objects.Colors import Colors
from objects.Card import Card
message = "Welcome to the king's corner card game! \n\nCreated by: \tGerardo Torres \nDate: \t\t9/22/2018"
usage = "\n\t Usage: \n----------------------------\nusage\t\tprint this menu\npla... |
5242884132de0603fb505ed3695653558e64bc62 | skarim9/Eight-Puzzle | /project/searcher.py | 8,153 | 3.59375 | 4 | #
# searcher.py (Final project)
#
# classes for objects that perform state-space search on Eight Puzzles
#
# name: Shihab Karim
# email: skarim9@bu.edu
#
# If you worked with a partner, put his or her contact info below:
# partner's name:
# partner's email:
#
import random
from state import *
class ... |
53173054f58fa45675b81f443345c3a8a8c69061 | josenava/katas | /cracking_the_code_interview/python/chapter_2/04.py | 781 | 3.640625 | 4 | from chapter_2.linked_list import LinkedList, Node
def partition(ll: LinkedList, k: int) -> LinkedList:
ll_gte = LinkedList()
ll_lt = LinkedList()
aux = ll.head
while aux is not None:
if aux.value < k:
ll_lt.add(Node(aux.value))
else:
ll_gte.add(Node(aux.value)... |
51480d3e7a943cd0c885c6d64873740459e073bd | DSXiangLi/Leetcode_python | /script/[148]排序链表.py | 2,044 | 4.15625 | 4 | # 给你链表的头结点 head ,请将其按 升序 排列并返回 排序后的链表 。
#
#
#
#
#
#
# 示例 1:
#
#
# 输入:head = [4,2,1,3]
# 输出:[1,2,3,4]
#
#
# 示例 2:
#
#
# 输入:head = [-1,5,3,4,0]
# 输出:[-1,0,3,4,5]
#
#
# 示例 3:
#
#
# 输入:head = []
# 输出:[]
#
#
#
#
# 提示:
#
#
# 链表中节点的数目在范围 [0, 5 * 104] 内
# -105 <= Node.val <= 105
# ... |
0b40d9eb6e370819eb8a1e303c03273192d20273 | dorynakad/EaglesUAS | /pixel counter.py | 776 | 3.984375 | 4 | # imports
import numpy as np
from PIL import Image
from math import sqrt
# opening the image and loading it into a
# numpy array using PIL and numpy
img = Image.open("penny.jpg")
pixels = np.array(img)
# dimensions of the image
width, height, channels = pixels.shape
# this is information you will need ... |
03c2df347edceea1223913bab871c08a40662675 | OrfeousWriter/TextAdventureTest | /adventure.py | 1,991 | 3.734375 | 4 | def start():
print("A ray of sunlight beams across your eyes."
" You are instantly comforted by the rigorous rocking of the waves.")
print("To your left: a chair bolted down to the sturdy wooden flooring.\n"
"To your right: a small window with a brief glimpse at the deep blue sea beyond.")
... |
5b1a03ed0bdab1b5791fbbf5344b3d566ab17e70 | srhimel/office-python | /funtur.py | 532 | 4.15625 | 4 | import turtle
turtle.color("red", "green")
turtle.speed(10)
def turtle_circle(height, degree1 , degree2):
for i in range(20):
for j in range(4):
turtle.forward(height)
turtle.left(degree1)
turtle.left(degree2)
turtle.exitonclick()
while True:
heig = input("What is t... |
5ec02cd45bb22dae37b638264025743b6a410b78 | guillox/Practica_python | /2013/tp1/tp1ej10.py | 184 | 3.671875 | 4 | """10.- a) Escriba un script que reciba un caracter por entrada estandar e imprima su correspondiente codigo
ASCII en pantalla."""
car=raw_input('Ingrese un caracter')
print ord(car) |
bd9c1e9fa4147aa2707c76cb8b4aafe995c33364 | aanchal1234/Assignment1 | /assignment15.py | 1,730 | 3.671875 | 4 | #1- Extract the user id, domain name and suffix from the following email addresses.
emails = "zuck26@facebook.com" "page33@google.com"
"jeff42@amazon.com"
desired_output = [('zuck26', 'facebook', 'com'), ('page33', 'google', 'com'), ('jeff42', 'amazon', 'com')]
import re
b1="zuck26@facebook.com"
b2="page33@google.com... |
a76e5c436fee798e83945bb00347be4530113511 | kaushikd49/async_systems_dist_algo | /project/Accounts.py | 1,211 | 3.859375 | 4 | from Account import *
import random
class Accounts:
def __init__(self):
self.accountMap = {}
def isAccountPresent(self,accountNumber):
print("account map ",self.accountMap)
if not accountNumber in self.accountMap:
print('Account {} not present. Creating a new account. '.format(accountNumber))
acc = Acc... |
468b1865b91d5fc11fa66d7651c5678cf3ab3515 | alter027/notes | /PF Liu/PF1.py | 243 | 3.875 | 4 | import math
while True:
length=int(input())
width=int(input())
height=int(input())
a=length*width
b=width*height
c=length*height
print('the surface area is {} '.format(2*(a+b+c)))
print('the volumn is {} '.format(math.sqrt(a*b*c)))
|
82b615812dc8efa1ebd75c1f16189c5c4b227182 | betcherj/adventofcode2020 | /day1.py | 896 | 3.609375 | 4 |
def sum_to_2020(x):
for i in range(len(x)):
for j in range(i, len(x)):
if x[i] + x[j] == 2020:
return (i, j)
print("No entries found")
return None
def three_sum_2020(x):
for i in range(len(x)):
if x[i] > 2020:
continue
for j in range(i, l... |
187948995a2ae7f27df36fb80fa8cf1b8e9408f4 | ama0322/Algorithms-in-Python | /coding-bat-in-python/Warmup2/last2.py | 550 | 4.15625 | 4 | def last2(str):
"""
Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring).
last2('hixxhi') → 1
last2('xaxxaxaxx') → 1
last2('axxxaaxx') → 2
... |
2ddb97aa3a47b0d791716efe6181d3e9e06f3e4e | jijodv/py_class | /bsysarg.py | 350 | 4.0625 | 4 | #!/usr/bin/env python
import sys
print ("Name of the script: ", sys.argv[0])
print ("Number of arguments: ", len(sys.argv))
print ("The arguments are: ", str(sys.argv))
if len(sys.argv) is not 2:
print ("Usage: {} <arg1> <arg2>" .format(str(sys.argv)))
else:
print ("{} has {} arguments as expected" .format(str(sys.a... |
45ab06f6d5564529c1a14aed89ed1bca36bd076b | chuck0523/chuck-personal-repo | /python-math/6_1_3.trajectory.py | 1,513 | 3.765625 | 4 | from matplotlib import pyplot as plt
from matplotlib import animation
import math
g = 9.8
def get_intervals(u, theta):
t_flight = 2 * u * math.sin(theta) / g
intervals = []
start = 0
interval = 0.005
while start < t_flight:
intervals.append(start)
start = start + interval
retu... |
14e2c5e5354295739fa1d629789afc9a42653ecd | youkidkk/python-sample | /pysample/function/parameter.py | 345 | 3.59375 | 4 | def parameter(x, y=1, z=2):
print(x, y, z)
# 通常の呼び出し
parameter(2, 3, 4)
# -> 2 3 4
# 引数の省略して呼び出し
parameter(3, 4)
# -> 3 4 2
parameter(4)
# -> 4 1 2
# キーワードで指定して呼び出し
parameter(5, z=6)
# -> 5 1 6
# 引数リストのアンパック
args = [3, 4, 5]
parameter(*args)
# 3 4 5
|
b2aee853f38506567fc5f0d1e20c28e40fbb4ec9 | rausalgue/IS211_Assignment1 | /assignment1_part1.py | 975 | 3.890625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Assignemnt Week One - Part 1"""
class ListDivideException:
pass
def listDivide(numbers, divide=2):
"""Validates Data for Matchmaking
Args:
numbers (list): list of numbers
divide (int): The mini number of players needed for matches
Retu... |
acd8ae460dbdd3f06e65b318d0232b630e94ffd4 | Dawa1234/Billing_System | /Codes/bill_code.py | 12,802 | 3.828125 | 4 | from tkinter import *
# Creating a Class
class BillApp:
# Creating Function.
def __init__(self, root):
self.root = root
# Setting Resolution of the window.
self.root.geometry("1500x800+0+0")
# For the title of the Window.
self.root.title("Billing Software")
ti... |
8ea0b16a7a29b259019d6d611e0d1576c896a8a6 | smittank/Yr13-Textbook-Answers-MASTER | /Chapter 21.py | 2,958 | 4.09375 | 4 | class MyTime:
# ...
def __init__(self, hrs=0, mins=0, secs=0):
""" Create a new MyTime object initialized to hrs, mins, secs.
The values of mins and secs may be outside the range 0-59,
but the resulting MyTime object will be normalized.
"""
# Calculate total ... |
e3369e11d5d698d5dfd25efa2c0707b2ed9075f9 | brigitteunger/katas | /test_arranging_coins.py | 695 | 3.6875 | 4 | import unittest
import math
class Solution:
def arrangeCoins(self, n: int) -> int:
stairs = int(math.sqrt(2*n+0.25)-0.5)
return stairs
class TestArrangeCoins(unittest.TestCase):
def setUp(self):
self.sol = Solution()
def test_arrange_coins_5(self):
n = 5
stairs ... |
1d12f38978c4961173f9c0a2dd82b70ad863213a | jacksonbill2/pythonbasicfile-learning-github- | /python executable files/program3(just continue pass word quize).py | 323 | 3.828125 | 4 | x=str(input("enter the password (alpabets only)" ))
y=str(input("enter the confirm password(which u used above)" ))
z=str(input("enter your name"))
if x==y:
print("welome to the world of python programming")
print(z)
else:
print("wrong password")
print("try again")
print(z)
input(... |
204f47fbe8df600ac8944ef0c50815be236c5310 | DannyMcwaves/codebase | /pythons/PROJECT simples/locker.py | 1,316 | 3.71875 | 4 | """
this is a simple locker problem thingy.
there are 100 students in a school and each of them has a locker.
One day, the first student to enter the school opened his locker and the rest of the 99
lockers and left it opened.
the next student went to his/her locker and then closed it and then closed the remaining 98.
t... |
57c3e14cf5b9f58bd49d48e7ecbd2d366b786937 | anjana24-r/projects | /abc/regular expn/ab.py | 191 | 3.6875 | 4 | import re
n=input("enter a string")
x='(^a[a-zA-Z0-9\W]*b$)' # *ab 0 refers to nothing can come
match=re.fullmatch(x,n)
if match is not None:
print("valid")
else:
print("not valid") |
663e5bf9c2ad724caea8557f12edefde8b0ea4d8 | hsong124/LearntoType | /testPygame.py | 1,651 | 3.515625 | 4 | from google.cloud import texttospeech
import os
import pygame
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'C:/Users/Heather/Desktop/LearnToType/LTTKey.json'
#set up speech to text api
client = texttospeech.TextToSpeechClient()
voice = texttospeech.types.VoiceSelectionParams(
language_code='en-US',
ssml_... |
3301c53730245d8fc3a7e4e0f231043b9d1af8db | nonlining/Algorithms | /Complexity/evacuation.py | 3,327 | 4.15625 | 4 | # python2
class Edge:
def __init__(self, u, v, capacity):
self.u = u
self.v = v
self.capacity = capacity
self.flow = 0
# This class implements a bit unusual scheme for storing edges of the graph,
# in order to retrieve the backward edge for a given edge quickly.
class FlowGraph:
... |
10d1371a75d4e4c91c7bd4555bac1226887edd7e | karthikpalameri/PythonLearn | /methods/methodsDemo1.py | 2,780 | 4.09375 | 4 | """
methods demo
A group of code statements which can perform same specific task
Methods are reusable and can be called when needed in the code
def
"""
def sum_nums(n1, n2):
"""
Get sum of two numbers
:param n1:
:param n2:
:return:
"""
return (n1 + n2)
sum1 = sum_nums(2, 8)
sum2 = sum_... |
4f5b00216d6c08ebb12ad9b13b34aefaa0fc3ec7 | Esken1234/Programming | /Practice/11/Python/11. Возведение в степень.py | 366 | 3.890625 | 4 | a=float(input())
b=float(input())
a1=a
b1=(b*b)**0.5
if b>=0:
if b==0: print(1)
elif b==1: print(a)
else:
for i in range(2, int(b)+1):
a=a*a1
print(a)
else:
if b==-1: print(1/a)
else:
for i in range (2, int(b1)+1):
a=a*a1
print(1/a)
stop=input()#это для того, чтобы программа останавл... |
3c9942df9a3e511db8f057ed8f48f9a7413a5664 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2816/60703/243912.py | 153 | 3.59375 | 4 | n = int(input());
list = [int(x) for x in input().split()];
list.sort();
num = list[(int((len(list)-1)/2))];
# if(num==3):
# print(list);
print(num); |
a65b4f7b3239885878c4f0b5829c1b6282acc8ca | Nuullll/google-kickstart | /2019/Practice/normal.py | 1,054 | 3.515625 | 4 | def read_int():
return int(input())
def read_ints():
return list(map(int, input().split()))
def load():
N = read_int()
scores = list(map(int, input()))
return N, scores
def solve(case):
N, scores = case
# find largest sum of contiguous subarrays of length: (N+1)//2
... |
88ad816888b7f9459c1fec4774284eddebb4c719 | IanGSalmon/regex | /address_book_groups.py | 1,480 | 3.6875 | 4 | import re
names_file = open("names.txt", encoding='utf-8')
data = names_file.read()
names_file.close()
last_name = r'Love'
first_name = r'Kenneth'
# Define groups with parenthesis
# But if they don't have every item we're looking for, they don't get included
# No Dave, or King Arthur
#print(re.findall(r'''
# ([-... |
20d753bdaaf0feab21f57a3d57bb51947db6cfd3 | Mdananda/Python-Programming-Language | /Numpy Part/Array Index.py | 227 | 3.640625 | 4 | print()
#Start Program
import numpy as np
nm = np.array([[1, 2, 3], [3, 4, 5]])
print(nm[0:, 0:])
'''
Indexing fully same on list indexing.
2D-Array 2 3rd Braket use or one braket 2 parameter separate the comma operator
''' |
ddc6bed1b79082fe9676b3a34bc5965daced54ac | ngthnam/Python | /Python Machine Learning/20_Neural_Network_with_TensorFlow_on_MNIST_data.py | 4,605 | 3.6875 | 4 | import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
'''
input > weight > hiddenlayer1 (Activation Function) >
weight > hiddenlayer2 (Activation Function) >
weight > hiddenlayer3 (Activation Function) >
weight > output layer
compare results with intended output > cost function (cross ent... |
131d49ee748bc2c15cb409cb8bbe8bf588004ca2 | KULDEEPMALIKM41/Practices | /Python/Python Basics/110.exercise.py | 364 | 3.734375 | 4 | # solution for constructor overriding.
class A:
def __init__(self):
print('class A constructor member called')
def aData(self):
print('class A member called')
class B(A):
def __init__(self):
super(B,self).__init__()
print('class B constructor member called')
def bData(self):
print('class B member... |
ba02ef6df8fef188111f78a6091fe2770e61bda5 | Nikhil-Vinay/Python | /7_operators.py | 749 | 4.3125 | 4 | # arithmetic operator -> + - * / %
x = 10
y = 3
print x+y # 13
print x-y # 7
print x*y # 30
print x/y # 3
print x%y # 1
print x**y # 1000 ** is exponent operator
# comparison operator ==, != , <>, >,<=, etc
# shift operator >> <<
x = 1
print x # 1
print x<<1 # 2
# assignment operator +=, - = , *=, /... |
bbadf3357f21602070c32d6b00aee2f099462530 | xs0203401/yaohuangL-APAD | /hw2/test_gofish.py | 433 | 3.546875 | 4 | import random
import gofish
def new_deck():
rank=["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]
suit=["spades", "hearts", "diamonds", "clubs"]
deck = [(r, s) for r in rank for s in suit]
return deck
if __name__ == "__main__":
deck = new_deck()
random.shuffle(deck)
print... |
0b044f16928d4dcdad5b27b20f6127f9d3140b27 | hypergraphman/G3 | /Урок3/example1.py | 463 | 4.3125 | 4 | # Типы данных
# str - строки char - символ
# Строка это набор char'ов: 'a'
# 'Hello, world!'
# '' - это пустая строка
# int - целые числа
# 1, 2, -50, 100
# float - действительные числа
# 5.0, 2.3, -1,5
# bool - логические значения
# True False
# Пример 1
a = input()
# print(a + 1) # Error
print(int(a) + 1) # str to... |
e028052bd260b7bca3bf5ded152c1105464b5c6d | santiago0072002/Python_stuff | /operators.py | 4,126 | 4.9375 | 5 | #https://www.w3schools.com/python/python_operators.asp
#Python Assignment Operators
# Assignment operators are used to assign values to variables:
"""
Operator Example Same As
= x = 5 x = 5
+= x += 3 x = x + 3
-= x -= 3 x = x - 3
*= x *= 3 x = x * 3
/=... |
cb6bd1487ea225cfb28382be304b0c5faf0322da | edu-athensoft/stem1401python_student | /py200622_python2/day19_py200824/sample/string_22_join.py | 1,324 | 4.5 | 4 | """
join()
returns a string by joining all the elements of an iterable,
separated by a string separator.
string.join(iterable)
iterable = list, tuple, set, dictionary, string
"""
# Example 1. list
mylist1 = ['a','b','c', '1', '2', '3']
sep = ','
result = sep.join(mylist1)
print(result, type(result))
mylist1 = ['Pyt... |
af9d2ccf81a23468d6f88e12d8dc0bddd59be359 | woairui134/mashang | /pyzuoye.py | 1,040 | 3.890625 | 4 | # -*- coding: utf-8 -*-
import random
class timo:
myhp1 = 100
enemy_power = 0
def my_hp(self,myhp1,enemy_power):
self.myhp1 = myhp1
self.enemy_power = enemy_power
myhp = self.myhp1 - self.enemy_power
return myhp
class police:
enemy_hp1 = 100
my_power = 20
def e... |
a2aec90e306a5bc84eb6cb012cedb51463100dc4 | excess30/CompetitiveProgramming | /coingame.py | 1,041 | 4.21875 | 4 | # Python 3 program to find coins
# to be picked to make sure that
# we never loose
# Returns optimal value possible
# that a player can collect from
# an array of coins of size n.
# Note than n must be even
def printCoins(arr, n):
oddSum = 0
# Find sum of odd positioned coins
for i... |
75841e98b3b8d51df72858fab0d3337bb4dee514 | Tigrolik/git_workspace | /python/fileReading/readAndSort.py | 193 | 3.75 | 4 | #fname = raw_input("Enter file name: ")
fh = open('romeo.txt')
lst = list()
for line in fh:
for w in line.split():
if not w in lst:
lst.append(w)
lst.sort()
print lst
|
430e29f131dd3a5b14f4b13b73a829c9c9f73a43 | patsonev/Python_Basics_Exam_Preparation | /sea_trip.py | 390 | 3.765625 | 4 | money_food_day = float(input())
money_souvenirs_day = float(input())
money_hotel_day = float(input())
money_travel = 420 / 100 * 7 * 1.85
money_food = 3 * money_food_day
money_souvenirs = 3 * money_souvenirs_day
money_hotel = money_hotel_day * (0.9 + 0.85 + 0.8)
total_money = money_hotel + money_souvenirs + ... |
865095c86b4664675013a006d67091db27323755 | LizinczykKarolina/Python | /Dictionary/ex9.py | 719 | 4.1875 | 4 | #24. Write a Python program to create a dictionary from a string.
sample_string = 'w3resource'
d = {}
for i in sample_string:
if i not in d:
d[i] = 1
else:
d[i] += 1
print d
#25. Write a Python program to print a dictionary in table format.
my_dict = {'C1':[1,2,3],'C2':[5,6,7],'C3':... |
b56a6fc34e4685c02edb15b745275f3bc4b2c624 | gladysmorales/module3lab | /M3 Problem 2.py | 207 | 4.5625 | 5 | # This program asks the user for their name and greets them with their name
# Assign name as the variable
name = input ("What is your name?")
# Greet the user once they input their name
print("Hello", name)
|
b01750894a6880eede69f3ac59f44c7b2c5ce499 | pilagod/leetcode-python | /336.py | 937 | 3.5 | 4 | class Solution(object):
def palindromePairs(self, words):
"""
:type words: List[str]
:rtype: List[List[int]]
"""
dict = {}
result = []
for i in range(len(words)):
dict[words[i]] = i
for i in range(len(words)):
for j in range(l... |
dbb1da44ea282f9dc829732d5e8307bc4ffcca5c | Jimbiscus/Python_Dump | /Garlic bread/tempCodeRunnerFile.py | 789 | 3.734375 | 4 | :
list_of_fwords.append(word)
print(f"Il y a {count_words} mots qui finissent par e .")
for word in list_of_words:
print(f" - {word}")
print(f"il y a {count_fwords} mots qui commencent par f")
for fword in list_of_fwords:
print(f" - {fword}")
words_count = {}
longestF = []
for fword in list_of_fw... |
71a5162fff2f66bcf0744b3883a93b2bc3f7fe16 | 0xJinbe/Sci.CompPY.-FreeCodeCamp | /caderno 2.4.py | 3,857 | 4.34375 | 4 | #exercícios sobre random
#""" Display a random fruit from a list of five fruits. """
from random import choice
fruit = choice(['banana', 'maça', 'abacate', 'laranja', 'mamao'])
print(fruit)
#""" Randomly choose either heads or tails ('h' or 't'). Ask the user to make their choice. If their choice is the
#same as the... |
09c02540c964f4db02c5ffbd1a27b3c63f553f91 | Andrey27936/practicum_1 | /49.py | 653 | 3.75 | 4 | """
: practicum_1
: 1.0
: 49.
: 2020 .. ,
: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/deed.ru)
: 16/12/2020
: 49.
# Python: 3.9
"""
import random
N = int(input(" "))
A = [random.randint(-1, 1) for i in range(0, N)]
print(A)
for i in range(N):
if A[i] == 0 an... |
eda1def2ed2b848431538bd1e9b792b52eb60c1e | rjovelin/Rosalind | /Textbook_track/3A/kd_motif.py | 3,332 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 01:53:00 2015
@author: Richard
"""
import itertools
def kd_motif(input_file):
'''
(file) -> list
Get integers k and d and a collection of DNA sequences from the input file.
Return all (k, d)-motifs in Dna.
(k, d)-motifs are motifs x such that leng... |
355ad3fa8aafe00b31f2b5e52c0f2c4f335a9e62 | esvrindha/python-programming | /pallindrome.py | 158 | 3.671875 | 4 | vrin=int(input(""))
vamp=vrin
rev=0
while(vrin>0):
dig=vrin%10
rev=rev*10+dig
vrin=vrin//10
if(vamp==rev):
print("yes")
else:
print("no")
|
38fd0017e92ab962438f08a9d02414ad4bca49bd | cravenormality/portfolioterm2 | /WordSearchGame.py | 5,288 | 3.5625 | 4 | #Dominic Santistevan & Jessica Weinburger
#Question list, their corresponding answers, and a score
import random
questionList = ["If within another if statement","Checks for a character wihtin a string",
"Another option within an if statement","How you end an if statement",
"Data ty... |
77cff0c5ae1a1e21e3a8461410df60f127799414 | swtwinsy/Code_Challenges | /projecteuler.net/problem_19.py | 1,489 | 3.828125 | 4 | # from datetime import date
def zeller_calculation(yr, mo):
"""
don't need day as all days will be on first of month
:param yr: year in question
:param mo: month in question
:return: returns 1 if 1st was on Sunday otherwise 0
"""
if mo < 3:
mo += 12
yr -= 1
m = 13 * (mo... |
d675d382e099436a928d3899e91bd0fd40b532a6 | moshiur-ux/simple-Phython-code | /name.py | 248 | 3.859375 | 4 | t = int(input(""))
type(t)
for x in range(1,t+1):
a=int(input(""))
b=int(input(""))
c=int(input(""))
if(a*a+b*b==c*c or b*b+c*c==a*a or a*a+c*c==b*b):
print("case %i: YES"%x)
else:
print("case %i: NO"%x)
|
3db1ddd1557524010334887def5199128e5c643c | jkcadee/A01166243_1510_assignments | /A1/doctests.py | 8,391 | 4.03125 | 4 | import doctest
# roman_numerals
def divisor_for_roman_numeral(number_1, number_2):
"""Divides the first parameter by the second parameter
>>> divisor_for_roman_numeral(10, 5)
2.0
>>> divisor_for_roman_numeral(8, 2)
4.0
"""
num = number_1 / number_2
return num
def remainder_number(nu... |
8c0420e475828c9a24db6f80b359b97ed69f0812 | YuanKQ/leetcode | /src/Linkedlist/merge_two_sorted_list/best_result.py | 2,298 | 3.78125 | 4 | #-*- coding: utf-8 -*-
"""
*****************************************
@Time : 2018/2/4 13:51
@Author : Yuan Kaiqi
@Site :
@File : best_result.py
@Software: PyCharm
@Desctiption:
┏┛┻━━━┛┻┓
┃ ┃
┃ ┳┛ ┗┳ ┃
┃ ┻ ┃
┗━┓ ┏... |
1246bc1cec672fbe88c0999f1ceb6dbc6732d5b4 | Yarl745/BigStorageOnConda | /codewars/human_readable_time.py | 293 | 3.828125 | 4 | def make_readable(seconds):
hours, minutes = 0, 0
hours = seconds // 3600
seconds -= hours * 3600
minutes = seconds // 60
seconds -= minutes * 60
return "{hours:02}:{minutes:02}:{seconds:02}".format(hours=hours, minutes=minutes, seconds=seconds)
print(make_readable(0)) |
b28d842a785b8ddc61b449d5b2e5e78fcaf55740 | MikeBarkerSpain/TareasTheBridge | /Entregables/Entregados/03_Hundir_la_Flota/func2.py | 3,469 | 4.3125 | 4 | def insert_boat_check(pos_str, boat_len, Tablero):
# lo primero es comprobar si el formato de insercion es el correcto
# los dos puntos son un elemento constante en la inserción de posición
if pos_str.count(':')==1:
# comprobación de elementos de una inserción vertical
if pos_str.count("v... |
0ff71634772a102e7299c6b6e1f7779dd061eeac | Orelavant/PracticeProblems | /Kattis/11_21_20/c.py | 972 | 3.59375 | 4 | import sys
def hiddenPass(file):
passW = ""
msg = ""
passWDict = {}
# Setup
for line in file:
lineArr = line.split()
passW = lineArr[0].rstrip()
msg = lineArr[1].rstrip()
# Populating passWDict
for char in passW:
if char in passWDict:
passWDict[... |
080341b9ac0f1d109c9c1f7de120adfc989e216e | mepragati/100_days_of_Python | /Day 001/BandNameGenerator.py | 251 | 4.1875 | 4 | #Band Name Generator Program
print("Welcome to the Band Name Generator !!")
name=input("What is the name of the city you grew up in?\n")
pet=input("What is the name of the first pet you owned?\n")
print("The name of your Band could be: "+name+" "+pet) |
ccddfb5b2ed43e10537ff4b4c986bc55297f893d | broker25/Python_lessons_basic | /lesson02/home_work/hw02_normal_My_hw_4.py | 901 | 3.890625 | 4 | # Задача-4: Дан список, заполненный произвольными целыми числами.
# Получите новый список, элементами которого будут:
# а) неповторяющиеся элементы исходного списка:
# например, lst = [1, 2, 4, 5, 6, 2, 5, 2], нужно получить lst2 = [1, 2, 4, 5, 6]
# б) элементы исходного списка, которые не имеют повторений:
# например,... |
24cfa7fd4b69fec468f36132321c46aa358cc260 | hawkraft/python-MyFirstProject | /MergeSort.py | 679 | 3.796875 | 4 | #!/usr/bin/python3
import math
def merge(arr, p, q, r):
n1 = q - p + 1
n2 = r - q
temp1 = [0] * (n1 + 1)
temp2 = [0] * (n2 + 1)
for i in range(0, n1):
temp1[i] = arr[p + i]
for j in range(0, n2):
temp2[j] = arr[q + j + 1]
temp1[n1] = math.inf
temp2[n2] = math.inf
... |
7b2310db415397f228b28f9bf1b181cd2c8e6bce | vsanghan/fare_calculator | /fare_calculator.py | 2,200 | 3.578125 | 4 |
import requests
import json
from datetime import datetime
def fare_calculator():
origin = input("Enter the origin : ")
destination = input("Enter the destination : ")
mode = input("Enter the travel mode (rick or taxi or bus): ")
if mode == 'bus':
bus_type = input("Enter the type of bus(ac o... |
832af0a7b665893f1fe39802a6e2fd8d187f8dc1 | hottarian/sample | /sample.py | 428 | 3.703125 | 4 | import datetime
today = datetime.date.today()
print(today)
num = 12
if num < 4 :
cal = 10
print(cal)
else :
cal = 50
print(cal)
list_max =[1,2,3,4]
print (list_max)
list_len = len(list_max){key: value for key, value in variable}
print(list_len)
list_max.append(5)
print(list_max)
list_max.inser... |
26ed61e036899f8327ad09a2f46c17aa9c1eb6f8 | hrit1995/Sorting-Analysis-Queue-BST | /queue_sort.py | 667 | 3.84375 | 4 | def minIndex(queue, sorted_index):
min_index = -1
min_val = float('inf')
n = len(queue)
for i in range(n):
curr = queue[0]
queue.pop(0)
if curr <= min_val and i <= sorted_index:
min_index = i
min_val = curr
queue.append(curr)
return min_index
def insertMinToRear(queue, min_index):
m... |
e79ee5a4b22bbfa874bdc6f9862ab3df33427ca9 | ximimiao/JZ.offer | /num6.py | 419 | 3.921875 | 4 | class resolution:
"""
斐波那契数列
"""
def Fibonacci(self,n):
if n<=1:
return n
first,second,third = 0,1,0
for i in range(2,n+1):
third = first +second
first = second
second = third
return third
if __name__ == '__main__':
fi... |
e7b0deb2a2b6aeeadd2fcda0c31ff36af451fceb | rahaf19-meet/meet2017y1lab5 | /fun2.py | 269 | 3.734375 | 4 | #print("*")
#print("*")
#print("*")
#print("*")
#print("*")
#print("*" *5)
#def draw_1d(n,char):
#print(char*n)
#def draw_reactangle(n1,n2):
#for i in range(n1):
#print('*'*n2)
def draw_2d(n,m,char1):
for i in range(n):
print(char1*m)
|
0d80cda07752af3bb106071d930a26e5eb2260a3 | aliciamorillo/Python-Programming-MOOC-2021 | /Part 3/03. Numbers.py | 109 | 3.734375 | 4 | limit = int(input("Upper limit:"))
number = 0
while number < limit-1:
number += 1
print(number) |
74cd98e328895ddc7b528efdfecf684c65f2620a | kreativitea/ProjectEuler | /problems/euler011.py | 1,484 | 3.5 | 4 | from operator import mul
def euler011(n, grid):
''' Largest product in a grid
In the 20*20 grid below, four numbers along a diagonal line have been marked in red.
The product of these numbers is 26 * 63 * 78 * 14 = 1788696.
What is the greatest product of four adjacent numbers in any direction (up,... |
529507b1793c2cd306bc1dca1d1cdeef29ddc5f5 | chetanrakheja/python_niit | /wordOccr.py | 666 | 4.1875 | 4 | sentence = input("enter a sentence \n")
#sentence = "tic tac toe is named as tic tac toe when it was made"
words = sentence.split(" ")
wordToSearch = input("enter a word to search \n")
#wordToSearch = "tic"
countWord=0
for j in words:
if j==wordToSearch:
countWord +=1
print (words)
print(... |
56a0318eb41f6cf2cc6e613ec88f203a0cc9c252 | primelos/cs-prac | /leet_python/intersection_two_linkedlist.py | 1,613 | 4.125 | 4 | # Write a program to find the node at which the intersection of
# two singly linked lists begins.
# For example, the following two linked lists:
# begin to intersect at node c1.
# Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
# Output: Reference of the node with value = 8
#... |
3b617f9786c1d189db1c940156cdd2cc0ebe412f | YPrahasith/DIP_Lab | /Lab5/YPrahasith_lab5.py | 1,593 | 3.578125 | 4 | # Program to filter an image using averaging low pass filter in spatial domain and median filter
from PIL import Image
def low_pass_mean_filter(img):
mean_img = Image.new('L', (img.width, img.height))
for i in range(img.width):
for j in range(img.height):
total = 0
n = 0
... |
7ccef30a70c0196d304078df3a8e3e6d78aea942 | subhayan-test/python-practice | /Couroutines/average_calculator.py | 1,860 | 3.546875 | 4 | # Simple couroutine which calculates the running average of numbers
# There are two examples presented here one without priming and the other one with priming
from priming_couroutines import couroutine
def calc_average():
average = 0
total = 0
count = 0
while True:
value = yield average
... |
fae1eb629c88356aba82e93d8fd6eefc8e10c911 | billy98/s10 | /day1/list.py | 237 | 3.828125 | 4 |
name_list = ['alex', 'eric', 'billy', 'rain', 'jason', 'rain', 'jack', 'james']
name_list2 = ['andy','lay']
name_list.extend(name_list2)
print name_list
age = [23,68,32,11,38,87,18,8,3]
age.sort()
print age
age.reverse()
print age |
147c4469c66c2caf4a82db0d1bdbf991152f0edf | davakir/geekbrains-python | /lesson-2/fourth.py | 227 | 3.6875 | 4 | string = input('Введите строку из нескольких слов: ')
string = string.split(' ')
for num, word in enumerate(string):
if len(word) > 10:
word = word[:10]
print(f'{num+1}: {word}')
|
e16668e3fe6ddbd43b0d815073cbb5641214d2af | subedisapana/python-fundamentals | /Functional Programming/map_filter_lamda.py | 827 | 3.890625 | 4 | '''
much more faster than comprehension function'''
def sqr(num1):
return num1**2
l = [10,20,30,40,50]
result = list(map(sqr,l)) #function as an argument
print(result) # we will get map object
#or value in result:
#print(value)
def add(num1, num2):
return num1+num2
l1=[100,200,300,400]
l2=[10,20,30,40,... |
b5ba679adccb82851f19100452a72b784e66d955 | saramic/learning | /dojo/adventofcode.com/2021/catchup/imnimo-day22.py | 5,343 | 3.59375 | 4 | # https://pastebin.com/vKSar4KB
import numpy as np
def part_1():
#part 1 is pretty easy, we just make an array of the size we need, and do the operations
#Note that I just manually deleted the items outside the valid range from the
#input file (they all come before the invalid ones)
#that was faster than writ... |
68ecca71596abe848393d3da14f2dac2f198f7f6 | DanPiston/ProjectEuler | /prob_4.py | 356 | 3.765625 | 4 | def gen_product(x, y, max_num):
palindrome_list = []
while x <= max_num:
while y < max_num:
product = x * y
if str(product) == str(product)[::-1]:
palindrome_list.append(product)
y += 1
y = x
x += 1
return max(palindrome_list)
... |
2dff086eea8ed71221acc62c3691e0b4524de71d | susan025/myproj01 | /test0315/exam02.py | 485 | 3.671875 | 4 | import random
if __name__ == '__main__':
#随机生成一个序列,再次生成一个整数,查看这个整数有没有在序列中
print("序列为",end=":")
mlist = list()
for i in range(0,5):
m = [random.randint(0,10)]
mlist.append(m)
print(mlist)
print("整数为",end=":")
n = [random.randint(0,10)]
print(n)
if mlist.index(n):
... |
de8cd4eba0fe4463304bf33be1203e98c9894c84 | Junga15/Keras2 | /keras2.0/KEYWORD_argmax.py | 246 | 3.84375 | 4 | import numpy as np
x = np.array([1,2,3,4,5])
y = np.array([[1,2,3],[6,5,4],[20,10,100]])
print(np.argmax(x)) ##최대값의 순서(인덱스값) 구하기
print(np.argmax(y,axis=-1)) #-1을 넣어야 최대값의 순서(인덱스값) 구하기
|
87eeb03733e5cf9ceabfa63ffa0eee4970b6d1f1 | rfujino731/python_study | /practice/python_style_rule.py | 1,568 | 3.640625 | 4 | # 不必要なセミコロンは省く
x = 2;#これでも動作するが、;は書かないのが、基本ルール
print(x)
# 不要な()も省く
if (a and b):#pythonはこれでも動くが、不要な()はつけないのがルール
#1行は80文字にする。80文字以上は改行すること
def test_def(abddef…
…xyz)#改行する際は、()のインデントを揃えること
#ただしurlは、改行するとあとがめんどくさいので、80文字を超えても改行しなくて良い
#pythonのタブは原則4つにする
#演算子の前後は、半角スペースを入れる
A = 2 + 3
#ただし関数の宣言に... |
6b2f60d4cd1f27d12118552935526085fc476130 | purcellconsult/python_advance | /Random_Stuff/random_person_generator.py | 281 | 3.796875 | 4 | from random import choice
first_names = ['Jack', 'Sally', 'Mike', 'Jennifer', 'Kevin', 'Sue']
last_names = ['Johnson', 'Nguyen', 'Adams', 'Garcia', 'Abera']
def create_names():
name = '{} {}'.format(choice(first_names), choice(last_names))
print(name)
create_names()
|
9d9171c4bbf0d18721e21d606d20ee087e43e3c4 | alexandraback/datacollection | /solutions_5652388522229760_1/Python/togatoga/solve.py | 347 | 3.546875 | 4 | T = int(input())
for i in range(T):
N = int(input())
if (N == 0):
print ("Case #%d: INSOMNIA" % (i + 1))
continue
digits = set()
base = N
while (True):
for x in str(N):
digits.add(x)
if (len(digits) == 10):
break
N += base
print ("C... |
59b004e3360413b4f99b3efc537a2863213e183b | Knimisha/Python_Basics | /NMK_Common strings function1.py | 288 | 4.3125 | 4 | # len function is used to find the length of the string
String1 = "a I love my country"
print(len(String1))
# to print the stings in upper case
print(String1.upper())
# to print the strings in lower case
print(String1.lower())
# to capitalise the string
print(String1.capitalize()) |
34a97959654dff7120e3b8cd702078e2e576744f | paddyjclancy/eng_57_class_notes | /Python/exercises/108_mr_miyagi.py | 1,772 | 3.5625 | 4 | # mr Miyagi trainee
# make a mr miyagi virtual assistant
# as a user I should be able to speak with mr miyagi and get appropriate response s as I go
#
# Ask for user input and depending on the response, mr Miyagi will respond.
#
# prompt user for input
# Evaluate each input and print the appropriate responses
# Foll... |
08ec3489673e958acc93babaac29585209e9722d | sathishkumark27/LearningNewCPPFeatures | /graphs_python/1.py | 2,758 | 4.09375 | 4 | # Write a program to calculate the resources needed
# to remodel a golf course hole.
# See assignment description for details.
#
# The inputs should be:
# Enter Course Length:
# Enter Course Width:
#
# The outputs should be:
# Total square yards of rough sod:
# Total square yards of smooth so... |
fd9b96505eac2eed73a2017858aa9b1045b0cddd | dongkyu92/TIL | /Python/Algorithm/Palindrome_deque.py | 552 | 3.625 | 4 | import collections
# deque 자료형을 이용한 최적화 리스트보다 5배 빠른 실행속도. 약 64ms
def isPalindrome(s: str) -> bool:
# 자료형 데크로 선언
strs: Deque = collections.deque()
for char in s:
if char.isalnum():
strs.append(char.lower())
while len(strs) > 1:
if strs.popleft() != strs.pop():
... |
b1c15a3647eed908f690f2c288b19d7b7a9b598d | nicsins/Capstone2020 | /databaselab/part1db.py | 683 | 3.90625 | 4 | import sqlite3
conn = sqlite3.connect('part1db')
conn.execute('create table if not exists Records (full_name name , country text ,catches integer)')
conn.execute('insert into Records values ("Janne Mustonen", "Finland",98)')
conn.execute('insert into Records values ("Ian Stewart", "Canada",94)')
conn.execute('inse... |
8eb4740899cd582fe65da4be15ffc295abd20aa0 | marisakaupert/algorithms | /pythonChallenge/caesarCipher.py | 830 | 3.515625 | 4 | import string
def cipher(text):
alphabet = string.ascii_lowercase
result_string = ""
for i, val in enumerate(text):
if val in alphabet:
if alphabet.index(val) == 24:
result_index = 0
elif alphabet.index(val) >= 25:
result_index = 1
... |
28db7facae8a7b426129f237388759667c6ab526 | bellacapilla/bioinformatics | /neighbor.py | 647 | 3.78125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 27 09:27:33 2020
@author: isabellac
"""
from hammingdist import hammingDistance
def Neighbors(Pattern, d):
if d == 0:
return Pattern
elif len(Pattern) == 1:
return {'A', 'C', 'G', 'T'}
Neighborhood = []
SuffixNeighb... |
0c579384989cd55715081daf4cd821717eb5d379 | mrfc0301/Litao_Learning | /pycode/fraction.py | 800 | 4.03125 | 4 | # -*- coding:utf-8 -*-
"""
作者:李涛
日期:2020年11月02日
"""
# 分数表示
class Fraction:
def __init__(self, a, b):
self.a = a
self.b = b
x = self.gcd(a, b)
self.a /= x
self.b /= x
def gcd(self, a, b):
while b > 0:
r = a % b
a = b
... |
356e2f8d31b0f801f6e088395c5215cc14accda4 | icoding2016/study | /PY/leetcode/longest_palindrome.py | 1,528 | 3.796875 | 4 | # Longest Palindrome
# Easy
# Given a string s which consists of lowercase or uppercase letters,
# return the length of the longest palindrome that can be built with those letters.
# Letters are case sensitive, for example, "Aa" is not considered a palindrome here.
#
# Example 1:
# Input: s = "abccccdd"
# Output: 7
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.