blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f81a296538f4059927d91edd5ab1c79aee3f3bc5 | theodoresi/leetcode_solutions | /python_version/171_excel_sheet_column_number/excel_sheet_column_number.py | 535 | 3.671875 | 4 | #!/bin/env python
class Solution:
def letter_to_number(self, letter):
"""
>>> solution = Solution()
>>> solution.letter_to_number('A')
1
>>> solution.letter_to_number('b')
2
>>> solution.letter_to_number('Z')
26
"""
return ord(letter.up... |
9b1e013fc92bff0a43c2b166c5a15fd6f41e43c2 | theodoresi/leetcode_solutions | /python_version/283_move_zeros/move_zeros.py | 805 | 3.6875 | 4 | from typing import List
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
We need a p1 to find the next zero, and a p2 to find the next non-zero
"""
n = len(nums)
if n <= 1:
return None... |
6d97c8835e8918182dc5121ba0eea8126fe6b368 | Tekaichi/Bias-Reduction-in-Crowdsourced-ContentModeration-Tasks | /data/format_dataset_shuffle_comments.py | 5,040 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 2 22:06:06 2020
@author: msdc1
"""
# -*- coding: utf-8 -*-
"""
Create two datasets in csv format; one for India, and one for USA
@author: Miguel Cardoso
"""
import random as rand
import csv
import pandas as pd
def inverse(label):
if(label... |
f4b864f11e387c056d578acb682cb3ffb73d6d8b | NCookies/TrendDetector-FB | /choose_data.py | 976 | 3.515625 | 4 | # -*- coding: utf-8 -*-
import argparse
import unicodecsv as csv
import sys
def commandline_arg(byte_string):
unicode_string = byte_string.decode(sys.getfilesystemencoding())
return unicode_string
parser = argparse.ArgumentParser()
parser.add_argument("-i", dest="input_file_name", default=None,
... |
f6ccd8910cae7dc6a90f06e66eaf90504f7cdc3f | bschwyn/friendAbot | /dunno.py | 1,573 | 3.6875 | 4 | #split and prepare tweets.json
#tweets.json has format [{},{}, {}, {},...]
#read array and print tweet to file line by line.
#load portion of array (figure out how to do this)
#for array split portion
#get array chunk,
#turn json to list of strings
#download Karpathy charRNN
import json
def json_to_tweets():
j... |
f537f8f0a6970c15b6e445d6437d266ae18a1746 | Lana-Pa/Python-Algorithms-from-Udemy | /linked_list.py | 4,275 | 4.375 | 4 | #create a singly linked list
class Element(object):
def __init__(self, value):
self.value = value
self.next = None
class LinkedList(object):
def __init__(self, head = None):
self.head = head
def append(self, new_element):
""" add a new element at the end of a list """
... |
e38a58b563e235d061c18ca5a6d492df1ae90ebe | sdoylelambda/python_code_challenges | /fibInf.py | 3,211 | 4.3125 | 4 |
import math
import os
import random
import re
import sys
#
# Complete the 'fibonacci' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts INTEGER n as parameter.
# U.P.E.R.
# U - UNDERSTAND
#
# FIB NUMBERS = SEQUENCE OF NUMBERS WHERE:
# AFTER FIRST 2 NUMBERS
... |
88f444d2df6740cf17346c6aa20aab4d57c829d7 | sdoylelambda/python_code_challenges | /FibAgain.py | 329 | 3.859375 | 4 | n = 10
def recurse(n):
# make list with [0,1,2]
fibList = [0, 1, 2]
# repeat n number of times
for loop in n:
# add positions list[1] + list[2] to list
position3 = fibList[1] + fibList[2]
fibList.append(position3)
# increment list
print('fibList', fibList)
return... |
989d94b72a9785505afcb96435c2365f26469e03 | abargar/dropout | /network_code/wf_model.py | 2,090 | 3.875 | 4 | """
Simplest model for testing: 2 hidden layers with 10 units apiece, and one
logistic sigmoid output unit. Thresholding function is piecewise linear.
This model was employed in "An empirical analysis of dropout in piecewise linear networks"
by Warde-Farley et. al. It was used to solve binary problems over the MNIS... |
bf67cf38475ed135ca480cc4b2df869b677f2e9f | logotip123/py_fcsv | /fcsv.py | 437 | 3.5625 | 4 | """Total price module"""
import csv
def calc_price(filename, open_=open):
"""
Search total price in all file
:param filename: file for reading
:param open:
:return: the sum of all multiplications
"""
with open_(filename, 'rt') as csvfile:
reader = csv.reader(csvfile, delimiter=',')... |
beec8328469968d60d03c7837ea3373a2024276f | 010akv/ctci-python | /linked-lists/linked_list_all.py | 5,879 | 3.9375 | 4 | class Node:
def __init__(self, value):
if not value:
raise ValueError('Need at least one value to init a Node')
self.value = value
self.next = None
class LinkedList:
def __init__(self, value):
if not value or not isinstance(value,int):
raise ValueError('N... |
6e71471983339a96d41f667454a3e11fba146e44 | 010akv/ctci-python | /big-o/sum-1-to-n.py | 1,611 | 3.59375 | 4 | import argparse
from timeit import default_timer as timer
import sys
def parse_my_args():
parser = argparse.ArgumentParser()
parser.add_argument('--num', required=True, type=int, help="Enter 'n' to find the sum of n natural numbers")
parser.add_argument('--rec',default=False, type=str2bool, help="Enter True to use... |
cfaa681c966927ff3c7b16c30dd8abcf1900748e | bimasetia/python-exercise | /33.py | 78 | 3.6875 | 4 | a = [1, 2, 3]
for n,i in enumerate(a):
print(f"Item {i} has number {n}")
|
eabd1735ad7573e3bbfed0e3af2c34adf35027ab | bimasetia/python-exercise | /57.py | 153 | 3.5 | 4 | line = input("Enter Values:")
line_list = line.split(",")
with open("user_data.txt", 'a+') as file:
for i in line_list:
file.write(i + "\n")
|
1b15e2585a3f8db77cf391ba313c45a8479dafb5 | 1Crazymoney/transpyle | /test/examples/python3/matmul.py | 1,193 | 3.515625 | 4 | #!/usr/bin/env python3
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('limit', type=int)
parser.add_argument('width', type=int)
parser.add_argument('height', type=int)
args = parser.parse_args()
limit = args.limit
width = args.width
... |
6a97f49eaf1da8c91cbe9c7674bbdbb48e2e8c59 | bl15343/lpthw2 | /ex11.py | 676 | 3.8125 | 4 | #print "How old are you?",
age = raw_input("How old are you? ")
#print "How tall are you?",
height = raw_input("How tall are you? ")
#print "How much do you weigh?",
weight = raw_input("How much do you weight? ")
print "So, you're %r old, %r tall, and %r heavy." % (
age, height, weight)
#Study drills 3.
name = r... |
e2db90fc84fa7843084cb0036289a33d9676ebd5 | Maria16pca111/StartingToEnd | /KthPrimeVariant.py | 448 | 3.859375 | 4 | def IsPrime(n):
flag=True
for i in range(2,n**1/2):
if(n%i==0):
flag=False
break
return flag
def kthprime(n,k):
if(n==1 and k==1):
print(2)
return
count=0
while(count<=k):
if(IsPrime(n)):
count+=1
if(count==k):
... |
028e66ab901e9bccbd8953be367343eac9ccf7d4 | kirabot/kirabot.github.io | /essayify.py | 2,775 | 3.890625 | 4 | from datetime import date
import textwrap
working_essay_file = open("working_essay.txt", "r")
lines = filter(None, (line.rstrip() for line in working_essay_file))
def today_to_meta_text():
# Formats date to display on site e.g. 22 Dec 2020
meta_text = date.today().strftime("%d %B %Y")
meta_text = meta_text... |
512386b3c3dd50fe2a241e590b3f5713fd3b6152 | damianaudley/collaborative-document | /quadratic.py | 167 | 3.625 | 4 | def quadratic(a, b, c):
"" some function ""
return a * b * c
# a is the number of apples
# b is the number of bananas
# c is the number of carrots
|
5c973bce02aea8b20aae6d1991200d7863843810 | pratya08/Open_Cv_IEEE_WIE.night_session | /Type_Shape.py | 524 | 3.921875 | 4 | import cv2 #importing the module
#OpenCv reads an image as a matrix
""" Image Characteristics"""
img=cv2.imread("flower.jpg",1) # reading a Coloured Image
print("Image is in the form a 3D matrix")
print(img)#3D array
print("The size of the image is : ")
print(img.shape)
print("The type of the ima... |
205ae87ad2f8f87e4a24d1a879068f1c87eeb349 | Adil-Anzarul/Pycharm-codes | /OOPS 14 Operator Overloading _ Dunder Methods T67.py | 971 | 4.125 | 4 | """opertor overloading"""
class Employee:
no_of_leaves=8
def __init__(self,a,b,c): #this is constructor
self.name=a
self.salary=b
self.role=c
def printdetails(self):
return f" The name is {self.name}, salary is {self.salary} and role is {self.role} "
@classmethod
... |
c89113d0a7c085a442e4bee58153c4666d1c44b6 | Adil-Anzarul/Pycharm-codes | /coroutinessss.py | 538 | 3.90625 | 4 | # this prog. is to search a character from list
# by using coroutines
def search():
import time
time.sleep(5)
list1=[chr(i) for i in range(ord('A'),ord('Z')+1) ]
# print(list1)
while 100:
text=(yield )
if text in list1:
print("Text Found")
else:
pr... |
b036ee70ca19716724d843b45a70348e3daa9e15 | Adil-Anzarul/Pycharm-codes | /test2.py | 197 | 3.6875 | 4 | # a=[1,2,3,4,58,75,42,25,7,8,5]
# def kind(a):
# print(a,"\t",a[0])
# return a[0]
# a.sort(key=kind)
# print(a)
a=[1,2,"adil"]
# b=[1,2,"adil"]
# b=a[:]
b=a
print(b is a)
print(b == a)
|
904dc5a14ffc65e5fa8a01ff027941a1038ba4d0 | Adil-Anzarul/Pycharm-codes | /OOPS 8 Multiple Inheritance T61.py | 1,375 | 4.03125 | 4 | """MULTIPLE INHERITANCE"""
class Employee:
var=8
no_of_leaves=8
def __init__(self,a,b,c): #this is constructor
self.name=a
self.salary=b
self.role=c
def printdetails(self):
return f" The name is {self.name}, salary is {self.salary} and role is {self.role} "
@clas... |
8a5c074c5149329f51600e7eb7a9be1785203267 | Adil-Anzarul/Pycharm-codes | /driving.py | 81 | 3.65625 | 4 | print("Enter your age")
var1=int(input())
if var1<18:
print("You cant drive") |
c5aeb8fd7bca66afb3cb4dfc4fefe23e6bbf247c | Adil-Anzarul/Pycharm-codes | /T41 _args and __kwargs In Python .py | 736 | 4.03125 | 4 | def function_name_print(a,b,c,d,e):
print(a,b,c,d,e)
function_name_print("harry","arohan","adil","imran","rima")
#args aur kwargs ka place ma koi aur name v likh sahta hai
def funargs(normal,*args,**kwargs):
print(type(args))
print(normal)
for item in args:
print(item)
for key,value in kw... |
111abe2687b360b6da81be81348547ed351844f7 | Adil-Anzarul/Pycharm-codes | /T31 Using With Block To Open Python Files.py | 222 | 3.703125 | 4 | with open("harry.txt") as f:
a=f.readlines()
print(a)
"""when opened with with block no need to close the fine
with block is equivalent to
fopen and fclose
"""
f=open("harry.txt")
print(f.readlines())
f.close() |
332c8086a614f5150d98c7086d501eee6be8ca2e | Adil-Anzarul/Pycharm-codes | /table.py | 156 | 3.609375 | 4 | if __name__ == '__main__':
print("Enter the number u wanna table off")
n=int(input())
for i in range(1,11):
print(n," * ",i," = ",n*i);
|
de9c9e8b292c216cd9a1936db3e1e207d800099a | bsusila/Bagus-Susila_I0320016_Wildan-Rusydani_Tugas4 | /I0320016_soal3_tugas4.py | 141 | 3.546875 | 4 | # berat maksimum bagasi (kg)
x = 22.68
y = int(input("Masukkan berat bagasi : "))
print("Berat maksimum bagasi adalah",x,"kg")
print(y < x)
|
c4e9be09ecad5509b8fc4cfd1289acc7943ce67c | Freeha-S/problemset | /primes.py | 1,341 | 4.375 | 4 | #asks the user to input a positive integer and tells the user
#whether or not the number is a prime.
##Please enter a positive integer: 19
#That is a prime.
def prime(num):
if num <= 1: #if number is 0 and 1 its not prime so return the messaage ont prime
return "not a Prime Number"
j= 2 # set a varia... |
c1a7bdb90d3f648496c48ffe792722497d51a55d | CederGroupHub/smol | /smol/moca/sublattice.py | 8,230 | 3.953125 | 4 | """Implementation of Sublattice class.
A sublattice represents a set of sites in a supercell that all have
the same domain/site space. More rigourously it represents a substructure
of the random structure supercell being sampled in a Monte Carlo
simulation.
"""
__author__ = "Luis Barroso-Luque, Fengyu Xie"
import it... |
28b7a945c666f2b94bb01ad10f94011b71d424ee | EmSanchezM/WebCrawler | /autograder.py | 1,974 | 3.546875 | 4 | grade = 100
def end_and_print_grade():
print('='*79)
if grade == 100:
print('¡Felicidades no se detectó ningún error!')
print('Su nota asignada es: NOTA<<{0}>>'.format(grade if grade >= 0 else 0))
exit()
def print_error_and_exception(error, exception):
print(error)
print("La excepcion recibida fue: \n... |
ec7afd1390d77f7b18cfe53bb0f5e8f1513036df | harryto/.dotfiles | /bin/colors.py | 346 | 3.625 | 4 | #!/usr/bin/python
def print_format_table():
"""
Prints table of formatted text format options
"""
for style in range(8):
for fg in range(30,38):
s1=''
for bg in range(40, 48):
frmat = ';'.join([str(style), str(fg), str(bg)])
s1 += '\x1b[%sm %s \x1b[0m' % (frmat, frmat)
print(s1)
print('\n... |
3d8e595ac8e586865e0fb1a5cc4cc68bce747077 | Sephfire05/LPTHW | /ex8.py | 525 | 3.515625 | 4 | # String with placeholders
formatter = "{} {} {} {}"
# Put these in the placeholders of formatter
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, False, True))
# This puts those 4 {} 4 times so 16 {}
print(formatter.format(formatter, format... |
ec16db6f60f4f59975f2056fc59278824f8ccad2 | Sephfire05/LPTHW | /ex4.py | 760 | 3.984375 | 4 | #Int
cars = 100
#Floating point number
space_in_a_car = 4.0
#int
drivers = 30
#int
passengers = 90
#This variable is a function 100 - 30 = 70
cars_not_driven = cars - drivers
#int = 30
cars_driven = drivers
#Function = 30 * 4.0 = 120.0 floating point number
carpool_capacity = cars_driven * space_in_a_car
#function = 90... |
2d4d9377c7df33c436c1867e8c0355a35abec9e4 | Sephfire05/LPTHW | /ex20.py | 1,265 | 4.40625 | 4 | # Import argv module
from sys import argv
# These are the arguments
script, input_file = argv
# This prints the current file through .read command to f (passed argument)
def print_all(f):
# .read reada all like a text file
print(f.read())
# This rewinds the file? .seek puts the file in the indicated position
d... |
3b02a2bf09dbfdea21cd7ba6fd3d2051ceac0fcd | katelin-cherry/BIOE521 | /Lab05/python-d.py | 239 | 4 | 4 |
# "\d" - matches a digit, same as [0-9]
import re
string1 = "99 bottles of beer on the wall."
m_obj = re.search(r"(\d+)", string1)
if m_obj:
print m_obj.group(1), "is the first number in '" +\
string1 + "'" |
0f4c657da86d333fcb7cf80a592902690a4f2f8a | katelin-cherry/BIOE521 | /Lab05new/python-pipe.py | 253 | 4.5 | 4 | # "|" matches the preceding pattern element one or more times
#! /usr/bin/python
import re
string1 = "Hello, world."
if re.search(r"(Hello|Hi|Pogo)", string1):
print "At least one of Hello, Hi, or Pogo is " +\
"contained in " + string1
|
9e1f5a72813ccaa274246d8fc0455c1b21016f1c | katelin-cherry/BIOE521 | /Lab05new/python-b.py | 225 | 4.15625 | 4 | # "\b" - Matches a word boundary
#! /usr/bin/python
import re
string1 = "Hello World"
if re.search(r"llo\b", string1):
print "There is a word that ends with 'llo'"
else:
print "There are no words that end with 'llo'"
|
39fc43f8de0bf0f6ca4e401b87c1950c9876f5dd | forrestwaters/advent_of_code | /2020/01.py | 1,051 | 3.71875 | 4 | def part1(arr):
"""
Brute force - find 2 items in list that add together to be 2020
return the product of those 2 items
"""
for idx1 in range(0, len(arr)):
idx2 = idx1 + 1
if arr[idx1] > 2020:
# could there be negative #'s?
continue
while idx2 <= len(a... |
a9a684efb2659e27a3782c3344ee92bb85a4e8bc | kentsommer/4511W-FinalProject | /reversi.py | 16,154 | 3.96875 | 4 | # Reversi - base code: http://inventwithpython.com/reversi.py
## Author: Kent Sommer
### Notes:
## The code to display the game in terminal is from: http://inventwithpython.com/reversi.py
## All AI and alternative evaluation functions were writen by Kent Sommer.
## The following is a heavily modified version of ba... |
306f85bf737a72b6376e7f1b2cf7ae34760ca52b | kmohee/Blackjack | /blackjack.py | 1,938 | 3.578125 | 4 | import random
from utils import ace_checker
class Blackjack:
### Global variables
global cards
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
def __init__(self):
self.user_hand = [ace_checker(random.choice(cards), None) for i in range(2)]
self.computer_hand = [random.choice(card... |
45bcfe854696d3aa6baa6ce10cab41788bbbeca4 | shreyansh-agarwal/mtech_sem1 | /DSAD_assignment/graph.py | 1,490 | 3.859375 | 4 | friends_list = {
}
gupton = ('sharman', 'roy', 'kumar', 'ray')
ray = ('ray', 'goldberg', 'arun', 'gupton')
sharman = ('gupton', 'panth', 'jaim')
kumar = 'gupton'
panth = 'kumar'
roy = ('gupton', 'goldberg')
goldberg = ('roy', 'ray')
arun = ('jaim', 'ray')
goldi = ""
jaim = ('sharman', 'arun')
class Graph:
def... |
bdc0314026db07513e9318e9486c84375bb41c1a | potatoHVAC/leetcode_challenges | /algorithm/349.1_intersection_of_two_arrays.py | 3,215 | 4 | 4 | # Intersection of Two Arrays
# https://leetcode.com/problems/intersection-of-two-arrays/
# Completed 4/28/19
"""Approach
1. Create dictionary that holds list elements as key and counts of those elements as values
2. Create list of all elements in the second list that were stored in the dictionary.
"""
class Solution:... |
c80e517e5b7e3d687043d00f19423ddd63846c51 | potatoHVAC/leetcode_challenges | /algorithm/86.2_partition_list.py | 1,417 | 4.0625 | 4 | # Partition List
# https://leetcode.com/problems/partition-list/
# Completed 5/8/19
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
"""Approach
1. Create dummy linked lists to hold the lower values and the >= values
2. Create pointe... |
d77bcfebfe3cc21a490ba8738614650a08b9235f | potatoHVAC/leetcode_challenges | /algorithm/20.1_valid_parenthesis.py | 1,697 | 3.8125 | 4 | # Valid Parenthesis
# https://leetcode.com/problems/valid-parentheses/
# Completed 5/12/19
"""Approach
1. Use regex to replace all () [] {} sets with empty strings and save to
a new variable.
2. If new length == old length then check completion.
2.1 Return True if new length == 0
2.2 Return False if new length... |
9725600f825d586e78dfca4da635ad41e1e80cde | potatoHVAC/leetcode_challenges | /algorithm/30.1_substring_with_concatenation_of_all_words.py | 3,836 | 3.875 | 4 | #-------------------------------------------------------------------------------
# Substring with Concatenation of All Words
#-------------------------------------------------------------------------------
# By Daniel Speer
# https://leetcode.com/problems/substring-with-concatenation-of-all-words/
# Completed 6/8/19... |
e3fe4f5327b6b194f860b3c916e47b53edca301f | potatoHVAC/leetcode_challenges | /algorithm/122.1_best_time_to_buy_and_sell_stock_ii.py | 2,251 | 3.8125 | 4 | #-------------------------------------------------------------------------------
# Best Time to Buy and Sell Stock
#-------------------------------------------------------------------------------
# By Daniel Speer
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
# Completed 6/13/19
#--------------... |
c46853b16222932c441c304c7f2ca5b29cb82118 | potatoHVAC/leetcode_challenges | /algorithm/207.1_course_schedule.py | 3,372 | 3.953125 | 4 | # Course Schedule
# https://leetcode.com/problems/course-schedule/
# Completed 4/26/19
''' Approach
1. Create a doubly linked graph.
2. Remove leaf nodes from tree and delete their references in parent nodes.
3. Repeat 2 until tree is empty or no more leaves exist.
4. Return True if tree is empty.
'''
class Node:
... |
f332fa7b235578da076dc25f60b8916485005dc6 | potatoHVAC/leetcode_challenges | /algorithm/235.1_lowest_common_ancestor.py | 3,334 | 4.125 | 4 | # Lowest Common Ancestor of a Binary Search Tree
# https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/
# Completed 5/2/19
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
''' Appr... |
48ce20482c3185a92004f35e1de253c4495eba92 | potatoHVAC/leetcode_challenges | /algorithm/912.1_sort_an_array.py | 981 | 4.09375 | 4 | # Sort an Array
# https://leetcode.com/problems/sort-an-array/
# Completed 4/25/19 With time out on large input test case
# Bubble Sort
"""Approach
1. Implement bubble sort
2. Itterate through array
2.1 if adjacent numbers are out of order, flip those numbers
3. If setp 2 is complete and a flip occured, repeat step... |
612aa6e40093bd8afefa49afd295a631218c3c20 | python-elective-fall-2019/Lesson-04-OOP-Basics | /code_from_today/inheritance.py | 639 | 3.71875 | 4 | # inheritance.py
class Person:
def __init__(self, name):
self.name = name
"""
class Student(Person):
def __init__(self, name, id):
super().__init__(name)
self.id = id
class Teacher(Person):
def __init__(self, name, skills):
Person.__init__(self, name)
self.skills ... |
309d6b84f77e4a49e4121701f54b6ea1c9116c55 | AndrewSigorskih/ROSALIND_problems | /Bioinformatics Stronghold/66_afrq.py | 275 | 3.53125 | 4 | from math import sqrt
def main():
with open("rosalind_afrq.txt", "r") as f:
A = list(map(float, f.readline().split()))
with open("out.txt", "w") as o:
print(*[f"{(2*sqrt(i)-i):.3f}" for i in A], sep=' ', file=o)
if __name__ == "__main__":
main() |
759347f81fd1746fe5fe0ef451d9830203efac9b | VISUJOHN/Pattern_Programs | /program31.py | 197 | 3.734375 | 4 | ''' sample output
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1 '''
n=int(input('Enter no of rows: '))
for i in range(1,n+1):
print(' '*(i-1),end='')
print((str(n-i+1)+' ')*(n-i+1))
|
473e027afcf85de18ffd6f5433f7daebb4883b93 | VISUJOHN/Pattern_Programs | /program57.py | 380 | 3.75 | 4 | ''' sample output
4
4 3
4 3 2
4 3 2 1
4 3 2 1 0
4 3 2 1
4 3 2
4 3
4 '''
n=int(input('Enter no of rows: '))
for i in range(1,n+1):
print(' '*(n-i),end='')
print(*[j for j in range(n-i,n)][::-1])
for i in range(1,n)[::-1]:
print(' ... |
f7f15864cf9c43c39a6839617d03209c184b3cfc | VISUJOHN/Pattern_Programs | /program51.py | 384 | 3.78125 | 4 | ''' sample output
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7
1 2 3 4 5
1 2 3
1 '''
n=int(input('Enter no of rows: '))
for i in range(1,n+1)[::-1]:
print(' '*(n-i),end='')
print(*[j for j in range(1,i+1)],*[j for j in range(i+1,2*i)])
'''for i in range(1,n+1):
print(' '*(n-i),end='')
print(*[... |
46006ca5dada52291ff00f06ca86043c7a0f0f0d | VISUJOHN/Pattern_Programs | /program40.py | 210 | 3.71875 | 4 | '''
1
3 2 1
5 4 3 2 1
7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1 '''
n=int(input('Enter no of rows: '))
for i in range(1,n+1):
print(' '*(n-i),end='')
print(*[x for x in range(1,2*i)[::-1]])
|
df0014917d733780bd50a486c3361dc1aa66c4a2 | VISUJOHN/Pattern_Programs | /program32.py | 205 | 3.84375 | 4 | ''' sample output
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1 '''
n=int(input('Enter no of rows: '))
for i in range(1,n+1):
print(' '*(i-1),end='')
print(*[j for j in range(1,n-i+2)])
|
c9f64cc7ceeb36aafbda9d8b282c14139308657d | ISURobotics/Computer-Vision-Workshop-2018 | /FilteringExample_NNIntro.py | 1,284 | 4 | 4 | import cv2
import numpy as np
"""
This is just a demo script describing what filters are and how they act on an image.
Filters are, in a sense, the basis of all neural networks.
Another word for a filter is a kernel.
"""
#Initialize our webcam and get a single frame
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
... |
ea16fba4d9157e61003d144dc13089d5a39a5f70 | mestre204os/Python-Curso_em_video | /LIções/001.py | 389 | 3.6875 | 4 | casa = float(input('Qual é o valor da casa? '))
salario = float(input('Quanto você recebe por mês? '))
tempo = int(input('Em quanto anos você pretende pagar? '))
valor_mensal = casa / tempo
salario_minimo = salario * 30 / 100
if valor_mensal > salario_minimo:
print('O contrato não pode ser firmado.')
else:
... |
713f810dd7315ca934d5841e521f0ac7fd37f526 | HarrisonHall/trace_camp | /day1/if_else.py | 234 | 4.1875 | 4 | #!/bin/python3
N = int(input())
if (N % 2 != 0):
print("Weird")
else: # Therefore even
if N in range(2,7):
print("Not Weird")
if N in range(6,21):
print("Weird")
if N > 20:
print("Not Weird")
|
aa68931998af531df9fa624edda294853386f7f5 | YaXiaoYX/ROBOT | /quadratureencoder.py | 892 | 3.765625 | 4 | class QuadratureEncoder(object):
"""
A simple quadrature encoder class
Note - this class does not determine direction
"""
def __init__(self, pin_a, pin_b):
self._value = 0
encoder_a = DigitalInputDevice(pin_a)
encoder_a.when_activated = self._increment
en... |
8d94081f729d766d5fc551dfdc1da694ffb210e5 | suhanibhargava/FDSP2019 | /Day02/panagram.py | 344 | 4.375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 8 17:21:06 2019
@author: Dell
"""
string = input("Enter string: ")
alpha = "abcdefghijklmnopqrstuvwxyz"
ispanagram = True
for word in alpha:
if word not in string.lower():
ispanagram = False
if ispanagram:
print ("PANAGRAM")
else:
print ("NOT... |
e0585420bbbca7790e65d5028606121039a3dc60 | suhanibhargava/FDSP2019 | /Day06/pallindromic2.py | 241 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 13 10:27:13 2019
@author: Dell
"""
inp = input().split(' ')
if all(int(x)>0 for x in inp) and any(x==reversed(x) for x in inp ):
print("True")
else:
print("False")
|
b334942a2feaf984a5c025378e7bca96f65911d5 | suhanibhargava/FDSP2019 | /Day03/duplicate.py | 211 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 9 23:32:01 2019
@author: Dell
"""
l = [12,24,35,24,88,120,155,88,120,155]
s = set()
for item in l:
if item not in s:
s.add(item)
s=list(s)
print(s)
|
9b00d8f9013ff0d06f222f0e9e5f8b1072cc8497 | suhanibhargava/FDSP2019 | /Day04/copy.py | 300 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 10 10:53:11 2019
@author: Dell
"""
with open("c1file1.txt","rt") as file:
file_contents=file.read()
file2 = input("Enter name of the file in which you want to copy contents: ")
with open(file2,"wt") as file:
file.write(file_contents)
|
f6ebbdc2f83063858fa53258bb8dbd3e0660d82a | suhanibhargava/FDSP2019 | /Day05/regex1.py | 311 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat May 11 16:01:06 2019
@author: Dell
"""
import re
while True:
inp = input("Enter a string")
if not inp:
break
else:
if re.match(r'^[+-]?\d*\.\d+$',inp):
print("True")
else:
print("False")
|
400d1de607f96b87653482e6074cec6c54604d40 | suhanibhargava/FDSP2019 | /Day03/frequency.py | 289 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 9 13:04:00 2019
@author: Dell
"""
inp = input()
d= dict()
for item in inp:
if item not in d.keys():
d[item]=1
else:
d[item]+=1
for key,values in d.items():
print(key,values)
|
5e2a17fbdb6bb1b9e4fc5d8ee7ca08e4c8ca92ed | lnhote/leetcode | /148_sort_list.py | 1,936 | 4.09375 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def sortList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
p1 = head
p2 = head
prev = N... |
114c6829ec7d96aece8ec1ff92bab7662a0cc27f | lnhote/leetcode | /128_longest_consecutive_sequence.py | 1,039 | 3.921875 | 4 | class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
stack = []
if len(s) == 0:
return False
for i in range(0, len(s)):
if s[i] in ['(','[', '{']:
stack.append(s[i])
els... |
73e94d60b33137020f9245d979ed44bbcef48b01 | lnhote/leetcode | /23_merge_k_sorted_list.py | 1,262 | 4 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def mergeKLists(self, lists):
"""
:type lists: List[ListNode]
:rtype: ListNode
"""
from Queue import PriorityQueue
... |
5c8f1cbdeefb18cb4a343a5df092dedfb6b65b7e | lnhote/leetcode | /139_word_break.py | 931 | 3.640625 | 4 | class Solution(object):
def wordBreak(self, s, wordDict):
dp = [False for i in range(0, len(s))]
for i in range(0, len(s)):
for word in wordDict:
if len(word)-1 > i:
continue
if s[i-len(word)+1:i+1] != word:
if dp[i]... |
088db4c85570217855737b8f0fccba5efb2a3518 | mazayus/ProjectEuler | /problem028.py | 253 | 3.578125 | 4 | #!/usr/bin/env python3
def spiral_corners(size):
yield 1
num = 1
sidelen = 3
while sidelen <= size:
for _ in range(4):
num += sidelen - 1
yield num
sidelen += 2
print(sum(spiral_corners(1001)))
|
22ed8d1e70244560475f5a14bfda1c01d1eee61f | mazayus/ProjectEuler | /problem018.py | 802 | 3.671875 | 4 | #!/usr/bin/env python3
from functools import *
triangle = """
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 4... |
96c33665ce66802c9632f8a1f4db62fc844d1d7c | mazayus/ProjectEuler | /problem019.py | 860 | 4.03125 | 4 | #!/usr/bin/env python3
from itertools import *
def dates(year, month, day):
def is_leap_year(year):
return (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0)
def days_per_month(year, month):
if month == 2:
return 29 if is_leap_year(year) else 28
elif month in [4, 6,... |
5ac9662294a7450e54512f60f9c3d10fb2f87331 | hincaltopcuoglu/algorithms | /algorithms5/main.py | 470 | 3.671875 | 4 | def minx(nums):
number = nums[0]
for i in range(1,len(nums)):
if nums[i]<=number:
number = nums[i]
else:
number
return number
def sort():
f = open("input", 'r')
nums = f.readlines()
nums = [int(i) for i in nums]
mylist = []
for i in range(len(num... |
2ee8f33b1f22748cdd40e496ec01b1384d24310b | kraime/Otus_Homeworks | /OOP/src/Figure.py | 3,422 | 3.9375 | 4 | import math
class Figure:
def __init__(self, name, angles):
self.name = name
self.angles = angles
def add_area(self, any_figure):
if Figure not in any_figure.__class__.__bases__:
raise TypeError('Hey! Ты передал не класс Figure')
return self.area + any_figure.area... |
8eb67fecbd793af654be036dd902e278159ad73a | Javissk8/ejercicios-python | /juego1.py | 774 | 3.734375 | 4 | import random
veces = [0]
numero = random.randint(1,100)
print(numero)
num = 1
actual = 0
prev = 0
i = 0
while num >= 1 and num <= 100 and i < 1:
print("adivina el numero")
num = int(input())
if num != numero:
veces.append(num)
actual = numero - num
if abs(actual) <= 10:
print("warm!")
elif abs(actual)... |
eba876432d42b2ed061beada1d21e7267f00fed1 | lidebao513/Python | /untitled2/day1/frmatTest.py | 468 | 3.90625 | 4 | #! /usr/bin/env python
#-*-coding:utf-8-*-
#author:xiaobao
name = 'xiaobao'
age =30
addres ='shanghai'
print('my name is %s ,age is %s come from %s'%(name,age,addres))
#format
print('my name is {0} ,age is {1} come from {2}'.format(name,age,addres))
# 不建议使用
print('my name is {:s}, age is {:d},come from {:s}'.format... |
40cec42f7b56f328568ad61afa96f9622aa64aea | Srijan-dixit/Leet-Code | /paranthesis_lc.py | 508 | 3.640625 | 4 | class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
if len(s)%2!=0:
return False
top="#"
start=[]
map_={")":"(","]":"[","}":"{"}
for i in s:
if i in map_:
if start... |
c92c98912ec241872165f5462588b4cec032deb6 | gasparRuben01/TeoriaAlgoritmos1 | /TP2/Problema de la mochila/Test_Knapsack.py | 2,773 | 3.78125 | 4 | #!/usr/bin/env python
from Knapsack import *
import sys
import time
class Objeto:
def __init__(self, key, value, weigth, x):
self.key=key
self.value=value
self.weigth=weigth
self.x=x
def get_key(self):
return self.key
def get_value(self):
return self.value
def get_weigth(self):
return self.weigth
d... |
8398df3b43f44fe8b47e03d545b1bfef40ef58de | AntonSergeqich/GeekHttps | /ls4_dz7.py | 1,242 | 3.71875 | 4 | # Реализовать генератор с помощью функции с ключевым словом yield, создающим очередное значение.
# При вызове функции должен создаваться объект-генератор.
# Функция должна вызываться следующим образом: for el in fibo_gen().
# Функция отвечает за получение факториала числа, а в цикле необходимо выводить только первые 15... |
920f144f04fa593d2f5b441d1a386a02b6e94af9 | AntonSergeqich/GeekHttps | /Less8/ls8_dz1.py | 2,532 | 3.640625 | 4 | # Реализовать класс «Дата», функция-конструктор которого должна принимать дату в виде строки формата «день-месяц-год».
# В рамках класса реализовать два метода. Первый, с декоратором @classmethod, должен извлекать число, месяц, год и
# преобразовывать их тип к типу «Число». Второй, с декоратором @staticmethod, должен п... |
82016c264c0e18e7950c76e2f62c6fa2575dd827 | AntonSergeqich/GeekHttps | /ls4_dz6.py | 991 | 3.96875 | 4 | # Реализовать два небольших скрипта:
# а) бесконечный итератор, генерирующий целые числа, начиная с указанного,
# б) бесконечный итератор, повторяющий элементы некоторого списка, определенного заранее.
# Подсказка: использовать функцию count() и cycle() модуля itertools.
from itertools import count, cycle
"""
Не увере... |
6c5840252464917db0471bfb528dfb0a8bf876af | CodedQuen/The-Python-3-Standard-Library | /Ch03/03_06/03_06_Start.py | 310 | 3.515625 | 4 | # Tempfile Module
import tempfile
# Create a temporary file
tempFile = tempfile.TemporaryFile()
# Write to a temporary file
tempFile.write(b"Save this special number for me: 456879")
tempFile.seek(0)
# Read the temporary file
print(tempFile.read())
# Close the temporary file
tempFile.close() |
e86f0b0bf2cfce343d12ad317cd9babea3b9f997 | CodedQuen/The-Python-3-Standard-Library | /Ch04/04_03/04_03_Finish.py | 484 | 3.53125 | 4 | # Calendar Module
from datetime import datetime, timedelta
import calendar
now = datetime.now()
testDate = now + timedelta(days=2)
myFirstLinkedInCourse = now - timedelta(weeks=3)
print(testDate.date())
print(myFirstLinkedInCourse.date())
if testDate > myFirstLinkedInCourse:
print("Comparison works... |
bb3f3d62b35b7872dc9c95daabb73089656761df | CodedQuen/The-Python-3-Standard-Library | /Ch04/04_04/04_04_Start.py | 231 | 3.796875 | 4 | # Create a Timer with the Time module
import time
run = input("Start? >")
seconds = 0
if run=="yes":
while seconds != 10:
print(">", seconds)
time.sleep(1)
seconds +=1
print(">",seconds)
|
a78a03dcc6d275b61f295313630ca6fdbc1d8e6b | CodedQuen/The-Python-3-Standard-Library | /Ch04/04_06/04_06_Finish.py | 774 | 3.5 | 4 | # Text Wrap Module
import textwrap
websiteText = """ Learning can happen anywhere with our apps on your computer,
mobile device, and TV, featuring enhanced navigation and faster streaming
for anytime learning. Limitless learning, limitless possibilities."""
print("No Dedent:")
print(textwrap.fill(websiteTex... |
6c6277db29895dbc2b76f956c14ae5eebf42e458 | CodedQuen/The-Python-3-Standard-Library | /Ch01/01_01/01_01_Start.py | 789 | 4.3125 | 4 | # Python Logical Operators: And, Or, Not:
# What is a Boolean?
isRaining = True
isSunny = True
# Logical Operators -> Special Operators for Booleans
# AND
# true and true --> true
# false and true --> false
# true and false --> false
# false and false --> false
if isRaining and isSunny:
print("We m... |
e7edd2073f0e87c71b0d5f5b51523e3856e40fcc | obnoxious-consequnence/Exercises | /Michael/Exercism/python/word-count/word_count.py | 204 | 3.828125 | 4 | import re
from collections import Counter
def word_count(phrase):
words = re.split(r"'?\s+'?|[_,!&@$%^.:]+", phrase)
counter = Counter((word.lower() for word in words if word))
return counter |
18355903722cf18638c076287971fa920cf91448 | jjmalloy79/MyPythonCode | /exam4/Exam4.py | 1,603 | 4.4375 | 4 | #Exam 4: This program will ask user for a word that they want to find in different files,
#it will print out the name of the file the word was found in and the line it was in.
# import section
import os
import Epic
#this gets a list of all files in dir and places into a string called files
files = os.listdir(".")
#t... |
f84eb347b863eee471c5ba04165ad0f29dc403e3 | jjmalloy79/MyPythonCode | /others/birdCount.py | 2,466 | 3.78125 | 4 | # ------------------------------------------------------------
# For a badge do the following:
#
# After each user query print out the bird that has been seen
# most often. If there is a tie, print all of birds that are
# tied for most sightings.
#
# Allow the user to enter a bird name as often as the like.
# When t... |
19fed97ac63f3627c11a91b807598fe34c3271a7 | jjmalloy79/MyPythonCode | /others/exam.py | 3,279 | 3.96875 | 4 | # ------------------------------------------------------
# reads the speeds in the specified file (filename)
# and returns them as a list of integers
# ------------------------------------------------------
def readData(filename):
file = open(filename, 'r')
dataInfo = []
for line in file:
data = lin... |
4092531803f48874bdd15182ed01938564630053 | resvirsky/Python | /Chapter 10 - Python in a day.py | 414 | 3.8125 | 4 | somevalue= 10
def adicao (x,y):
addition = x+y
return addition
print adicao (3,5)
print somevalue
def subtraction (x,y,z):
resultado = x-y+z
return resultado
print subtraction (3,5,17)
def multiplicacao (a,b,c):
resultado = (a*b)**c
return resultado
print multiplicacao (5,3,2)
def divi... |
c5c54a006a21b3ccae2b496f9956b7340f437db7 | resvirsky/Python | /Tutorial Item 41.py | 326 | 4 | 4 | print("Let's see how long have you liver in days, minutes and seconds")
name = input("name: ")
print("now enter your age")
age = int(input("age: "))
days = age*365
minutes = age*365*24*60
seconds = age*365*24*60*60
print (name, "has been alive for", days, "days", minutes, "minutes and", seconds, "seconds! Wow!")
... |
aa62a66b94bb3d75942d5c9195cfa80e08da74a1 | leilaadel/DojoAssignments | /Python/scoresandgrades.py | 581 | 4.125 | 4 |
def scoregrade():
import random
import math
print "Scores and Grades"
for i in range(1, 10):
randnum = (random.randint(1,100))
#print randnum
if randnum >= 90:
print "Score:"+str(randnum)+"; Your Grade is A"
elif randnum >= 80:
print "S... |
4315262fe97890b89fc2efa899b5e8f1258f71e2 | bhagyakjain/debaised-analysis | /intents/util/time_window.py | 2,201 | 3.609375 | 4 | """
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distrib... |
bcf93b6492a904a4bd04e8e5f034c6e19f32e283 | yamato1992/at_coder | /abc/abc152/b.py | 121 | 3.578125 | 4 | a, b = input().split()
res_a = a * int(b)
res_b = b * int(a)
if res_a > res_b:
print(res_b)
else:
print(res_a)
|
236c4fc16bad77a02e80d11a7ffdb9b480ef1f16 | yamato1992/at_coder | /abc/abc144/b.py | 216 | 3.84375 | 4 | def check():
n = int(input())
if n <= 9:
return 'Yes'
elif n > 81:
return 'No'
else:
for i in range(2, 9):
if n % i == 0 and n / i <= 9:
return 'Yes'
return 'No'
print(check())
|
3a3e1c69e44b19413ef31e2e70b10456c6dbe105 | yamato1992/at_coder | /virtual_contest/yorukatsu_contest#45/a.py | 224 | 3.71875 | 4 | n = int(input())
maximums = [0, 0]
nums = [int(input()) for _ in range(n)]
maximums = sorted(nums, reverse=True)[:2]
for num in nums:
if num == maximums[0]:
print(maximums[1])
else:
print(maximums[0]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.