blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
715df80224d4637c68ccf079bf8903df7c50206e | dasdachs/smart | /10/python/game.py | 867 | 4.125 | 4 | def main():
country_capital_dict = {"Slovenia": "Ljubljana", "Croatia": "Zagreb", "Austria": "Vienna"}
while True:
selected_country = country_capital_dict.keys()[0]
guess = raw_input("What is the capital of %s? " % selected_country)
check_guess(guess, selected_country, country_capital... |
c779658f93ddbdb80fb733f03b68d4a0db554847 | mahurangimike/user-info-v1 | /main.py | 64 | 3.671875 | 4 | name = input ("hello what is your name? ")
print ("hello", name) |
6f26257b43de17840edca561366bc1a58412bd21 | rkidwell2/Algorithms | /BSTree.py | 3,089 | 3.84375 | 4 | """BinarySearchTreeclass withmethods insert(E element),
remove(E element), contains(E element)
Write a test class for BinarySearchTreeas well."""
class Node(object):
def __init__(self, element):
self.element = element
self.left = None
self.right = None
class BSTree():
def ... |
3e6d7e4be0111adae03259bd19d23e6c83b00465 | volvalder/topological_shortest_path | /topological_shortest_path.py | 1,241 | 3.609375 | 4 | class Graph:
def __init__(self, vertices):
self.adjList = {}
self.q = []
for u,v,w in vertices:
self.addNodes([u,v])
self.addEdge(u, [w,u,v])
self.distTo = [float('inf') for v in range(len(self.adjList))]
self.edgeTo = [None] * len(self.adjList)
d... |
e6c32a1fc14d02bbf7534f982a9155d122039d5f | sedx876/100-Days-of-Code---The-Complete-Python-Pro-Bootcamp-for-2021 | /Day24/main.py | 776 | 3.734375 | 4 | # with open("my_file.txt") as file:
# contents = file.read()
# print(contents)
# with open("my_file.txt", mode="a") as file:
# file.write("\nHere is some new text")
#
# with open("new_file.txt", mode="w") as file:
# file.write("Some more text")
PLACEHOLDER = "[name]"
with open("./Input/Names/invite... |
55eb9729b92845e903bc14352d344bada73c3b92 | scottbelden/advent_of_code_2020 | /day_11.py | 6,107 | 3.546875 | 4 | from collections import Counter
from utils import answer1, answer2, get_input, debug
ANSWER1 = None
ANSWER2 = None
seats = get_input("day_11_input")
debug("Original")
for row in seats:
debug(row)
iteration = 0
while True:
debug("")
debug(f"{iteration=}")
new_seats = []
for y_index, row in enume... |
0c7dd1b4d6225f7aa76d2f17f842517224a57446 | scottbelden/advent_of_code_2020 | /utils.py | 793 | 3.59375 | 4 | DEBUG = False
def answer1(value):
print(f"Part 1 Answer: {value}")
return value
def answer2(value):
print(f"Part 2 Answer: {value}")
return value
def get_input(filename):
with open(filename) as fp:
return [line.strip() for line in fp]
def get_input_as_int(filename):
with open(fil... |
cf9642fb01018904f0835099441ce991d8c417a2 | piyushsri05/Context-Extraction | /ReviewsResult.py | 10,491 | 3.78125 | 4 | #inport libraries
import re
import math
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
#function to draw pie chart for accuracy
def drawPieChart(count):
labels = 'Whom', 'When', 'Where', 'Occasion' #the slices will be ordered and plotted counter-clockwise.
... |
c6dbfcd98c2629aef7f5e399454757c33aee417d | Devil104/html_css_bootstarp_javascript_python | /python2/class4.py | 277 | 3.625 | 4 | class pe():
def __init__(self,title,name,page):
self.title=title
self.name=name
self.page=page
def __str__(self):
return "title:{},name:{},page:{}".format(self.title,self.name,self.page)
x=pe("advancer","harry potter","300")
print(x)
|
d39171bc13c7ec18760d044c4190250a257e9c25 | OliviaFortuneUCD/pythonProject75 | /BeautifulSoup.py | 296 | 3.5 | 4 | from bs4 import BeautifulSoup
import requests
import pandas as pd
url = 'https://en.wikipedia.org/wiki/List_of_countries_by_greenhouse_gas_emissions'
req = requests.get(url)
print(req)
soup = BeautifulSoup(req.text,"html.parser")
soup.prettify()
#print(soup)
row1 = soup.find('tr')
print(row1) |
301a502c6119fbc704c61fea44aba50d63b1b5e0 | abehmiel/cosine_similarities | /vsm.py | 1,769 | 3.515625 | 4 | """
Accept a list of tweets and generate a tweet_cosine_similarities.csv
"""
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import linear_kernel
def find_relations(tweets, feature_extraction, tdm):
"""
Go through all the tweets and create a map fo... |
c4949bf6c500d45ecc8a6a1235f7db98e76ce12f | chaowyc/leetcode | /isAnagram.py | 329 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 18 22:40:41 2015
@author: Understand
"""
def isAnagram(s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
#return sorted(s) == sorted(t)
from collections import Counter
return Counter(s).items() == Counter(t).items()
print isAnagra... |
c98528e205021fdca222eba56e69404942704638 | iPedriNNz/Exercicios | /ex078.py | 405 | 3.765625 | 4 | num = []
cont = 0
for v in range(0, 5):
cont += 1
num.append(int(input(f'Digite um número para o posição {cont}: ')))
maior = max(num)
menor = min(num)
print(f'Você digitou os números {num}')
print(f'O maior número digitado foi {maior} e ele apareceu na {num.index(maior) + 1}ª posição')
print(f'O maior número d... |
f9866b572628445fbce24b4fa5673ca28deaa442 | iPedriNNz/Exercicios | /ex067.py | 543 | 4.09375 | 4 | while True:
print('-' * 20)
print('[Digite um número negativo para finalizar o programa]')
num = int(input('Quer ver a tabuada de qual valor ? '))
print('-' * 20)
if num < 0:
print('Fim do programa ! Obrigado e volte sempre !')
break
print(f'''
{num} x 1 = {num * 1}
{num} ... |
244caeca775b8de42eb502a37da16fed80f23796 | iPedriNNz/Exercicios | /ex022.py | 608 | 4.46875 | 4 | # Exercício Python 022: Crie um programa que leia o nome completo de uma pessoa e mostre:
# - O nome com todas as letras maiúsculas e minúsculas.
# - Quantas letras ao #odo (sem considerar espaços).
# - Quantas letras tem o primeiro nome.
name = str(input('Digite seu nome completo: '))
print('Seu nome com as letras min... |
dcd94ba9364d24db15b90fc74e422eb5c73b9967 | iPedriNNz/Exercicios | /ex015.py | 152 | 3.890625 | 4 | c = float(input('Informe a temperatura em ºC '))
f = float(c * 9 / 5) + 32
print('A temperatura de {:.1f}ºC corresponde a {:.1f}ºF ! '.format(c, f))
|
d3e103da86ff5e3bb9ceb372d31cbd7826d76a10 | iPedriNNz/Exercicios | /ex096.py | 230 | 3.59375 | 4 | def area(a, b):
area = a * b
print(f'A área do terreno de {a:}x{b} é de {area:.1f}m²')
print('CONTROLE DE TERRENOS')
largura = float(input('Largura (M): '))
altura = float(input('Altura (M): '))
area(largura, altura)
|
338e2b7085fa942cabb25a3b273814bf13faa1f7 | iPedriNNz/Exercicios | /ex019.py | 527 | 4.125 | 4 | # Exercício Python 019: Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que
# ajude ele, lendo o nome dos alunos e escrevendo na tela o nome do escolhido.
from random import choice
student1 = input('Nome do primeiro aluno ')
student2 = input('Nome do segundo aluno ')
student3... |
c1ff637ea498ce9174a72d99f280447e37f2d738 | iPedriNNz/Exercicios | /ex061.py | 179 | 3.90625 | 4 | termo = int(input('Primeiro termo: '))
razao = int(input('Razão da PA:'))
cont = 1
while cont <= 10:
cont += 1
print(termo, end=' → ')
termo += razao
print('FIM!')
|
ad6fb4595aeadbb1e5fd4c9b2cda5273d0f8df7f | iPedriNNz/Exercicios | /ex036.py | 783 | 4.3125 | 4 | # Exercício Python 036: Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa.
# Pergunte o valor da casa, o salário do comprador e em quantos anos ele vai pagar. A prestação mensal não pode exceder
# 30% do salário ou então o empréstimo será negado.
home = float(input('Qual o valor da casa: ... |
18bad236388573bb15347108587b7e29a98da2c5 | andrew-d/oisc | /assemble.py | 18,882 | 3.734375 | 4 | #!/usr/bin/env python
from __future__ import print_function
import re
import sys
import itertools
from numbers import Number
label_count = 0
def temp_label():
global label_count
label_count += 1
return "__tmp_%d" % (label_count,)
# --------------------------------------------------
class Instruction(... |
89008c8a1e7fdf3aa27d28bc134c09579fd0ccf9 | kumargovind2714/PythonProject | /excel_writing.py | 1,461 | 3.90625 | 4 |
'''
File Name : excel_writing.py
Author Name : Lakshmi Damodara
Date : 01/24/2018
Version : 1.0
Description :
This file is primarily to write the data to a csv file with comma delimiters
It accepts the name of the file with directory and list as an argument
Then it opens the file w... |
6f77cf0343ac00a6405fff203c6e6281c74b503a | sureshsinghbhandari/wairAvtomaciq | /appium-for-mac/examples/calculator.py | 1,316 | 3.75 | 4 | from selenium import webdriver
from random import randint
print 'Starting the WebDriver session'
driver = webdriver.Remote( command_executor='http://localhost:4622/wd/hub', desired_capabilities={'platform':'Mac'})
print 'Opening the "Calculator" app'
driver.get("Calculator")
print 'Selecting the 1st Window'
driver.s... |
19e77cd66664f13c25d23d660933d17b8c4f2beb | ballaneypranav/rosalind | /archive/bins.py | 787 | 3.75 | 4 | n = int(input())
m = int(input())
numbers = [int(x) for x in input().split()]
queries = [int(x) for x in input().split()]
# numbers = [10, 20, 30, 40, 50]
# queries = [40, 10, 35, 15, 40, 20]
def binary_search(array, query):
n = len(array)
if n == 0:
return -1
if n == 1:
if array[0] =... |
ff4f17017729a5569103bd6423d9bc33bfe2c582 | salomechemiat/ANN | /ANN.py | 5,009 | 3.859375 | 4 | import numpy as np
class NeuralNetwork():
def __init__(self):
# seeding for random number generation
np.random.seed(1)
#converting weights to a 3 by 1 matrix with values from -1 to 1 and mean of 0
self.synaptic_weights = 2 * np.random.random((3, 1)) - 1
d... |
de8ae962a9ce9d2688f5bddc29207c129828e899 | NBryant83/code-challenges | /count_positives_sum_negatives.py | 549 | 3.953125 | 4 | def count_positives_sum_negatives(arr):
#your code here
def count_positives_sum_negatives(arr):
sum = 0
count = 0
new_arr = []
for num in arr:
if num > 0:
# print("I'm great😊", num)
count += 1
elif num < 0:
sum += num
# if arr... |
1e57e31431826418c8ae1da645f64d3635f5e420 | magnuskonrad98/max_int | /FORRIT/python_verkefni/leika/testing2.py | 92 | 3.859375 | 4 | total = 0.00001
while 3 <= 5:
total = total+0.00001
print("The total is: ", total)
|
05e7f389e65814504c2c7fb679c56f8c5b34f269 | magnuskonrad98/max_int | /FORRIT/python_verkefni/byrjendanamskeid/verkefni_day_2/if_else_verkefni/if_else.py | 207 | 3.859375 | 4 | final_grade = input("Enter a grade: ")
final_grade = float(final_grade)
if final_grade > 4.5:
print("Well done")
if final_grade == 4.5:
print("lucky")
if final_grade < 4.5:
print("try again")
|
25d24f958ded0cb76bf094cb58798c7a90ed073e | magnuskonrad98/max_int | /FORRIT/python_verkefni/byrjendanamskeid/verkefni_day_2/while_verkefni/verkefni__04.py | 222 | 3.953125 | 4 | low = int(input("Enter low: "))
high = int(input("Enter high: "))
total = 0
while low <= high:
if low % 2 == 0:
total += low
low += 1
print("total sum: ", total)
print("low: ", low)
print("high: ", high) |
3200951b5317c881bf9c2fc22c5b91b216f86df3 | magnuskonrad98/max_int | /FORRIT/timaverkefni/22.08.19/dice.py | 378 | 3.828125 | 4 | d1 = int(input("Input first dice: ")) # Do not change this line
d2 = int(input("Input second dice: ")) # Do not change this line
# Fill in the missing code below
if not (d1 and d2 in range(1, 7)):
print("Invalid input")
else:
sum = d1 + d2
if sum in [7, 11]:
print("Winner")
elif sum in [2, 3, ... |
6ecbbd21bb3a7ff477c7223ae2ea8d2d820d8f7c | magnuskonrad98/max_int | /FORRIT/python_verkefni/byrjendanamskeid/verkefni_day_2/while_verkefni/verkefni__02.py | 217 | 4.21875 | 4 | low = int(input("Enter an integer: "))
high = int(input("Enter a higher integer: "))
while low <= high:
a = low % 2
if a!=0:
print(low)
low=low+2
else:
low=low+1
print("Done!") |
9515d46934654041e67c2c04f05fea00268a3097 | magnuskonrad98/max_int | /FORRIT/python_verkefni/byrjendanamskeid/verkefni_day_2/while_verkefni/verkefni__02_betra.py | 196 | 4.0625 | 4 | low = int(input("Enter low: "))
high = int(input("Enter high: "))
while low <= high:
if low % 2 != 0:
print(low)
low = low + 2
else:
low = low + 1
print("Done!")
|
a94f6da125dd57a91b57ae05673d022c73ac5c6e | magnuskonrad98/max_int | /FORRIT/python_verkefni/byrjendanamskeid/verkefni_day_1/verkefni_01.py | 108 | 3.640625 | 4 | number = input("Enter your number: ")
print("The answer to life, the universe, and everything is ", number) |
110028be423e920bf5226c6620dbe6e39ef4b620 | magnuskonrad98/max_int | /FORRIT/timaverkefni/29.08.19/first_n_odd_numbers.py | 89 | 4.03125 | 4 | num = int(input("Input an int: "))
x=1
for i in range(1, num+1):
print(x)
x += 2
|
7e4b9c3843c4251db490394b94d03f230ed962de | magnuskonrad98/max_int | /FORRIT/python_verkefni/leika/test.py | 141 | 3.71875 | 4 | a = int(input("enter a nuber: "))
if a > 60:
print(a)
elif a > 50:
print(a)
elif a > 40:
print("cool",a)
else:
print("wow")
|
135d55325ea9ff7c5257fd3c1ef03bca19a48fba | magnuskonrad98/max_int | /FORRIT/timaverkefni/aefing_fyrir_prof_1/4.4.py | 151 | 3.984375 | 4 |
a = int(input("Enter a num: "))
b = int(input("Enter a num: "))
for x in range (1, a):
if a % x == 0 and b % x == 0:
gcd = x
print(gcd) |
f1337838af3d2dafe14302b84ac07870d7409029 | magnuskonrad98/max_int | /FORRIT/timaverkefni/27.08.19/prime_number.py | 341 | 4.15625 | 4 | n = int(input("Input a natural number: ")) # Do not change this line
# Fill in the missing code below
divisor = 2
while divisor < n:
if n % divisor == 0:
prime = False
break
else:
divisor += 1
else:
prime = True
# Do not changes the lines below
if prime:
print("Prime")
else:
... |
8e153e7a94889b4ef1332639733e5d15b6ac5323 | magnuskonrad98/max_int | /FORRIT/python_verkefni/byrjendanamskeid/verkefni_day_2/for_loops_verkefni/verkefni_01.py | 88 | 4 | 4 | a = int(input("Enter an integer: "))
for number in range(a, -1, -1):
print(number)
|
a034a356238b33501ee10c8f0890b9eee849a15c | chao-yin/Function-Group-Detecting-Program | /Detect_C/Simple_INFO.py | 12,130 | 3.5 | 4 | import numpy as np
import sys
import os
class Single_Bond:
def __init__(self,NAtom,BO,IAn,ICoor): # Nomal_Bond is the number of bond that the initial atom aonnected with other, for instance, C is 4,O is 2
self.NAtom = NAtom
self.BO = BO
self.IAn = IAn
self... |
41afc3aa1242792e7c42b17a483717dbe199776a | yqy/zero_pronoun | /src/lib/tree_kernel.py | 8,842 | 3.5 | 4 | #coding=utf8
import parseTree
import nltk
import math
import sys
def get_tree_list(filename):
fin=file(filename)
lines=[line for line in fin]
fin.close()
sent_list=[]
for line in lines:
if line[0:11]=='<ParseTree>':
sent_list.append(line[11:].strip())
#print sent_list
treelist=[]
for s in ... |
fb1515550c3168c5d4dee7e1d996b0e50baff8eb | TedYav/CodingChallenges | /HackerRank/Challenges/Week Of Code 28/boat_trips.py | 301 | 3.625 | 4 | def run():
(n,c,m) = map(int, input().split())
passengers = list(map(int, input().split()))
print("Yes" if can_travel(c, m, passengers) else "No")
def can_travel(capacity, num_boats, passengers):
max_capacity = capacity * num_boats
return all(map(lambda p: p <= max_capacity, passengers))
run() |
0ac18624bb87ae2d3b2fdb7d4da981cb619ec3d0 | TedYav/CodingChallenges | /HackerRank/Algorithms/dp/two_robots.py | 5,472 | 3.984375 | 4 | """
TWO ROBOTS:
Given N queries, and two robots, determine minimum total distance that must be traversed.
Robots start at position of first query they take.
let F(i,x,y) = minimum distance necessary to process queries Q_i to Q_n-1, inclusive, with robots starting at postitions x and y respectivel... |
8fa2839f5c02e9c272f21e437caa8e2ab7f4f2c9 | TedYav/CodingChallenges | /Pramp/python/flatten_dict.py | 1,137 | 4.125 | 4 | """
Time Complexity: O(n) based on number of elements in dictionary
1. allocate empty dictionary to store result = {}
2. for each key in dictionary:
call add_to_output(key,value,result)
add_to_output(prefix,value,result)
- if value is dict:
for each key in dict, call add_... |
f3e8dbd5e5feac718d20c3b9a7ac0c6b5c98339f | TedYav/CodingChallenges | /leetcode/add_two_numbers.py | 3,860 | 3.9375 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
"""
Strategy:
Add digit by digit
Carry over one digit if needed after each addition.
Can add one list to another -- when list ends and carry is 0, then ret... |
a72274a379578c163ae8466302b55f46748a5036 | TedYav/CodingChallenges | /HackerRank/Algorithms/dp/longest_common_subseq.py | 982 | 3.734375 | 4 | """
LCS(A,B) is really asking:
LCS of A and B starting at index 0 in both
Thus, we can define F(i,j) as LCS(A,B) starting at A_i and B_j
F(i,j) = {
if i > n - 1 :: 0
if j > m - 1 :: 0
if A_i == B_j :: F(i+1,j+1) + 1
if A_i != B_j :: max(F(i+1,j), F(i,j+1))
}
"""
def run():
n,m = map(int, input().st... |
998697efe96797dc59a24144167d38fc65525f03 | TedYav/CodingChallenges | /HackerRank/Challenges/Week Of Code 28/the_great_xor.py | 229 | 3.609375 | 4 | def run():
q = int(input().strip())
for _ in range(q):
x = int(input().strip())
print(num_xors(x))
def num_xors(x):
pow = 0
num = 0
while x > 0:
if not x & 1:
num += 2 ** pow
x >>= 1
pow += 1
return num
run() |
3175ccf2d32b4a86e183d2b265a53bb468b04a1f | TedYav/CodingChallenges | /Pramp/python/islant_count.py | 928 | 3.71875 | 4 | """
0 1 0 2 0
0 0 2 * 2
3 0 0 2 0
0 5 # 0 0
4 0 5 0 6
Strategy:
* Go through row by row
* Explore each island, change to -1
* Increase island count the first time each one is encountered
m x n matrix.
O(m*n)
EXTENSION: Island Groups (connected by -1) and Average Per Group
... |
f0c83b2a204751dbf7afc0e069b3a52d80781f24 | TedYav/CodingChallenges | /Pramp/python/min_value_tree.py | 1,495 | 3.875 | 4 | """
Can you hear me? You went black
Try refreshing page :)
"""
"""
may be the connetion is weak
let me refresh
can you hear m?
tree root
left right key
"""
"""
x = 5, result = 1
5
1 7
x = 1, result = None
5
1 7
x = 4
looking for node with value 3
5
2 7
4
class Node:
val -> int
l... |
feafa465376b0fbe9dbca199ea0658fc74c40bc9 | TedYav/CodingChallenges | /Pramp/python/busiest_time.py | 2,112 | 3.90625 | 4 | """
Given an array of timestamps:
{ time: 1440084737, count: 4, type: "enter" }
Return timestamps: beginning to end
Brute Force -> Enumerate all seconds in last year, count number of people in each, return
Better Solution: Treat entering and exiting as delta values
E.G.
1: 4 ent... |
ab94ea08a8712665acce4f9cd40d6a673ed99036 | TedYav/CodingChallenges | /leetcode/linkedin/factor_combinations_wrong.py | 1,755 | 3.984375 | 4 | """
getFactors:
Step 1: generate all prime factors up to sqrt n
Step 2: iterate through prime factors. Each time we find one, store it as a base.
Add all the ways to make n / current_factor to the end of this number
Step 3: Repeat until we're out of factors.
ISSUES:
... |
9071d93e0cefd555d28fe33db27d32fa2aee5870 | TedYav/CodingChallenges | /Pramp/python/sudoku_solver.py | 2,918 | 4.0625 | 4 | """
- look for the first empty square
- if the board is full, we check for correctness
- look for viable candidates in square
- if none are found, we return false
- we pick one to fill, and make a recursive call
- we keep picking until we've tried all of them
- if none of them work we return false
"""
#... |
e59663bbf992b8695137bebf4a8030720d440a71 | belayneh-a/fenix-challange | /fenix_q1/question1_a.py | 3,003 | 3.5625 | 4 | import sys
'''
Fenix Full Stack Software Challenge:
For Question 1 (a,b)
'''
# Implementation of the solution is not only for the case of 4 arguments rather it works for N number of arguments
# In order to comply with the challenge default case of execution 3 should be chosen as No loans number(3 args + K)
... |
7ce27d581d8016ddf8786b6821b4ab047397ed5b | kde713/code-challenge | /google-foobar/02-1_dont_get_voluteered.py | 4,189 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Don't Get Volunteered!
======================
As a henchman on Commander Lambda's space station, you're expected to be resourceful, smart, and a quick thinker.
It's not easy building a doomsday device and capturing bunnies at the same time, after all! In order to make sure that
everyone w... |
05079dc89ec7c4a7626240190ca2f6965aa7f395 | athenanv/6034artificialintelligence | /lab8_Support Vectors/lab8.py | 5,307 | 3.734375 | 4 | # MIT 6.034 Lab 8: Support Vector Machines
# Written by 6.034 staff
from svm_data import *
from functools import reduce
# import matplotlib
#### Part 1: Vector Math #######################################################
def dot_product(u, v):
"""Computes the dot product of two vectors u and v, each represented ... |
1469223461416248bf84fb154fcf20ed76585c60 | athenanv/6034artificialintelligence | /lab0_testing_python_knowledge/lab0.py | 9,908 | 3.65625 | 4 | # MIT 6.034 Lab 0: Getting Started
# Written by jb16, jmn, dxh, and past 6.034 staff
from point_api import Point
#### Multiple Choice ###########################################################
# These are multiple choice questions. You answer by replacing
# the symbol 'None' with a letter (or True or False), corres... |
2707cd605c57ef06adc08857d40c0120d1b94f41 | ilae4e/Tools | /Encryption/Caesar.py | 683 | 3.59375 | 4 | __author__ = '13123035 - Jordan Harman'
import random
from string import letters
alphabet = letters[26:]
def encrypt(message, key):
encrypted_message = ""
for eachchar in message:
num = alphabet.find(eachchar.upper())
if num != -1:
num += alphabet.find(alphabet[key])
... |
0d890a36cebce9c9bb058c2cff8a06ab54eb82cc | ozMoreira/Python_Exercises | /CheckPoint1/Tarefa1_Exercicio2.py | 2,146 | 4.21875 | 4 | print("")
print("------------------------------------------------------------------------------------------------------------------")
print("| Este eh o exercicio 02 da Lista de CheckPoint #1, da disciplina de Computational Thinking do Curso de Analise |")
print("| e Desenvolvimento de Siste... |
32aae6c34471b69541a7c92bc261cf72df139be7 | ozMoreira/Python_Exercises | /Diversos/RepeticaoDivisores.py | 131 | 3.90625 | 4 | aux = input("Informe um numero")
num = int(aux)
div = 1
while div <= num:
if num % div ==0:
print(div)
div += 1
|
d65f38aa4d1a9715b7579bd9b6ac02b34bfa82c2 | ozMoreira/Python_Exercises | /CheckPoint1/Tarefa1_Exercicio3.py | 1,111 | 4.125 | 4 | import math
print("")
print("------------------------------------------------------------------------------------------------------------------")
print("| Este é o exercicio 01 da Lista de CheckPoint #1, da disciplina de Computational Thinking do Curso de Analise |")
print("| e Desenvolvime... |
d1883a3a3dce51aac5468f8ea46f3939a453864b | lucianopereira86/Python-Examples | /examples/collection.py | 908 | 3.859375 | 4 | # Simple list
names = ['Luciano', 'PEREIRA']
print('names = ' + str(names))
# Populating a list dynamically
numbers = []
numbers.append(1)
numbers.append(2)
print('numbers = {}'.format(numbers))
print('first number = {0}'.format(numbers[0]))
# Array with defined type ('d' = digits)
from array import array
grades = ar... |
b600abf744c3dbb8abbaa694f1df0516847b1cab | lucianopereira86/Python-Examples | /examples/error_handling.py | 661 | 4.15625 | 4 | # Division by zero
x = 1
y = 0
try:
print(x/y)
except ZeroDivisionError as e:
print('You must NOT divide by zero!!!')
finally:
print('This is a ZeroDivisionError test')
# Wrong type for parsing
a = 'abc'
try:
print(int(a))
except ValueError as e:
print('Your string cannot to be parsed to int')
fina... |
b85fd57a82d8cd32671f1f7c6cfe05659d182cf0 | mydopico/HackerRank-Python | /Introduction/division.py | 539 | 4.1875 | 4 | # Task
# Read two integers and print two lines. The first line should contain integer division, aa//bb. The second line should contain float division, aa/bb.
# You don't need to perform any rounding or formatting operations.
# Input Format
# The first line contains the first integer, aa. The second line contains the ... |
2a4cb83b49ceece938951553b52bfb8d504305bd | minotour4869/minesweeper | /client.py | 7,897 | 3.53125 | 4 | import random, pygame, os
SPRITE_SIZE = (25, 25)
class Piece():
def __init__(self, state=0):
self.state = state
self.revealed = False
self.flagged = False
class Board():
def __init__(self, size, mine, seed=None):
self.size = size
self.mine = mi... |
29ce07cfbb0c84442a92e1e199db4ba35eb11229 | ArjunPraveen/YeetCode | /Strings/longestPalindrome_5.py | 957 | 3.5625 | 4 | class Solution:
def checkCentres(self, s, l, r):
if l>r:
return 0
while (l>=0 and r<len(s) and s[l]==s[r]):
l-=1
r+=1
print(str(l) + " " + str(r))
return r-l-1
def longestPalindrome(self, s: str) -> str:
if s=="" o... |
da3b3161992eca568ee1b446ec3259743eb6c8f2 | Deeksha-Rawat/Hackerrank | /Python/No_Idea!.py | 1,251 | 3.796875 | 4 | ''' #There is an array of n integers. There are also 2 disjoint sets, A and B, each containing m integers. You like all the integers in set
# A and dislike all the integers in set B. Your initial happiness is 0. For each i integer in the array, if i is in A, you add 1 to your
# happiness. If i is in B, you add -1 to yo... |
1200607614b58afcd152426b225e240b76a82398 | Deeksha-Rawat/Hackerrank | /Problem_Solving/Python/filled_orders.py | 323 | 3.765625 | 4 | def filledOrders(order, k):
"""Method that resolve filled orders problem.
Usage: print(filledOrders([3, 2, 1], 3)) # Output: 2
"""
total = 0
for i, v in enumerate(sorted(order)):
if total + v <= k:
total += v
else:
return i
else:
return len(orde... |
df5d87577614832f48b1d8694614677deb4453e0 | sharmila4250/python-letsupgrade- | /day6ass1.py | 227 | 4.0625 | 4 | list1=[1,2,3,4,5,7,8]
list2=["a","b","c","d","e"]
res = {list1[i]: list2[i] for i in range(min(len(list1),len(list2)))}
print("First list is"+str(list1))
print("Second list is"+str(list2))
print("Combined list is"+str(res))
|
25472506548dfda11941ccc876964e8bec62ed6a | sharmila4250/python-letsupgrade- | /day7ass1.py | 335 | 3.734375 | 4 | port1={21:"FTP", 22:"SSH",23:"telnet",80:"http"}
print ("Original dictionary is : ")
print(port1)
port2={}
for k,v in port1.items():
if v in port2:
port2[v].append(k)
else:
port2[v]=[k]
print ("Dictionary after swapping is : ")
print("keys: values")
for i in port2:
print(i, ... |
95a01fb29f6fe738a88931eb2560ec75127ede81 | rubiconjk/python-sandbox | /dataorder.py | 1,162 | 3.625 | 4 | # This program will calcualte the number of sections of aerials and parcel
# data a customer is ordering (factoring in the data discount) and returns
# the appropriate charge.
print("\nGISMO Data Order Calculator v0.4")
print("Last modified: 9-19-2013\n\n")
numsections = int(raw_input("Enter number of sections... |
bcba3c8d25086416a544533abca072e2dff5088c | Matthew-cell/lesson2-HW | /PYTHON WEDNESDAY HW.py | 233 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jul 21 20:34:21 2021
@author: USER
"""
import random
x=random.randint(1,100)
z=int(input('guess a number'))
if x==z:
print:('right')
else:
print('wrong')
print(x) |
e6093bc0610203ec506d0b10e934bba9d49fe09e | vito-trianni/RandomWalksReloaded | /multi-agent-simulations/levy_f/distribution_functions.py | 2,983 | 3.859375 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: cdimidov
"""
import math
import numpy as np
import numpy.random as R
#define the uniform distribution
def uniform_distribution(a, b):
return a + (b-a) * R.rand()
#define the expponential distribution
def exponential_distribution(l):
u=uniform_distributi... |
c560c5500df289c562a501d1e6fbeea333779916 | lumosan/deeplearning2018 | /Projects/Project2/framework/activation_functions.py | 2,943 | 3.5 | 4 | # -*- coding: utf-8 -*-
import numpy as np
from torch import Tensor
from framework.modules import Module
class ReLU(Module):
"""Implements the Rectified Linear Unit activation layer"""
def forward(self, x):
"""Carries out the forward pass for backpropagation.
INPUT
x: input
... |
1f8e863c91ba1ce9b490b8d949297ae24842a034 | JuanmaMartin14/repaso | /repaso12.py | 292 | 3.515625 | 4 | peso_m=75
peso_p=112
munecas=float(input("ingrese la cant de munecas a comprar"))
payasos=float(input("ingrese la cant de payasos a comprar"))
peso_p2=round(float(payasos)*peso_p)
peso_m2=round(float(munecas)*peso_m)
peso=round(peso_m2+peso_p2)
print("el peso es " + str(peso) + "g")
|
57ba583649fdb78dfd5afdad714e2b9bd72ea363 | nini564413689/day-3-2-exercise | /main.py | 546 | 4.34375 | 4 | # 🚨 Don't change the code below 👇
height = float(input("enter your height in m: "))
weight = float(input("enter your weight in kg: "))
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
BMI = round (weight / height ** 2,1)
if BMI < 18.5:
result = "You are underweight."
elif BMI < 25:
result ... |
3de96c30c59043575fca1d5a11df36f68e2fad99 | chaithra-yenikapati/python-code | /question_10.py | 1,295 | 3.71875 | 4 | __author__ = 'Chaithra'
def left_binary_search(input, value):
def left_binary(low,high):
if(low>high):
return -1
else:
middle=(low+high)/2
if(value<input[middle]):
return left_binary(low,middle-1)
elif(value>input[middle]... |
9cd8f10f326504cf9a46d47048fcf3c25d2df827 | chaithra-yenikapati/python-code | /question_08.py | 1,356 | 4.21875 | 4 | __author__ = 'Chaithra'
notes = """
This is to make you familiar with linked list structures usage in python
see the listutils.py module for some helper functions
"""
from listutils import *
#Given sorted list with one sublist reversed,
#find the reversed sublist and correct it
#Ex: 1->2->5->4->6-... |
9a091876fb126508edbbf4bde03346c85c27ef98 | jinggz/UniMa-Semeval18Subtask7 | /ReadDataAndPostagging/PreprocessingLemmatizing.py | 894 | 3.71875 | 4 | # remove Stopwords
# Lemmatization
# remove Uppercase
#Title&Abstract as input
# Author: Sara
from nltk.stem import WordNetLemmatizer
import nltk
nltk.download('wordnet')
import io
import os
from nltk.stem import PorterStemmer
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
#wor... |
03b1d4eda387f3b62e38eb2a85dd9d3fc1d1e72c | wmemon/01_basic_python_assignment_msrit | /17.py | 157 | 4 | 4 | celsius_temperature = float(input("Please enter the temperature in Celsius:- "))
print(f"The temperature in Fahrenheit is {(celsius_temperature*(9/5))+32}")
|
8f4064207d8459cd3e3f18518f45d61aab47c0b9 | ghleokim/codeTestProblems | /baekjoon/2231_bruteForce.py | 344 | 3.703125 | 4 | # https://www.acmicpc.net/problem/2231
n = int(input())
for number in range(1,n+1):
# sum과 map을 이용하면 더 빠르다.
# compare = number + sum(map(int, str(number)))
compare = number
for digit in str(number):
compare += int(digit)
if compare == n:
print(number)
break
else:
prin... |
36a495950d0482a1a8f357b90d71f16d53052962 | ghleokim/codeTestProblems | /prgrmrs/L2_124num.py | 615 | 3.640625 | 4 | #https://programmers.co.kr/learn/courses/30/lessons/12899
def tri(n,i=0,res=[]):
if i==0:
res=[]
quotient, remainder = (n-1) // 3, (n-1) % 3
if remainder == 0:
res.append('1')
elif remainder == 1:
res.append('2')
else:
res.append('4')
if not quotient:
ret... |
d9ef500e365b64ef287dec4bcf31d9c9c890d2fd | ghleokim/codeTestProblems | /kakao/kakao2017_17681_treasuremap.py | 1,495 | 3.53125 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/17681
# 방법 1: ''.join(string)
def solution1(n, arr1, arr2):
answer = []
tmp = [[' ' for _ in range(n)] for __ in range(n)]
for i in range(n):
for j in range(n):
if (arr1[i] & (1 << j)) or (arr2[i] & (1 << j)):
tmp[... |
c903d1d312ff2943c8d35ff4fe1f2331f9c6e15c | kalevaibhav/Ass2_word-count | /Ass2.py | 409 | 3.53125 | 4 | import os
tex=open('text.txt','r')
line=0
word=0
char=0
v=0
vowels="AaEeIiOoUu"
for w in tex:
li=w.strip("\n")
vowels_c=[vowe for vowe in li if vowe in vowels ]
v=v+len(vowels_c)
line+=1
wor=w.split()
word+=len(wor)
ch=len(w)
print(f"no of line in file: {line}")
print(f"no of words in fi... |
df0c2a15d88363c6fe023ea836b47f773b972e0a | lakr1m0za/ksd_flg | /python_scripts/sum_mass.py | 356 | 3.578125 | 4 | #L = input()
def sum_mass(elem):
elem = list(map(int, elem))
i = 0
for x in elem:
i = i + x
return i
if __name__ == '__main__':
assert sum_mass([1, 2]) == 3
assert sum_mass([1, 2, 3]) == 6
assert sum_mass([99, 234, 34, 1, 0, -5, 55, 666, 42]) == 1126
print("Coding complete? Cli... |
a6908414bbc3f3867fa9ea0cfb49b9133608c397 | lakr1m0za/ksd_flg | /python_scripts/nest_lists.py | 394 | 3.828125 | 4 | #students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]]
#n = 5
if __name__ == '__main__':
students = []
for _ in range(0, int(input())):
students.append([input(), float(input())])
second_lowest = sorted(list(set([score for name, score in students])))[1]
pr... |
4b37ae001c4ff753471916875955f13c8c741f11 | lakr1m0za/ksd_flg | /python_scripts/translate.py | 377 | 3.59375 | 4 | def translate (k, n = 2):
l = ''
while k != 0:
l = l + str(k%n)
k = k//n
return (l[::-1])
if __name__ == '__main__':
# These "asserts" are used for self-checking and not for an auto-testing
assert translate(19) == '10011'
assert translate(19, 7) == '25'
assert trans... |
c18b622285056b2305b06fa34624e566826b2f19 | asbabiy/programming-2021-19fpl | /shapes/reuleaux_triangle.py | 1,435 | 4.1875 | 4 | """
Programming for linguists
Implementation of the class ReuleauxTriangle
"""
import math
from shapes.shape import Shape
class ReuleauxTriangle(Shape):
"""
A class for Reuleaux triangles
"""
def __init__(self, uid: int, width: int):
super().__init__(uid)
self.width = width
def... |
613218885c2cce0a3e616eb8fa8dec6ee1a4849e | michaelg68/tensorEnv | /main.py | 1,931 | 3.828125 | 4 | #https://www.techwithtim.net/tutorials/machine-learning-python/linear-regression-2/
#https://www.youtube.com/playlist?list=PLzMcBGfZo4-mP7qA9cagf68V06sko5otr
import pandas as pd
import numpy as np
import sklearn
from sklearn import linear_model
from sklearn.utils import shuffle
import matplotlib.pyplot as plt
from matp... |
3e0dfa0a57cf81a76d3cb8d4e359a028e8dd0987 | Funny-Code-Denis/small_database_python | /DATA_BASE.py | 4,038 | 3.703125 | 4 |
'''Console program for working with a database
Devoloper: Sosnin Denis
Verion 1.5'''
import time
import os
#Create new directory
def new_directory(path_to_dir, name_new_dir, List):
new_dir = path_to_dir + '\\' + name_new_dir
try:
os.mkdir(new_dir)
except OSError:
print('The directory is not c... |
a5e91083ea21a679e8ecac103db48bfa06a6aa91 | pratikgl/CompBio | /ManhattanTourist (1).py | 3,763 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 4 16:04:43 2021
@author: pratikgl
"""
# Dynamic Programming algorithm to solve the manhattan tourist problem
# Description of the problem
"""
Matrix dimension => 5*5
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors
# representation... |
97ad80b3b2d3ff3927905699483f38155b780b14 | AzeezRazak/python_spare_scripts | /Scraps_Friends/Seri/Random_Add.py | 2,507 | 3.796875 | 4 | import operator
import random
from random import randint
operators = [('+', operator.add), ('-', operator.sub)]
def random_with_N(n):
range_start = 10**(n-1)
range_end = (10**n)-1
return randint(range_start, range_end)
def random_with_nn(n):
range_start = 10**(n-1)
range_end = a
return randin... |
a5209870b4e20eab279814ce763070c7c0299955 | SaudAltamimi/ProjectEuler | /problem_30/main.py | 374 | 4.0625 | 4 |
def is_digits_sum_nth_power(num:int,n:int):
num_str = str(num)
return num == sum(int(d) ** n for d in num_str)
def main():
nums_found = [num
for num in range(2,1_000_000)
if is_digits_sum_nth_power(num,n=5)
]
# the answer
print(su... |
3b0215ecb502bbe6456529e4c5e10d08916afe4d | J4VJ4R/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/9-multiply_by_2.py | 184 | 3.9375 | 4 | #!/usr/bin/python3
def multiply_by_2(a_dictionary):
new_dictionary = dict()
for key, val in a_dictionary.items():
new_dictionary[key] = val*2
return new_dictionary
|
26369b3a557992bfd32f984c5ce2a7fe6c91eb8f | J4VJ4R/holbertonschool-higher_level_programming | /moki/5-no_c.py | 145 | 3.5625 | 4 | #!/usr/bin/python3
def no_c(my_string):
for i in my_string:
if ((my_string[i] == 'c') && (my_string[i] == 'C')):
return i |
7be72b0c71dbab01edb35b618ffaeee0bf94873f | bhanugudheniya/Python-Program-Directory | /PythonHome/Basic/ObjectIdentity.py | 283 | 4 | 4 | """
In python every created object identifies uniquely in python.
It provides the guaranteed that no two objects will have the same identifiers.
The build-in id() function, is used to identify the object identifiers.
"""
a = 50
b = a
c = 100
print(id(a))
print(id(b))
print(id(c))
|
9fc901382c1065e5ed2db51daf45782aaa7a40ca | bhanugudheniya/Python-Program-Directory | /PythonLab Assignment 2/SecondLargestElement_ONE.py | 204 | 3.859375 | 4 | n=[5,10,4,8,3,9]
print(f"The List Is {n}")
l=len(n)
for i in range(0,2):
for j in range(0,l-1):
if(n[j]>n[j+1]):
n[j],n[j+1]=n[j+1],n[j]
print(f"The Second Largest Element In The List Is {n[l-2]}")
|
bb8a63e3519eb993938fb8bd1dab2e4f7c83170a | bhanugudheniya/Python-Program-Directory | /CWH_Program_Practice_DIR/CH7_Loops_RightTriangleNumberPatternUsingWhile.py | 143 | 3.90625 | 4 | n = int(input("Enter Row no : "))
i = 1
num = 1
while i <= n:
j = 1
while j <= i:
print(num, end=" ")
j += 1
num += 1
print()
i += 1 |
496a4f7d22be556069f223ed783004735a52ed21 | bhanugudheniya/Python-Program-Directory | /PythonLab Assignment 2/OddNumberOfTimes_THREE.py | 345 | 4.0625 | 4 | L=[]
K=[]
n=int(input("Enter Number of elements in a list that you want to insert:"))
for i in range(n):
x=input()
L.append(x)
for i in L:
y=L.count(i)
if(y%2!=0):
if(i not in K):
K.append(i)
print("The element which is occurring odd number of times is:",i)
if(K==[]):
print("There are no elements which occ... |
c491ce9d01b71f264356e2dac5578a0e2ca240b8 | bhanugudheniya/Python-Program-Directory | /CWH_Program_Practice_DIR/CH7_Loops_RightTriangleStarPatternUsingWhile.py | 182 | 3.96875 | 4 | n = int(input("Enter Row no : "))
i = 1
while i <= n:
j = 1
while j <= i:
print("*", end=" ")
j += 1 #increase column
print() #print next line
i += 1 #increase row |
2d7d2926305b7b0f003da1ad6525feae54b50a69 | bhanugudheniya/Python-Program-Directory | /PythonLab Assignment 2/Intersection_SIX.py | 215 | 3.515625 | 4 | s1=input("Enter First String:")
s2=input("Enter Second String:")
s1=list(s1)
s2=list(s2)
for i in range(len(s1)):
ctr=0
for j in range(len(s2)):
if(s1[i]==s2[j]):
ctr+=1
if(ctr==0):
print(s1[i],end=" ")
|
95058a6355a18b7a0ce81c9671e8e102ce194ac0 | bhanugudheniya/Python-Program-Directory | /CWH_Program_Practice_DIR/CH6_ConditionalExpression_PositiveIntegerCheck.py | 229 | 4.28125 | 4 | userInput = int(input("Enter Number: "))
if userInput > 0:
print(userInput, "is a positive integer")
elif userInput < 0:
print(userInput, "is a negative integer")
else:
print("Nor Positive and Nor Negative Integer, it's Zero") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.