blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
e90e9082d05fd53377313a5d66246b1ee86d26de | HareshNasit/LeetCode | /Linked_List/sort_list.py | 509 | 3.734375 | 4 | def sortList(self, head):
"""
https://leetcode.com/problems/sort-list/
:type head: ListNode
:rtype: ListNode
"""
#Brute Force Time complexity O(nlogn)
curr = head
nodes = []
while curr:
nodes.append(curr.val)
curr = curr.nex... |
9573731d1731c75418a6720d4c29ca17b3d36e73 | GeekYuliana/Python_MachineLearning | /CONV_CSV_XML.py | 561 | 3.5 | 4 | import pandas as pd
df = pd.read_csv('untitled.txt', sep='|')
def convert_row(row):
return """<movietitle="%s">
<type>%s</type>
<format>%s</format>
<year>%s</year>
<rating>%s</rating>
<stars>%s</stars>
<description>%s</description>
</movie>""" % (
row.Title, row.Type, row.Format, row.Yea... |
3b648c7456f15769d7ed2c9c7b6ad5bb538802f3 | kdave12/Machine-Learning-Algorithms | /ID3 Decision Trees/decisionTree.py | 12,750 | 3.5 | 4 | ''' This program implements a Decision Tree learner.
This file learns a decision tree with a specified maximum depth,
prints the decision tree in a specified format, predicts the labels
and calculates the training and testing errors.
Krishna Dave (kdave)
'''
from __future__ import print_function
i... |
7c169cedf367e7b2aceb2b078ddc226938f6a35f | anunay-kumar/python-datastructure | /find_prime_numbers.py | 493 | 4.1875 | 4 | """
Find all the prime number between two numbers
"""
i=1
j=int(float(input('Finding prime number between 1 and <limit> provided by you, enter limit: ')))
for num in range(i,j):
prime=True
#print('num is',num)
for divisor in range(2,num):
#print('divisor is',divisor)
if num%divisor == 0:
... |
5e7cc8bb723eda4b3920463f176719cf7e82f7c6 | anunay-kumar/python-datastructure | /find_perfect_sqrt.py | 449 | 4.15625 | 4 | import math,sys
print("Find the perfect squareroot of a number")
a = abs(int(float(input('Enter the number for which want to find the perfect square root: '))))
i=1
square = False
while i <= math.sqrt(a):
if i*i == a:
print('Found perfect square root of {} which is {}'.format(a,i))
square = True
... |
f29be0e001f252c171d5859d1a5d19887524e867 | zhupiggy/alien_invasion | /alien.py | 1,148 | 3.5 | 4 | import pygame
from pygame.sprite import Sprite
class Alien(Sprite):
"""表示单个外星人的类"""
def __init__(self, gui_setting, screen):
"""外星人:初始化、位置确定"""
super().__init__()
self.screen = screen
self.gui_setting = gui_setting
# 加载外星人,设置其rect属性
self.image = pygame.image.l... |
b5aa738992a3cb23b587f910e49f7e0ebf027553 | DarkTyr/python_work | /python_sphinx_examples/Python_for_the_Lab/my_module/people.py | 1,447 | 4.40625 | 4 | # -*- coding: utf-8 -*-
'''
Module people
=============
Defines two classes, Pearson and Teacher.
'''
class Person:
'''Class to store a general persons information. For example the name.'''
def __init__(self, name):
'''Create a person object by providing a name.
For example:
... |
b2f8a0f379c0a9c1745e5a783ef3274488e8f91e | Aarijit/css605_2012 | /David Masad/RPS Round 2/player.py | 775 | 3.78125 | 4 | """
This class implements a very stupid simple player for the RPS game
"""
import constants as c
import random
class Player(object):
def __init__(self, id="noID"):
self.myScore=0
self.score_history=[]
self.move_history=[]
self.id=id
def getID():
return self.id
def go(self):
return c.ROCK
def res... |
87d48354b54f582ad05e8784e3992129439cc872 | Aarijit/css605_2012 | /Terrie Franks/Rock-Paper-Scissors/player.py | 6,259 | 3.859375 | 4 | '''
This file contains the various player methods. Read chapters 14-27 of Learning Python to try iterators, how to test,
and printing strings.
'''
import constants as c
import random
import shelve
from random import randint
from time import sleep
class Player(object):
def __init__(self, id="noID"):
... |
c0358007ba593381654a2c2637cd812ab8e87635 | Aarijit/css605_2012 | /Craig Brown/RPS/player.py | 2,433 | 3.640625 | 4 | '''
Craig Brown
CSS 605
Fall 2012
Rock, Paper, Scissors
Player Class
'''
import constants as c
import random
class Player(object):
def __init__(self, id="noID"):
self.myScore=0
self.score_history=[]
self.move_history=[]
def getID():
return self.id
... |
77726a56097186e3aa7ed4abc386efebc41b68e1 | Aarijit/css605_2012 | /Jose Manuel PERU/ds_tuples.py | 1,208 | 3.828125 | 4 | '''
Created on Sep 13, 2012
PRACTICING some functionality of Tuples in Python!!
@author: josemagallanes
'''
#!/CSS 605 - Object OSS/github/css605_2012/Jose Manuel PERU
# Filename: ds_tuples.py
import myfunctions
supplyList = ['Book on Python', 'Memory stick', 'Pencils', 'Chewing Gum', 'Mobile','Ipad','Backpack'] # My... |
cd74b13b46c9ff157374379dda818cd5e350edd4 | arlin13/LearningPython | /LearningPython/yield.py | 759 | 4.15625 | 4 | """
YIELD
Used to pass/return (yield) value to caller function with every iteration
"""
def read_file():
try:
file = open("yield.txt", "r")
# for line in file.readlines():
# for line in read_line(file):
for line in read_proper_nouns_line(file):
print(line)
file.... |
33fe45635c1cd75876002a1f6e9d3899190c108c | arlin13/LearningPython | /LearningPython/booleans.py | 982 | 3.984375 | 4 | # Python booleans
python_course = True
java_course = False
print(python_course)
print()
# True is 1
print("Is this a python course?")
if python_course == 1:
print(int(python_course))
else:
if python_course == 0:
# False is 0
print(int(python_course))
print("Is this a python course?")
if pyt... |
2635fbffeec718c2b42ad9acb89f43c3a4ef2823 | arlin13/LearningPython | /LearningPython/functions.py | 1,589 | 4.09375 | 4 | """
FUNCTIONS
"""
print("I'm being printed by a function!")
# def imprimir(text):
# print(text)
# def imprimir(text):
# for t in text:
# print(t)
# imprimir("I'm being printed by a custom function")
# Returning a value
print()
students = []
def print_students_total():
print(f"Total of stud... |
a1adfb17645b47c32c0fec0fa5d8232fb7f60633 | github19970909/python1902 | /day9/my_var.py | 806 | 3.65625 | 4 | if 1==1:
print("1==1")
else:
print("1!=1")
print("this is"
"and with"
"thuhusdf"
"sdsfafd")
var = ["1,2","3,4","5,6"]
print(var)
a1=a2=a3=a4=a5=1
sum = a1+a2\
+a3+\
a4\
+a5+\
a1+\
a2+\
a3
print(sum)
var = "this is one\nthis is two\nthis is three\""
ss = ""... |
b2ff64b07d240e5f63a592c3846928e6f97c3b1a | HayesCapers/The-Guessing-Game | /guess_the_number_redo.py | 1,522 | 4.0625 | 4 | import random
random_number = random.randint(1, 10)
number_of_guesses = 6
go_again = True
restart_game = False
print "I am thinking of a number between 1 and 10."
while (go_again == True) and (number_of_guesses > 1):
guess_input = raw_input("What's the number? ")
if (int(guess_input) > random_number):
print "Nope... |
2a688f24e2a44635220acedbc3097c5586dffdbe | saki45/CodingTest | /py/CLRS1_9/rearrangeNode.py | 511 | 3.6875 | 4 | from ListNodeDef import ListNode
n1 = ListNode(1)
n2 = ListNode(2)
n3 = ListNode(3)
n4 = ListNode(4)
n1.nextNode = n2
n2.nextNode = n3
n3.nextNode = n4
n1.printList()
def rearrangeNode(head):
pa = head
pb = head.nextNode
while pb.nextNode != None:
pb = pb.nextNode.nextNode
pa = pa.nextNode
pb = pa.nextNod... |
60f8d9ed6e61b414ed538d2e7bc29dcda5130461 | saki45/CodingTest | /py/backtrack/knight.py | 691 | 3.515625 | 4 |
def knightPath(board, xMove, yMove, cx, cy, count):
print(cx, cy, count)
board[cx][cy] = count
if count == 64:
for row in board:
print(row)
return
for i in range(0,8):
nextX = cx + xMove[i]
nextY = cy + yMove[i]
if 0 <= nextX <= 7 and 0 <= nextY <= 7 and board[nextX][nextY] == 0:
knightPath(board... |
9393e97ff6185ce42e089917131f1391926bf47a | saki45/CodingTest | /py/backtrack/selection.py | 385 | 3.765625 | 4 | def selection(n):
# this method print all the possible selection of number 1 to n
if n<=0:
return
res = []
selectionrecur(res, 1, n)
def selectionrecur(res, cur, n):
if cur == n:
res.append(n)
print(res)
res.pop()
print(res)
return
res.append(cur)
selectionrecur(res, cur+1, n)
res.pop()
selectio... |
3b8a7cfa981ecf3fc400c25c9f069bd4d743b691 | saki45/CodingTest | /py/math/findfactor357.py | 1,131 | 3.96875 | 4 | def findfactor(N):
# this method will print the first N numbers containing only factors of 3, 5 or 7
# create three queues, the first one (Q3) only contains numbers with factors only 3, the second queue (Q5)
# contains numbers with factors 3 and 5. The last queue (Q7) contains numbers with factors 3, 5, 7
from col... |
8712f09fff73eea54746fe7f50097ea6a2d1695e | PerJNilsson/FFR120_Project | /prey.py | 13,056 | 4 | 4 | from animal import Animal
from numpy.random import rand
import random
import numpy as np
import math
class Prey(Animal):
maxHunger = 500# The maximum amount of food the prey can store.
maxRestTime = 20 # The amount of turns a prey have to rest after having eaten a plant.
maxExplorationTime = 200 # NOT SUR... |
df540a16227e62e2fd9a0908ef2d3d483adfc410 | Astreyns/Programming | /RPG_game.py | 2,967 | 3.75 | 4 | # make a game where you fight people and you have stats
# Agility 1 = 10% dodge chance
# Make game attack monster
# TODO: Rethink attack mechanic
import random
class Monster:
def __init__(self):
self.agility = random.randrange(0, 2) # Increased chance to dodge 0% - 30%
self.attack = random.randr... |
1b58a83b7117efd94d4cd245dd4fa84f912690f4 | sharu4innovation/algorithms | /tictactoe.py | 1,771 | 3.9375 | 4 | import numpy as np
def setup():
arr = np.array([['' for i in range(0,3)] for j in range(0,3)])
return arr
def check_input(arr,x,y):
try:
arr[x,y]
except:
print("Enter the right coordinates!")
return False
if arr[x,y] == '':
pass
else:
prin... |
1998f4606d68519f293d5d40cc15cb2c147debe4 | peacount/AutomatetheBoringStuff | /25. Repetition in Regex Patterns and Greedy Nongreedy Matching.py | 2,577 | 3.828125 | 4 | import re
# ? (zero or one)
batRegex = re.compile(r'Bat(wo)?man')
mo = batRegex.search('The Adventures of Batman')
print(mo.group())
mo = batRegex.search('The Adventures of Batwoman')
print(mo.group())
mo = batRegex.search('The Adventures of Batwowowowoman')
print(mo)
phoneRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d... |
2f77c3588b0e9ee0c7795e7e0f6e13f0c4700587 | mutalip/interviewbit-coding-ninja | /03String/RomanToInteger.py | 1,220 | 4.1875 | 4 | # Roman To Integer
# Asked in:
# Amazon
# Facebook
# Microsoft
# Twitter
# Given a string A representing a roman numeral.
# Convert A into integer.
# A is guaranteed to be within the range from 1 to 3999.
# NOTE: Read more
# details about roman numerals at Roman Numeric System
# Input Format
# The only argument... |
b4109942101ef07a14ac837d88915ee14402fdc3 | mutalip/interviewbit-coding-ninja | /03String/ImplementStrStr.py | 1,221 | 4.15625 | 4 | # Implement StrStr
# Asked in:
# Facebook
# Amazon
# Qualcomm
# Wipro
# Microsoft
# Please Note:
# Another question which belongs to the category of questions which are intentionally stated vaguely.
# Expectation is that you will ask for correct clarification or you will state your assumptions before you start coding... |
a006f537a6254e19173269260fda32877d9ead60 | mutalip/interviewbit-coding-ninja | /03BinarySearch/RotateArray.py | 1,244 | 3.921875 | 4 | # Rotated Array
# Asked in:
# Facebook
# Suppose a sorted array A is rotated at some pivot unknown to you beforehand.
# (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
# Find the minimum element.
# The array will not contain duplicates.
# NOTE 1: Also think about the case when there are duplicates. Does your cu... |
47647bc736e6106746e7d83226d78843e5e82ce6 | mutalip/interviewbit-coding-ninja | /02Arrays/RotateMatrix.py | 1,426 | 4.0625 | 4 | # You are given an n x n 2D matrix representing an image.
# Rotate the image by 90 degrees (clockwise).
# You need to do this in place.
# Note that if you end up using an additional array, you will only receive partial score.
# Example:
# If the array is
# [
# [1, 2],
# [3, 4]
# ]
# Then the rotated array... |
703cc8debb7ca63c76905f2417a2676d4a91b504 | mutalip/interviewbit-coding-ninja | /03BinarySearch/SquareRootofInteger.py | 1,364 | 4.03125 | 4 | # Square Root of Integer
# Asked in:
# Facebook
# Amazon
# Microsoft
# Given an integar A.
# Compute and return the square root of A.
# If A is not a perfect square, return floor(sqrt(A)).
# DO NOT USE SQRT FUNCTION FROM STANDARD LIBRARY
# Input Format
# The first and only argument given is the integer A.
# Ou... |
a48ca47e23f4cb12e2e272db7ad5da50cd64bad1 | tonyyfeng/comp110-21f-workspace | /exercises 4/ex04/utils.py | 1,043 | 3.9375 | 4 | """List utility functions."""
__author__ = "730410711"
# TODO: Implement your functions here.
def all(search: list[int], specific_number: int) -> bool:
i: int = 0
length: int = len(search)
while i < length:
if search[i] == specific_number:
i += 1
else:
return Fals... |
512fdd3bafc9016bf961e1cbd5dd7e9c6b763ec7 | tonyyfeng/comp110-21f-workspace | /exercises/ex03/happy_trees.py | 446 | 3.609375 | 4 | """Drawing forests in a loop."""
__author__ = "730410711"
# The string constant for the pine tree emoji
TREE: str = '\U0001F332'
depth: int = int(input("Depth: "))
forest: str = ""
counter_one: int = 0
counter_two: int = 0
while counter_one < depth:
counter_one = counter_one + 1
forest = ""
counter_two =... |
4ffb2aca01501be422de256277c6ec54fe49cdd8 | tonyyfeng/comp110-21f-workspace | /exercises/ex03/find_duplicates.py | 470 | 3.78125 | 4 | """Finding duplicate letters in a word."""
__author__ = "730410711"
word: str = input("Enter a word: ")
counter_one: int = 0
counter_two: int = 0
duplicate: bool = False
while counter_one < len(word):
counter_two = counter_one
while counter_two < len(word) - 1:
counter_two = counter_two + 1
i... |
9e3f33c65f5b5cb0eaa2107633c7420535c5898c | Liorinco/MyTests | /testDefaultListArgument.py | 1,819 | 4.125 | 4 | # -*- coding: utf8 -*-
class PartLoloTestBad(object):
""" Part of the class LoloTestBad """
def __init__(self, var_test=None):
self.var_test = var_test
def __str__(self):
return str(self.__dict__)
def __repr__(self):
return str(self.__dict__)
class LoloTestBad(object):
... |
b68a3f2c1f7b7e391550d9596298e41228cbf3a0 | jacobosterholt/CIS-322 | /export/export.py | 3,763 | 3.75 | 4 | import csv
import psycopg2
import sys
conn = None
cursor = None
def create_csv(directory, name, header, list):
"""Writes the csv file.
inputs: directory: string for the target directory for the csv
name: string for the name of the csv file
header: list of column names
... |
c764f78518725c92a1d71ebd8bfca68a3f844d7c | verma-shivani/DSA-Library | /Algorithms/Searching/Jump_Search/jump_search.py | 946 | 3.9375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import math
def jumpSearch(lst, x):
# Get The Jump Value
jump = math.sqrt(len(lst))
currentPart = 0
# Get Which Part Of The Jumps x is
while lst[int(min(jump, len(lst)) - 1)] < x:
currentPart = jump
jump += math.sqrt(len(lst))
... |
e1fe13cabb7eb2a1f06a671f4ccbf085c52dd6fa | verma-shivani/DSA-Library | /Data_Structures/Array/Largest_Sum_Contiguous_Subarray/LSCA.py | 534 | 4.0625 | 4 | # Problem Link: https://leetcode.com/problems/maximum-subarray/
'''
Function to find the maximum sum of any contiguous subarray
Function Arguments: nums (the input array)
Return Type: maximum sum
'''
def maxSubArray(nums):
if len(nums)==0:
return None
cur_max = nums[0] # maximum sum so far
... |
364acd5a1e84d716f0b4b5a5701e8b95b5514a53 | verma-shivani/DSA-Library | /Project_Euler/21-Amicable_Numbers/Amicable_Numbers.py | 559 | 3.65625 | 4 | def sum_divisors(n):
# return the sum of proper divisors of n
res = 1
for i in range(2,1+int(n**0.5)):
if n%i==0:
res+=i
if n!=i*i: # if proper square, just add once
res+=int(n/i)
return res
sum_of_divisors = [0]*10000 # store sum of di... |
c38885b67ba5ea45e2231940d4deeb2220fa84f4 | IGuessThisIsMyLife/project2-graphs | /part_1.py | 5,670 | 3.75 | 4 | #Jonathan Nunes
#CS 435
#Project 2
import random
class Graph:
def __init__(self):
"""Graph Constructor"""
self.nodes = []
self.adjacency = []
def addNode(self, node):
"""Adds a new node to the graph"""
self.nodes.append(node)
self.adjacency.append([node])
... |
bce89688249bc401e077d226e5bcc4be6404b37a | Mick-tz/PolynomialPDEs | /DTM.py | 6,262 | 3.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 2 21:41:40 2018
This implementation of the differential transform method (DTM) is thought to comply
with the following problem:
A company must reduce prices by 10%. Profit will be modelled as the charge
y minus a penalty P(t,dotY) (where d... |
bf98c018e1ba343b0f41711aae2fac59069bf6fc | Gungoguma/PoDo_Logic | /파이썬/11721.py | 129 | 3.796875 | 4 | string = input()
for i in range(len(string)):
print(string[i], end="")
if (i + 1) % 10 == 0:
print("\n", end="") |
0bcee9d22498a0e4f7ee7ecd7fb2be2eb6211b2f | VanPhuongNguyen/Practicals | /prac_04/quick_pick.py | 455 | 3.78125 | 4 | from random import randint
quick_pick_lines = int(input('How many quick picks? '))
for i in range(quick_pick_lines):
one_line = []
for j in range(6):
number_to_append = randint(1, 45)
while number_to_append in one_line:
number_to_append = randint(1, 45)
one_line.append(numb... |
7382ad917d396a36a721bb9bf03fa8dbf99f6069 | marinabar/guessthenumbergame | /jeunombre.py | 358 | 3.859375 | 4 | import random
n = random.randint(0,50)
on = ""
while True:
number = input("Try to guess the number I chose between 0 and 50 ")
number = int(number)
if number == n:
on = "Right"
print(on)
break
elif number < n :
on = "More"
print(on)
else :
... |
b0d511df3f1112dd141ad70c8e5f20f26116abca | ThreeFDDI/ATBS | /ATBS-8_regex.py | 552 | 3.59375 | 4 | #!/usr/local/bin/python3
import os, re
# set path to be searched
path = "/Users/JT/JTGIT/ATBS/ATBS-8_regex_dir"
# list files in directory
files = os.listdir(path)
# loop through files
for file in files:
# find .txt files
if ".txt" in file:
# open and read file
with open(path + "/" + file) a... |
c45c764ef93b1c4858cf079d45612eb9f637927d | ThreeFDDI/ATBS | /ATBS-7.py | 3,084 | 4.375 | 4 | #!/usr/local/bin/python3
# Chapter 7 - Regular expressions
import re
# Pattern Matching with Regular Expressions
phoneNumRegex = re.compile(r"\d{3}-\d{3}-\d{4}")
mo = phoneNumRegex.search("My number is 415-555-4242. Your number is 415-555-5858")
print("Regex match: " + mo.group())
# Grouping with Parentheses
phoneN... |
b45e35175993144267e8c30c6c83813fb2f5784b | ThreeFDDI/ATBS | /ATBS-6_bullet-points.py | 431 | 3.78125 | 4 | #!/usr/local/bin/python3
# ATBS-6_bullet-points.py will add bullet points to text in the clipboard
import pyperclip
# take in text from the clipboard
text = pyperclip.paste()
# split text by newline
text = text.split("\n")
# prepend each line with a bullet point
for i in range(len(text)):
text[i] = "* " + tex... |
412dc01394d9665483ba8323fc563e0995f158d1 | 98ayush/tathastu_week_of_code | /day2/program1.py | 746 | 4.125 | 4 | def odd__even(n):
if(n%2==0):
print("even number")
else:
print("odd number")
def prime(n):
c=1
for i in range(2,n):
if(n%i==0):
c=0
break
if(c==0):
print("not a prime number ")
else:
print("number is prime")
def palindrome... |
dab74701948b3f8f126e2e23a4190b278f3d1505 | 98ayush/tathastu_week_of_code | /day3/prog3.py | 72 | 3.546875 | 4 | s=input()
s1=''
for i in s:
if i not in s1:
s1+=i
print(s1)
|
437be85c5bea9f7fd09b2e3bd147d6bab8d9ac11 | mariogonzserr/Data-Structures-and-Algorithms- | /guess_the-number.py | 727 | 3.9375 | 4 | import random
def guess_my_number(total_tries, start_range, end_range):
if start_range>end_range:
start_range, end_range=end_range,start_range
random_number=random.randint(start_range, end_range)
success_message=("Congratulations")
failure_message=("Wrong, theres no more tries")
miss... |
f5fb9203c19ab4bd5153fe6e87892cd2e8386299 | peanutsee/Data-Structures-and-Algorithms-Python | /Sorting Algorithms (DONE)/Bubble Sort (DONE)/bubble_sort_revision.py | 241 | 3.84375 | 4 | def bubble_sort(lst):
for i in range(len(lst)):
for j in range(len(lst) - 1 - i):
if lst[j] > lst[j + 1]:
lst[j], lst[j + 1] = lst[j + 1], lst[j]
return lst
print(bubble_sort([1,4,2,5,8,19,7,4]))
|
c6cf4934bf297b3d197ef2e726efcbe57df8ebb3 | peanutsee/Data-Structures-and-Algorithms-Python | /Data Structures (DONE)/Linked List/Single Linked List (DONE)/Single Linked List.py | 3,543 | 4.09375 | 4 | '''
Linear Data Structure: Linked List
1. Singly Linked List (Implement this first)
2. Doubly Linked List
3. Circular Linked List
Elements in the Linked List are linked using pointers, each node has a data value and a pointer that points to the next value.
'''
class Node():
def __init__(self, data_value... |
e1cc922bdd7930babec6f4db80256e44716f7b17 | weichune/selenium7th | /day1/ZhuceTest.py | 614 | 3.609375 | 4 | #实现注册功能的自动化
from selenium import webdriver
#打开浏览器
driver=webdriver.Chrome()
#打开商城首页
driver.get("http://localhost/")
#打开注册页
driver.get("http://localhost/index.php?m=user&c=public&a=reg")
driver.find_element_by_name("username").send_keys("weichune1")
driver.find_element_by_name("password").send_keys("123qwe")
driver.find... |
7540bf0c7a101ac7e32696be06bbc36a8bfe921e | Tyyagoo/lang-workshop | /coursera/py_1/week_7/exercises/imprime_retangulo_cheio.py | 160 | 4.03125 | 4 | n = int(input("digite a largura: "))
m = int(input("digite a altura: "))
for i in range(0, m):
for j in range(0, n):
print("#", end="")
print() |
a6dc5e052e2ab6f667e0a7bfef40b75badb26402 | Tyyagoo/lang-workshop | /coursera/py_1/week_3/0_exercises/buzz.py | 90 | 3.828125 | 4 | n = int(input("Insira um numero: "))
if n % 5 == 0:
print("Buzz")
else:
print(n)
|
e83aafc46cc692720827a2d310c0ae80fd35f9f3 | Tyyagoo/lang-workshop | /coursera/py_2/week_5/exercises/bubble_sort.py | 360 | 3.984375 | 4 |
def bubble_sort(lista):
end = len(lista) - 1
for i in range(end, -1, -1):
swapped = False
for j in range(0, i):
if lista[j] > lista[j + 1]:
swapped = True
lista[j + 1], lista[j] = lista[j], lista[j + 1]
print(lista)
if not swap... |
0e9be659543a1d9449b52b8bed69504cc9eb9cb1 | Tyyagoo/lang-workshop | /coursera/py_2/week_5/exercises/busca_binaria.py | 324 | 3.6875 | 4 | def busca(lista, elemento):
first = 0
last = len(lista) - 1
while first <= last:
mid = (first + last) // 2
print(mid)
if lista[mid] == elemento:
return mid
if elemento < lista[mid]:
last = mid - 1
else:
first = mid + 1
return Fa... |
504c543141af362947c8fbc3322d93fbd545ede8 | vishal446/MyFpython | /Area_of_triangle.py | 346 | 3.890625 | 4 | _a_side=int(input("Enter value of side a:"))
_b_side=int(input("Enter value of side b:"))
_c_side=int(input("Enter value of side c:"))
_Semi_parimeter=(_a_side+_b_side+_c_side)/2
_Area_of_Triangle=(_Semi_parimeter*(_Semi_parimeter-_a_side)*(_Semi_parimeter-_b_side)*(_Semi_parimeter-_c_side))**0.5
print("Area of Triangl... |
b96a96e1cef13755443a250a4ebc46087b4cb074 | atomandspace/firstpygui | /hello_gui.py | 1,144 | 3.953125 | 4 | # import everything from Tkinter
from Tkinter import *
# create a class "Application"
class Application(Frame):
# response when say_hi function is called upon
def say_hi(self):
print "Hello world!"
# create Widegets
def createWidgets(self):
# create QUIT Button
self.QUIT = Butt... |
aab3bb8e563e90bd5a72eb8283cd57a5262060b8 | caro-oviedo/LearningPython | /restaurant.py | 1,431 | 3.90625 | 4 | class Restaurant():
def __init__(self, name, cuisine_type):
self.name = name.title()
self.cuisine_type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
"""Prints restaurant's information. """
print("Restaurant name: " + self.name.title())
print("Type of cuisine: " +... |
2d8844d939f315960f2b4ae53a1ab100c307eb56 | geleazar1000111/eventbrite-potato | /scrape.py | 3,976 | 3.546875 | 4 | import datetime
import json
import operator
import requests
from bs4 import BeautifulSoup
# Custom date formatting from:
# https://stackoverflow.com/questions/5891555/display-the-date-like-may-5th-using-pythons-strftime
def suffix(d):
return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th')... |
a92ff8f7a1532a117beffa2f9418f0fc246038ad | jaystaks/Politico | /test/v1/models/test_office_model.py | 1,003 | 3.6875 | 4 | """
Tests for Office Model
"""
from unittest import TestCase
from app.api.v1.models.office import PoliticalOffice
class TestOfficeModel(TestCase):
"""
TestOfficeModel class
"""
def test_political_office_create(self):
"""
Test that PoliticalOffice Model Creates Political Offices
"""
political... |
6dc384fca1462ab9c39fe1d4046949a758cdd2e6 | BrassMic/Nauka | /Konwerter.py | 456 | 3.734375 | 4 | # do przerobienia kod z kalkulatora
def Euro(x, y):
return x * y
def Dulary(x, z):
return x * z
y = 4.26
z = 3.88
print("Waluty:")
print('1.Euro')
print('2.Dulary')
choice = input("Wybierz walutę (1/2):")
num1 = float(input("Kwota:"))
if choice == "1":
print(num1, "*", y, "=", Euro(num1, y))
elif choi... |
bfe7a0d5965001a07ff2a35ceeb527c175832c21 | GlobalNOC/routeflow-bgp-analysis | /bgp_report_source/bgp_report_source/get_urls.py | 4,055 | 3.53125 | 4 | '''
Input: Datetime range
Output: File named 'urlFile' which contains list of url's that we need to download
to compute the bgp stability information in the given time range.
Function: In Routeview archives, the bgp updates are stored every 15 minutes.
Given a range of year-mon-day-h-m-s, this program finds all the u... |
091f4014cd216eff57c4bda3a6b6cd6b1b2b344b | the-roth/HNAARGHBot | /commands/text_response.py | 973 | 3.671875 | 4 | '''
Created on Jun 22, 2017
@author: Rudy Laprade (penguin8r)
'''
from commands.command import Command
class TextResponse(Command):
'''
This is a basic text response command. When a user posts a command
(!{command name}), this will respond with a specified message and then
go on cooldown for 10 seconds by defult... |
bc528e13f717b00c3a8003c1d9f871e0c341c6da | the-roth/HNAARGHBot | /games/game.py | 10,777 | 3.546875 | 4 | """
Created on Jun 20, 2017
@author: Rudy Laprade (penguin8r) and the_roth
"""
import threading
import time
import re
from enum import Enum # install via pip install enum34
from commands.command import Command, SubCommand
DEFAULT_SIGNUP_TIME = 130
DEFAULT_PRINT_SPEED = 30
TIMER_COOLDOWN_DURATION = 60
Status = E... |
4371970da7d26c53e0900014804c0525cbc01b86 | olgaloboda/Python-MIT | /Week2/Week2_task1.py | 514 | 4.15625 | 4 | # Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month.
year = 12
while year >= 1:
monthlyInterestRate = annualInterestRate / 12.0
minMonthlyPaymentRate = monthlyPaymentRate * balance
monthlyUnpa... |
fe51ff977e99b0677ab2542b044edfbd094159d9 | nehatomar12/Data-structures-and-Algorithms | /Graph/graph.py | 2,015 | 4.15625 | 4 | def add_vertex(v):
global graph
if v in graph:
return("Vetex {} already exist!".format(v))
graph[v] = []
def add_edge(v1, v2, e):
global graph
if v1 in graph:
graph[v1].append((v2, e))
else:
graph[v1] = [(v2, e)]
def print_graph():
global graph
for vertex in g... |
9b3f0315e33cf60ba54f53ba4408d43eb2e2d430 | nehatomar12/Data-structures-and-Algorithms | /LinkedList/4.reverse_linkedlist.py | 1,502 | 3.78125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LL:
def __init__(self):
self.head = None
def empty(self):
if self.head is None:
return True
return False
def addLast(self, data):
newNode = Node(data)
if s... |
b0d1ab9952bea5b6918ae2f5a461865e965fc96e | nehatomar12/Data-structures-and-Algorithms | /LinkedList/6.intersection-point_ll.py | 2,582 | 3.921875 | 4 | """
Take two pointers for the heads of both the linked lists.
If one of them reaches the end earlier then use it by moving it to the beginning of the other list.
Once both of them go through reassigning they will be equidistance from the collision point.
"""
class Node:
def __init__(self, data):
self.data... |
e02449257aa84d29b204e0619b1cf153b1ef4ab6 | nehatomar12/Data-structures-and-Algorithms | /Strings/13.panagram.py | 1,002 | 4.3125 | 4 |
# Panagram: if sentence contain all 26 aplhabets
# Lipogram: if any letter is missing...etc
# Pangrammatic Lipogram: if it contain all letter except one letter
check_panagram = "The quick brown fox jumps over the lazy dog"
check_panagram = "The quick brown fox jumps over the dog"
def panagram_check(check_panagram)... |
1ab4746d8db631d1d69e9fe817bf638c073d2136 | nehatomar12/Data-structures-and-Algorithms | /Tree/print_all_paths.py | 1,283 | 4.1875 | 4 | import queue
class Node:
# Constructor to create a new node
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __repr__(self):
return str(self.data)
def levelOrder(root):
#Write your code here
q = queue.Queue()
q.put(root)
whil... |
42076d475bc283ec9bcb7f36bded66323cf841a7 | nehatomar12/Data-structures-and-Algorithms | /Strings/7.Permutations_of_string.py | 1,188 | 3.84375 | 4 | """
ABC
ABSG
Output:
ABC ACB BAC BCA CAB CBA
ABGS ABSG AGBS AGSB ASBG ASGB BAGS BASG BGAS BGSA BSAG BSGA
GABS GASB GBAS GBSA GSAB GSBA SABG SAGB SBAG SBGA SGAB SGBA
use backtracking
ABSG --> swap A with all other letters and first letter will be fixed
ABSG BASG SBAG GBSA --->... |
5e75bf72552f1fd7c66c0ff1b9a31d66d922e260 | nehatomar12/Data-structures-and-Algorithms | /Array/18.check-if-two-arrays-are-equal-or-not.py | 477 | 3.9375 | 4 | """
Given two arrays A and B of equal size, the task is to find if given arrays are equal or not.
output: 1 == equal, 0 == not equal
Steps:
create hash for array1
traverse array2 and check the values of hash calculated
"""
from collections import defaultdict
arr1 = [1, 2, 5, 4, 0]
arr2 = [2, 4, 5, 0, 1]
ans ... |
bca9f926cdac6998edb328ab93f6f74b924c7b91 | nehatomar12/Data-structures-and-Algorithms | /Trie/find-all-words-matching-pattern-dictionary.py | 1,467 | 4.15625 | 4 | """
Given a dictionary of words where each word follows a CamelCase notation,
find all words in the dictionary which match with the given
pattern consisting of all uppercase characters.
dict = [Hi, HiTech, HiTechCity, Hello, HelloWorld, HiTechLab]
* If the pattern is HT, the output is { HiTech, HiTechCity, HiTechLab... |
33bb7aa29264713da0a818054175e4c61d817e3e | nehatomar12/Data-structures-and-Algorithms | /Trie/trie_for_files_path.py | 1,019 | 3.734375 | 4 | class TrieNode:
def __init__(self):
self.key = None
self.children = {}
self.isLeaf = False
self.count = 0
def make_trie(root, path):
node = root
for _file in path.split("/"):
if _file not in node.children:
node.children[_file] = TrieNode()
no... |
509529c52384fc43195f7762e0c8d3843c537b48 | nehatomar12/Data-structures-and-Algorithms | /Tree/8.identical_tree.py | 1,701 | 3.703125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
def areIdentical_iterative(root1, root2):
if root1 is None and root2 is None:
return True
if root1 is None or root2 is None:
return False
return (root1.data==root2.data and areIdentica... |
7fcb383fa373848b7cc491ad04e13b98eaeb3b9e | nehatomar12/Data-structures-and-Algorithms | /Trie/Longest_common_prefix.py | 1,353 | 3.546875 | 4 | """
given = ["codable", "code", "coder" , "coding"]
o/p: "cod"
"""
class TrieNode:
def __init__(self, data):
self.data = data
self.children = {}
self.isleaf = False
def insert(root, data):
node = root
for char in data:
if char not in node.children:
node.childre... |
b2ac01121baa9dccd9e015a1434965c1e911de6b | nehatomar12/Data-structures-and-Algorithms | /LinkedList/13.add_two_no_ll.py | 3,625 | 3.828125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LL:
def __init__(self):
self.head = None
def empty(self):
if self.head is None:
return True
return False
def listprint(self):
trav = self.head
while trav i... |
0e9a2616f2e3dc3849a166a365a1352bb82413f1 | nehatomar12/Data-structures-and-Algorithms | /Tree/7.mirror_tree.py | 1,714 | 3.6875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
##
## mirror Tree
##
def areMirrors_iterative(root1,root2):
# inorder of root1 and
# reverse inorder of root2
st1 = []
st2 = []
while True:
while root1 and root2:
if root1.da... |
79fe7e76d8d1bcbbf52c7e64029c4656c5f3cf3f | nehatomar12/Data-structures-and-Algorithms | /Strings/strings/count_char_occurence.py | 451 | 4.28125 | 4 | def given_character_in_string(name="geeksforgeeks", char_to_count="g"):
#count the occurrence of a given character in a string
#create a map and return value of required character
hash = {}
for i in name:
hash[i] = hash.get(i,0) +1
if char_to_count in list(hash.keys()):
print("%... |
041f3f61144785bf59918ba67fea8c680cb129a0 | martyurb/OOAnalysis-Design | /src/classes/bag.py | 844 | 3.515625 | 4 | class Bag:
def __init__(self):
self.letters = [] # array of letters
def add(self, letters): # with rack
"""
Inherit letters from rack and add them to bag.
@param letters (list): Length of list must be between 1 and 7.
@return: Void
"""
... |
098d1a5009e044efdd9afd55b26956ca39ddc1c2 | willpakpoy/Year9IT-Task2 | /4-codebreaker/__main__.py | 3,497 | 4.15625 | 4 | '''md
© Will Pak Poy 2021
# Pseudocode
1. First up, we make a list of every character in the alphabet, plus a space at the end.
2. We then present the user with fields to enter their number string or letter string.
3. They then have the option to encode or decode their strings.
a. If they choose encode, the lett... |
f1eccb9638bd1ec8d07f16d7840dfee4dbb76315 | MaciekBielski/python101 | /3_flow_control.py | 1,230 | 3.71875 | 4 | #!/usr/bin/python3
import sys
print( '1.\t''for iterates over lists or strings')
a='simple string'
b=[11,22,33]
print( '\t',)
for i in a:
print(i,end='')
else:
print('')
print( '\t',)
for i in b:
print(i,end='')
else:
print('')
# iterating over a copy of a sequence for making modifications
# without a copy... |
ea24f07a608c812e07d9a936f57d182363712e81 | dmentipl/plonk | /src/plonk/utils/math.py | 2,157 | 3.96875 | 4 | """Utils for math."""
import numpy as np
from numpy import ndarray
from .._units import Quantity
def cross(x, y, **kwargs):
"""Cross product.
Parameters
----------
x, y
The two arrays (N, 3) to take the cross product of. Can be
ndarray or pint Quantity.
**kwargs
Keyword ... |
5633216a47811bf37f90731c55ed3b72d8f75ad5 | Krochi/Gitpro | /Less3.py | 2,619 | 3.890625 | 4 | #3.1 Реализовать функцию, принимающую два числа
def div(*args):
try:
a = int(input('Введите первое число:'))
b = int(input('Введите второе число:'))
rez = a/b
except ValueError:
return 'ValueError'
except ZeroDivisionError:
return 'На ноль делить нельзя!'
return r... |
1952ae4cfb15be6b0880b6fc6c774572916c30c0 | mrtitanic6/outschool_module1 | /module1.py | 694 | 4.0625 | 4 | name = "cat"
print(name + name + str(10))
number1=11
number2=4
print(number1**5 + number2**5)
print("hello " + name.upper())
color = "blue" #this is a variable for colors
print(color.upper())
print(color.lower())
print(color.title())
firstname = "Daniel"
lastname = "McHenry"
full_name = firstname + " " + la... |
21ac6836c1f82e2ae1b0571f55641a4a0cf5cb31 | dannykh/imdb_project | /prep/movie_vector/MovieVector.py | 2,101 | 3.796875 | 4 | class MovieVectorError(Exception):
def __init__(self, movie_id, msg):
self.message = "MovieVector <{}> : ".format(movie_id) + msg
import numpy as np
MISSING_FEAT = np.nan
class MovieVectorGenerator(object):
"""
An abstract movie vector generator. All generators should inherit this and
imple... |
1741d4555e3c70c29bc519808a44376d903c1ec6 | carlosrn98/Examen_XalDigital_Python | /ExamenXalDigital_Python.py | 3,312 | 3.65625 | 4 | #Examen XalDigital análisis de datos con Python
#Carlos de la Rosa
import requests
import pandas as pd
url = "https://api.stackexchange.com/2.2/search?order=desc&sort=activity&intitle=perl&site=stackoverflow"
#Se verifica que url al menos exista
try:
req = requests.get(url)
except:
print("ERROR: url no encontr... |
52b2fd228d56328252a1bcb94039c43e3837c040 | chitneedihemanth/py_codes | /get_pair_for_given_sum.py | 331 | 3.671875 | 4 | def get_pair_for_given_sum(arr,sum,length):
hashset=set()
for i in range(length):
pass
i=0
for i in range(length):
temp=sum-arr[i]
if temp in hashset:
print("{} {}".format(arr[i],temp))
hashset.add(arr[i])
arr=[2,4,45,6,10,8]
get_pair_for_given_sum(arr,1... |
ea2d3e5c7208a32a0ead37e8143cb415f76e9b34 | StokicDusan/EmirpPrimeCheck | /emirpPrimeCheck.py | 1,508 | 4.4375 | 4 | # Checks if the integer is an Emirp number or not.
# An emirp is a prime number that results in a
# different prime when its decimal digits are reversed.
from math import sqrt
from doctest import testmod
import sys
def is_prime(pp: int) -> bool:
if pp == 2 or pp == 3:
return True
elif p... |
af0ab842eac978afcfe1d472f34453dce68ad75d | linwiker/learpython | /python2/randint.py | 340 | 3.875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#猜字游戏
from random import randint
x = randint(0,300)
for count in range(50):
digit = input('please input a number:')
if digit == x:
print "Bingo"
break
elif digit > x:
print 'Too large,please try again:'
else:
print 'Too small... |
f068c724f5d44b45f98d33449cb3b045a0dd6458 | linwiker/learpython | /python3/Property.py | 1,016 | 3.71875 | 4 | #/usr/bin/env python
# -*- coding: utf-8 -*-
#源码级别解析property装饰器
class Property:
def __init__(self,fget=None,fset=None,fdel=None):
self.fget = fget
self.fset = fset
self.fdel = fdel
def __get__(self, instance, cls):
if self.fget is not None:
return self.fget(instance)
... |
d5ec5f5c1d8cb1cf0350fe0945d7e42094816d54 | linwiker/learpython | /python3/data structure/stack.py | 1,417 | 3.890625 | 4 | #/usr/bin/env python
# -*- coding: utf-8 -*-
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Stack: #定义栈,两个方法push和pop
def __init__(self):
self.top = None
def push(self, value): #入栈
node = Node(value)
node.next = self.top #结点的下一条既... |
28ed191f8c1862d801bd8b0d37920dacd9dcdbf3 | Pumpkin31415/dirforce | /dirforce.py | 852 | 4.0625 | 4 | import requests
#create a variable to store the url
url = input('Enter the url in https://www.example.com format : ')
#have the user specify the location of the file
fileLocation = input('Enter the location of the directories list : ')
#output what we are doing
print('Scanning ' + url)
r = requests.get(url)
#... |
b3839d729a92e218dfb130ad27429e21845605cf | egrepo7/python_oop | /OOP_animals/animal.py | 1,041 | 4.1875 | 4 | # Create an instance of the animal called 'animal' and have this animal walk three times, run twice, and have it display its health.
# Now, create another class called Dog that inherits everything that the Animal does and have, but 1) have the default health be 150 and 2) add a new method called pet, which when invoke... |
1e0a4b71091fc9dae4a327ee93edeeab535b6c97 | MalikQasimAli/EyeTracking_demo | /activities/SET B/567-code-python/ProgrammingActivities/DEBUG/DEBUG.py | 1,235 | 3.921875 | 4 |
# DEBUG
# Explanation:
# We want to know the price to buy:
# 1 cat
# 2 dogs
# 1 lion
# 2 wolves
# Assume the price of a cat is 10, dog = 20, lion = 100, wolf = 200.
# Fix the code below so the correct output is displayed.
# Expected output:
# Total was: 460
from enum import Enum
class Animal(Enum):
Cat = 1... |
d60cf8d5699db96adf54dbeb7c951e62cf2f8aaa | qwazzy1990/ladder | /src/CreateRoot.py | 1,570 | 4.125 | 4 |
def createRoot(Ladder, A, n):
if len(A)> 1:
# Finding the mid of the array
mid = len(A)//2
# Dividing the array elements
L = A[:mid]
# into 2 halves
R = A[mid:]
# Sorting the first half
createRoot(Ladder, L, n)
# Sorting the second... |
b5c674338a6e8b51d45f7f08bb2a5c942a1d3d73 | croggs/Sudoku | /create_sudokufield.py | 3,405 | 3.84375 | 4 | from random import shuffle
from random import randint
# ------------------------------------Hauptfunktionen-------------------------------------------
def valid_board(board,num):
for n in range(0, 81):
row = n // 9
column = n % 9
if board[row][column] == 0:
shuffle(num)
... |
f99610a72bebd596a8326c3582eaee3e12bab0c2 | fedor-goncharov/wrt-project | /ver-python/spectral-methods/spectral_laplace3d.py | 998 | 3.90625 | 4 | import numpy as np
"""
laplace3d.py
Function takes on input a three-dimensional image and returns its spectral
Laplace transform in 3D.
INPUT PARAMETERS :
u : matrix of size ngrid x ngrid x ngrid
ngrid : number of elements of one side of the matrix
period : length of the period of an i... |
2aa2ee8934c4425077515a49ffa7d37cb41802fe | omri30000/Trivia | /TriviaServer/Questions Script/script.py | 1,278 | 3.59375 | 4 | import sqlite3
import requests
import json
DB_ADDRESS = "../TriviaServer/OurDB.sqlite"
def connect_to_db(db):
conn = None
try:
conn = sqlite3.connect(db)
except Exception as e:
print(e)
return conn
def get_data_from_site(url):
data = requests.get(url)
data = data.text.rep... |
214ccd38b1e7e5de8674b235ca4bafddf1f199c2 | Shubh96/The-Python-Mega-Course-Udemy | /3. Iterate Loop.py | 117 | 4 | 4 | #Print list item if value is greater than 2
mylist = [1, 2, 3, 4, 5]
for i in mylist:
if i>2:
print(i)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.