blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
8b5d5e498c4cfdf5de6452f67c87a171680f0cd2 | danielgospodinow/InstagramUnfollowers | /src/backend/utils/trie.py | 638 | 3.921875 | 4 | def getRootOfTrie(words):
root = {}
for word in words:
currentNode = root
for char in word:
if char in currentNode:
currentNode = currentNode[char]
continue
newDic = {}
currentNode[char] = newDic
curren... |
6c1e715f8bb4292fcb482c6e39c1f9a7d669cc31 | KristinaKeenan/PythonWork | /3_16_15.py | 249 | 3.734375 | 4 | def getOrd(letters):
for aChar in letters:
print(aChar, "=",ord(aChar))
for aChar in letters.upper():
print(aChar, "=",ord(aChar))
def main():
alphabet = "abcdefghijklmnopqrstuvwxyz"
getOrd(alphabet)
main()
|
9052cee99473fb4da410c92c8806fe01042f55ca | pragatirahul123/list | /without_len_count.py | 87 | 3.71875 | 4 | list=[1,1,4,5,6,7,5]
index=0
count=0
for index in list:
count=count+1
print(count)
|
884376c095b8d35f3b2610546c126636b21a2c55 | jasonwee/asus-rt-n14uhp-mrtg | /src/lesson_data_persistence_and_exchange/pickle_dump_to_file_1.py | 564 | 3.5 | 4 | import pickle
import sys
class SimpleObject:
def __init__(self, name):
self.name = name
l = list(name)
l.reverse()
self.name_backwards = ''.join(l)
if __name__ == '__main__':
data = []
data.append(SimpleObject('pickle'))
data.append(SimpleObject('preserve'))
data... |
cb0fe28be7b88e9259879b2fd0c44df49249cf61 | MariaSyed/Python-SelfStudy | /Chapter 8/8.3 Calculator, Checking input validity.py | 1,291 | 4.25 | 4 | import math
print("Calculator")
keepgoing = True
while keepgoing:
try:
num1 = input("Give a number: ")
num1 = int(num1)
break
except ValueError:
print("This input is invalid.")
while keepgoing:
try:
num2 = input("Give a number: ")
num2 = int(num2)
break
except ValueError:
print("This inpu... |
89e20b1f1b15cae6603955cc69f9262dd3187b38 | 5samuel/juego-samuel | /comida.py | 2,519 | 3.84375 | 4 | import turtle
import time
import random
posponer = 0.1
#window configuration
wn = turtle.Screen ()
wn.title ("Juego de Snake")
wn.bgcolor ("pink")
wn.setup(width=600,height=600)
wn.tracer(0)
#snake head
head = turtle.Turtle ()
head.speed (0)
head.shape("circle")
head.penup()
head.goto(0,0)
head.direction="stop"
head... |
d172d3fcad8d16c87542c082ce8d358a6db5f5e0 | laismarques/AI-Machine-Learning-Course | /Optimization-Algorithms/Problem_Representation.py | 1,417 | 3.53125 | 4 | people = [('Lisboa', 'LIS'),
('Madrid', 'MAD'),
('Paris', 'CDG'),
('Dublin', 'DUB'),
('Bruxelas', 'BRU'),
('London', 'LHR')]
destination = 'FCO'
flights = {}
for i in open('flights.txt'):
origin, destination, departure, arrive, price = i.split(','... |
86db37d32f4b20ca2127601f0fb40b5457b036f6 | azarrias/udacity-nd256-project3 | /src/problem_1.py | 1,577 | 4.34375 | 4 | def sqrt(number):
"""
Calculate the floored square root of a number
Args:
number(int): Number to find the floored squared root
Returns:
int: Floored Square Root
"""
if number is None or number < 0:
return None
elif number in [0, 1]:
return number
low, ... |
12c7b8593ccef24efa7ee9fd5015a39bf35ce4eb | isun-dev/algorithm-study | /insun/numberof124.py | 579 | 3.53125 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/12899
def solution(n):
answer = ''
while n > 0:
# 1. 3으로 나눠지는 경우.
if n % 3 == 0:
# 3으로 나눠지는 경우 항상 4로 끝남.
answer = '4' + answer
n = int(n / 3) - 1 # 몫은 3으로 나눈 후 -1을 해야 한다.
else:
# 3으로 나눠지... |
0b7918136ef9747b0e19c4296d511619f29e53ed | rishinkaku/Software-University---Software-Engineering | /Python Fundamentals/MidExam_Preparation/03. Last Stop.py | 1,133 | 3.75 | 4 | painting_numbers = input().split()
command_line = input()
while command_line != 'END':
data = command_line.split()
command = data[0]
if command == 'Change':
num1 = data[1]
num2 = data[2]
if num1 in painting_numbers:
num1_index = painting_numbers.index(num1)
... |
5c382da3107e541ee88eb35e89f97ac95537c7b2 | Divadsjo/Skola | /EXTRA UPPGIFTER/3D_printer.py | 104 | 3.828125 | 4 | n = int(input("Antal: "))
for x in range(n):
if 1*2**x >= n:
print(x, "dagar")
break |
4bf04535657f52a9fcb050ae37c423a2ae03e492 | MineRobber9000/pyfiles | /xorfuscate.py | 834 | 3.578125 | 4 | def encode(data,n=1):
data[n] = data[n-1] ^ data[n]
if (n+1)<len(data):
return encode(data,n+1)
def decode(data,n=None):
n = len(data)-1 if n is None else n
data[n] = data[n-1] ^ data[n]
if (n-1)>0:
decode(data,n-1)
def display(payload):
print("PAYLOAD:")
print(" - {} item{}".format(len(payload),"s" if len... |
ad49c9be63b7312a8f7b92d7e285fb54dcfbf526 | GearoidDC/Automate_the_Boring_Stuff_Examples | /Fantasy_Game_Inventory.py | 745 | 3.984375 | 4 | inventory = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12}
dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby']
#Function lists out items in inventory
def displayInventory(inv):
total = 0
print("Inventory:")
for item , num in inv.items():
print(str(num... |
dc23d14805397e25ffacb122b0335442273dfadd | tejadeep/Python_files | /tej_python/basics/Exception_Handling/logging_2.py | 504 | 3.96875 | 4 | #program to store the exception logs in file
import logging
logging.basicConfig(filename="log.txt",level=logging.INFO)
logging.info(" ******** new information came ****** ")
try:
x=int(input("enter the num\n"))
y=int(input("enter the second num\n"))
print(x/y)
except ZeroDivisionError as msg:
print(" its wrong re... |
25d4120c50aaa7cf5304222cf058d4ccb8600ba1 | nischalshrestha/automatic_wat_discovery | /Notebooks/py/tallbrian/can-brian-survive-the-titanic/can-brian-survive-the-titanic.py | 7,178 | 3.640625 | 4 | #!/usr/bin/env python
# coding: utf-8
# Hello World
# ==========
# This is my first attempt at Titanic... I am new to data science and pandas but I am excited to learn.
# --------------------------------------------------------------------------------------------------------------------
# In the first cell I am __im... |
24e4de19c208f167b6ea7d60c63198e31b1f2977 | j-hermansen/in4110 | /assignment3/tests/test_array.py | 2,522 | 4 | 4 | from assignment3.array import Array
def test_if_print_returns_string():
arr1 = Array((5,), 1, 2, 3, 4, 5)
assert str(arr1) == "1 2 3 4 5"
def test_append_single_element():
arr1 = Array((3,), 1, 2, 3)
new_array = arr1 + (4,)
assert new_array == (1, 2, 3, 4)
def test_append_array():
arr1 =... |
16f3953901ed14ada788dd03619585b0ffb99233 | masterzz/python-learn | /文件/09-批量重命名.py | 638 | 3.703125 | 4 | import os
'''
#1. 获取制定路径下 的所有文件名
allFileName = os.listdir("./test")
print(allFileName)
#2. 循环的方式 依次进行重命名
for name in allFileName:
os.rename("./test/"+name,"./test/"+"[东京出品]-"+name)
'''
#0. 提示并获取一个要重命名的文件夹
needRenameFile = input("请输入要批量重命名的文件夹:")
#1. 获取制定路径下 的所有文件名
allFileName = os.listdir("./"+needRenameFile)
pr... |
cf04a5e3dd10063c28cfcfbfafad2d4ff70a7d9a | MaximPushkar/PythonUniversity | /2_term/Classworks/Classwork 3/problem 3_1.py | 1,099 | 3.6875 | 4 | class QuadraticEquation:
count = 0
@staticmethod
def get_count():
return QuadraticEquation.count
def __init__(self, a, b=0, c=0):
if isinstance(a, QuadraticEquation):
self._a = a._a
self._b = a._b
self._c = a._c
else:
assert a != ... |
f0364c901475b2a54c156ac5ce1c802640c73fd4 | NJ1219/UofT-FinTech-Projects | /Week-2 Python/Python_homework/PyRamen/PyRamen.py | 4,522 | 3.84375 | 4 | # -*- coding: UTF-8 -*-
"""PyRamen Homework Starter."""
# @TODO: Import libraries
import csv
from pathlib import Path
Path.cwd()
# @TODO: Set file paths for menu_data.csv and sales_data.csv
menu_filepath = Path('Resources/menu_data.csv')
sales_filepath = Path('Resources/sales_data.csv')
# @TODO: Initialize list obje... |
c723e747faaaeade47f9c831e2c83a2b5f521593 | hirosuzuki/atcoder-2020 | /abc180/abc180_c.py | 247 | 3.59375 | 4 | N = int(input())
from math import sqrt
result = []
for i in range(1, int(sqrt(N)) + 1):
if N % i == 0:
result.append(i)
j = N // i
if j != i:
result.append(N // i)
result.sort()
print(*result, sep="\n")
|
9f6634b53b6aa9d59e9cfab69f6e921511616c1e | justinclark-dev/CSC110 | /code/Chapter-5/my_graphics.py | 1,687 | 4.375 | 4 | # Turtle graphics functions
import turtle
# The square function draws a square. The x and y parameters
# are the coordinates of the lower-left corner. The width
# parameter is the width of each side. The color parameter
# is the fill color, as a string.
def square(x, y, width, color):
turtle.penup() # ... |
3885568c14a8e8d94130b77058985fd178a1f233 | g87l/Showcase | /Showcase_Project.py | 20,011 | 3.828125 | 4 | import sys
import pickle
class Rooms:
def __init__(self, name, north, south, east, west, up, down, description):
self.name = name
self.north = north
self.south = south
self.east = east
self.west = west
self.up = up
self.down = down
self.description =... |
e145e970939a81ca35029adade1a6e9b7e50113b | cindychea/python_fundamentals2 | /exercise5.py | 236 | 4.125 | 4 | def temperature_converter():
print("What is the temperature in Fahrenheit?")
return (int(input()) - 32) * 5/9
celsius_temp = temperature_converter()
print("The temperature is {:.0f} degrees Celsius.".format(celsius_temp))
|
029d67ad1f51cefefd78c6903beff8c9840c3ee4 | gitonga123/Learning-Python | /coin_demo.py | 247 | 3.84375 | 4 | import coin
def main():
my_coin = coin.Coin()
print "The side of the coin that is up: ", my_coin.get_sideup();
print "I am going to toss the coint in ten times:"
for count in range(10):
my_coin.toss()
print(my_coin.get_sideup())
main() |
f5f34f416ae11da6e29b6ed8062a87b5e5416ec7 | upul/WhiteBoard | /algorithm/reference/LinkedList.py | 2,631 | 3.875 | 4 | from reference.Node import Node
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def size(self):
if self.head is None:
return 0
counter = 0
current = self.head
while current is not None:
counter += 1
current... |
7baaf4a4275abc2a4668358e9c364c7def4f1e7e | zdravkob98/Programming-Basics-with-Python-March-2020 | /Programing Basics March2020/Programming Basics Online Exam - 28 and 29 March 2020/06. Tournament of Christmas.py | 772 | 3.703125 | 4 | count_days = int(input())
total_money = 0
total_win = 0
total_lose = 0
for day in range(1, count_days +1):
lose = 0
win = 0
count_money_per_day = 0
line = input()
while line != 'Finish':
games = line
win_or_lose = input()
if win_or_lose == 'win':
win += 1
... |
66bfa7ec4d6e137408180751df5b67d4e7c22ba8 | booniepepper/exercism-solutions | /python/raindrops/raindrops.py | 251 | 3.640625 | 4 | from typing import List, Tuple
Sound = Tuple[str, int]
sounds: List[Sound] = [
('Pling', 3),
('Plang', 5),
('Plong', 7)
]
def convert(n: int) -> str:
sound = ''.join(s for (s, m) in sounds if n % m == 0)
return sound or str(n)
|
6aea74caab6bef97a1c28d3c5bac392dea460825 | tuhiniris/Python-ShortCodes-Applications | /list/Ways to count the occurance of an element in a list.py | 1,638 | 4.25 | 4 | print("-------------METHOD 1--------------")
#simple approach
"""
We keep a counter that keeps on increasing
if the esquired element is found in the list.
"""
def countX(list,x):
count=0
for ele in list:
if ele == x:
count=count+1
return count
list=[]
n=int(input("Enter size of the list: "))
fo... |
13d96ebafc457e9ab74acafcb20686b6a1338ed6 | aidev42/codereview | /MNIST+-+CNN.py | 3,938 | 3.59375 | 4 |
# coding: utf-8
# In[40]:
# Import dependencies
import matplotlib.pyplot as plt
import numpy
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from keras.utils import np_utils
# In[41]:
# Download MNIST data
from keras.datasets import mnist
(X_train, y_train), (X_... |
83b9b17de6ec3d8a9fc3ffd16953faae892b4af2 | mikedesu/google_interview | /test3.py | 597 | 4.21875 | 4 | def print_matrix(matrix):
for row in matrix:
for col in row:
print('%d ' % col, end='')
print()
def main():
print('hello, world!')
matrix = [
[1,2,3],
[4,5,6],
[7,8,9]
]
print('printing matrix...')
print_matrix(matrix)
transposed = [[row[i... |
6f66b05988aab49d605b7006e137997f64742b8c | RicardsGraudins/Python-Fundamentals | /Solutions/07_palindrome.py | 612 | 4.40625 | 4 | #Palindrome - a word, phrase, or sequence that reads the same backwards as forwards, e.g. madam
#Ask the user for input
word = raw_input("Enter a word, phrase or sequence: ");
#Check if the parameter passed is a palindrome
#Note that the function is case sensitive, madam is not the same as Madam
def palindromeTest(str... |
373faca5bdf6f4ad392690f18e2b1491deaabe77 | MAPLE-Robot-Subgoaling/IPT | /data/HW3/hw3_132.py | 650 | 4.21875 | 4 | def main():
temp = float(input("Please enter the temperature: "))
unit = input("Please enter 'C' for Celsius, or 'K' for Kelvin: ")
if unit == "K" or unit == "k":
tempAdj=temp-273
elif unit == "C" or unit == "c":
tempAdj=temp
else:
print("Improper unit entry. Please try again... |
35bdab241a0abbf63592bb2047d3a081cdd8dd2f | Penzragon/CipherFile | /file.py | 2,403 | 4.21875 | 4 | alphabet = "abcdefghijklmnopqrstuvwxyz"
symbol = "~`!@#$%^&*()_-+=;:'\",.? "
def vigenere(message, keyword):
"""This is a function for decrypting a message
Args:
message (string): message that going to be decrypted
keyword (string): a keyword for decrypting the message
Returns... |
2d1af54d2a792274bf996c879905d4d5b5a531c1 | yuehenying/python | /spider/1.4.2.py | 2,263 | 3.84375 | 4 | # coding:utf-8
'''
1.Threading创建多线程
import time,threading
import random
def thread_run(urls):
print('Current %s is running...' % threading.current_thread().name)
for url in urls:
print('%s ---->>> %s' % (threading.currentThread.__name__, url))
time.sleep(random.random())
print('%s is running..... |
ae70b6adb207d13ea7a9c05ba857121c527fb69b | ethantofavaha/Quizzlet | /Quiz.py | 337 | 4 | 4 | #multiple question
print("What is the best fastfood franchise?")
user_answer = input()
if user_answer == "Mcdonalds":
print("You are correct!")
elif user_answer == "Burger King":
print("its nice but not the best.")
else:
print("not even close, try again next time.")
print("What is the best fastfood franchise?")
... |
9659c76aeb4d22de779682b92f3c2f1d87873165 | jessicabelfiore/python-exercises | /Chapter05/Exercise0505.py | 665 | 3.90625 | 4 | """
Exercise 5.5. Read the following function and see if you can figure out what it does. Then run it (see the examples in Chapter 4).
"""
try:
# see if Swampy is installed as a package
from swampy.TurtleWorld import *
except ImportError:
# otherwise see if the modules are on the PYTHONPATH
from Turtle... |
fbd152a735b515bcd606c78d6a9dcdb7b1bb4a30 | ahmedhamza47/Projects_for_Beginner | /text-base adventure game.py | 2,276 | 4.125 | 4 | print('Welcome to the text adventure game:')
name = input('Enter your name:')
age = int(input('Enter your age:'))
health = 10
try:
if age >=18:
print('Your are old enough to play')
des = input('Do you want to play?(y/n):').lower()
if des == 'y':
print('You are starting with 10 h... |
a038b7c1941a5727d8105ab5f1fa8ab0440de45b | aethersg/project_euler | /python/problem_30.py | 893 | 3.984375 | 4 | # coding=utf-8
# Solution to problem 30
# Problem Statement: Digit fifth powers
#
# Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
# 1634 = 1^4 + 6^4 + 3^4 + 4^4
# 8208 = 8^4 + 2^4 + 0^4 + 8^4
# 9474 = 9^4 + 4^4 + 7^4 + 4^4
# As 1 = 1^4 is not a sum it is not ... |
254fb3b2e982fcd46794ad8d4efc35dd7e85fe13 | saequus/learn-python-favorites | /Tasks/VectorClassRealization.py | 753 | 3.8125 | 4 | # Vector Class Realization
import math
class Vector:
def __init__(self, x, y):
self.x = x
self.y = y
# unary negation (-v)
def __neg__(self):
return Vector(-self.x, -self.y)
# addition (v + u)
def __add__(self, other):
return Vector(self.x + other.x, self.y + othe... |
e7b49e554790b8ea4e22d28d3098bb9b41d772fc | skoolofcode/SKoolOfCode | /TrailBlazers/LiveClass/Class_3_31_Live.py | 1,001 | 3.890625 | 4 | #Understanding Git : This is a modification to the file.
#Let's store dictionary into a file
#Just one more edit
student_scores = {'Rob':[10,20,30],
'Tommy':[34,45],
'Ram' : [50,50,10]}
print("This is my dictionary",student_scores)
#fp = open("/data/file_3_31.txt","w")
#fp.write(stu... |
c90cb3dd316432056ada1fd6e14f59b9e024f565 | maiphuong1809/nguyemaiphuong-fundamental-c4t4 | /session04/btvn04.py/turtle01.py | 171 | 3.5625 | 4 | from turtle import*
speed (-1)
color ("blue")
for i in range (35):
for i in range (4):
forward (100)
left (90)
right (345)
mainloop()
|
2535476ed46255cbbd4490c24454d86f1a832aa5 | PClark344/Demos-Learning | /Lishkov.py | 578 | 3.5625 | 4 | class Shape:
def __init__(self,shape_type):
self.__shape_type = shape_type
def get_type(self):
return self.__shape_type
def get_area(self):
pass
class Rectangle(Shape):
def __init__(self,width,height):
self.__width = width
self.__height = height
def get_are... |
ec77d4658bc68c3a9c458370755b9ff01b1f357c | LoicGrobol/python-im-2 | /corrections/recursion.py | 5,558 | 4 | 4 | class Node:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left # Node
self.right = right # Node
def __eq__(self, other):
"""On redéfinit la fonction d'égalité pour prendre en compte les arbres correctement."""
return (
sel... |
7279a251b020aa3b666bd1133061ae6301b4dda4 | SudhaDevi17/PythonCodingPractice | /Frequency Stack.py | 1,065 | 3.640625 | 4 | import collections
class FreqStack:
def __init__(self):
self.freq = collections.Counter()
self.group = collections.defaultdict(list)
self.maxfreq = 0
def push(self, x):
print("\n ####################### Push Operations #######################")
f = self.freq[x] + 1
... |
1184e2413a792513178890ca98db7781b22b6543 | infinitedreams9586/StatisticsAlgo | /Gradient Descent.py | 2,446 | 3.546875 | 4 | import numpy as np
import random
import sklearn
import pylab
from scipy import stats
from sklearn.datasets.samples_generator import make_regression
def gradient_descent(alpha, x, y, ep, max_iter):
converged = False
iterations = 0
m = x.shape[0]
print "m is %s" %(m)
# initial theta
theta0 = np... |
a68558b4dd5a8c97bac65d39bd96a7cca837e57b | daniel-reich/turbo-robot | /sDvjdcBrbHoXKvDsZ_20.py | 1,046 | 4.09375 | 4 | """
Write a function that returns `True` if a given name can generate an array of
words.
### Examples
anagram("Justin Bieber", ["injures", "ebb", "it"]) ➞ True
anagram("Natalie Portman", ["ornamental", "pita"]) ➞ True
anagram("Chris Pratt", ["chirps", "rat"]) ➞ False
# Not all letters are... |
773e95ec9dafaf6b344d27fad5e9653f45321772 | Andras-z/LeetCode | /Linked List/Add Two Numbers.py | 760 | 3.828125 | 4 | '''You are given two non-empty linked lists representing two non-negative integers.
The digits are stored in reverse order and each of their nodes contain a single digit.
Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
I... |
32c1a7d78496d3bd68b817615816d53b561b1641 | pavithrra/Spam-mail-prediction-using-Naive-Bayes-and-NLP | /workers.py | 836 | 3.515625 | 4 | import pandas as pd
def mapping_parallelize(df1):
print("Processing ....")
bag_of_words = []
for index, row in df1.iterrows():
bag_of_words = bag_of_words + row['words']
bag_of_words = list(set(bag_of_words))
column_names = ["mail_id"] + bag_of_words
df2 = pd.DataFrame(columns= c... |
5e75da87b5e20b886249ae11023647cc7e28d0cc | Aasthaengg/IBMdataset | /Python_codes/p03281/s380989578.py | 684 | 3.859375 | 4 | # -*- coding: utf-8 -*-
def get_input() -> int:
"""
標準入力を取得する.
Returns:\n
int: 標準入力
"""
N = int(input())
return N
def main(N: int) -> None:
"""
メイン処理.
Args:\n
N (int): 1以上200以下の整数
"""
# 求解処理
ans = 0
for n in range(1, N + 1, 2):
divisors_c... |
e845e0c9f866225a8df91b89c7aa18f1b5be8fc6 | Yuhsuant1994/leetcode_history | /solutions/easy_reverse_integer.py | 828 | 4.28125 | 4 | """
Given a 32-bit signed integer, reverse digits of an integer.
Note: Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For this problem, assume that your function returns 0 when the reversed integer overflows.
Example:
Input: x = 120
O... |
ed5a93c9ff62b00c4f4c0da63f5044319effd8f7 | CGayatri/Python-Practice1 | /control_28_assert.py | 1,169 | 4.3125 | 4 | ## program 28 - to assert that the user enters a number greater tha zero.
num = int(input('Enter a number greater than 0: '))
assert num>0, "Wrong input entered, it should be greater than 0"
print('U entered: ', num)
"""
F:\PY>py control_28_assert.py
Enter a number greater than 0: 5
U entered: 5
F:\PY>py control_... |
1292e93b4d56ed4e58870ac069abd1c090192d4b | citronneur/community | /MichaelBrown/sqlitetools.py | 25,073 | 3.8125 | 4 | """
Parsing tools for sqlite records.
These tools are aimed at reading rows from a database file when parts of the
file are missing or corrupted. It does not depend on reading the database
header information, but it it helpful to have prior knowledge about the column
types.
Limitations:
* If a record does not fit ... |
deb082bbb1e4082aef6f7131afa4a707fefde0fd | Ricky-Millar/100-days-of-python | /pycharm/main.py | 414 | 4.25 | 4 | # Split string method
import random
names_string = input("Give me everybody's names, separated by a comma. ")
names = names_string.split(", ")
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
# f lets you insert non strings into the {}, len-1 as the list counts from 0 and the length counts from... |
00ad4241d5a3c97928d9201357a4277a0c26d7a8 | nishant-sr/Student_Performance_Linear-Regression | /Student_Performance_Linear-Regression/main.py | 1,711 | 4.03125 | 4 | import pandas as pd
import numpy as np
import sklearn
from sklearn import linear_model
import matplotlib.pyplot as pplot
from matplotlib import style
# save csv file as dataframe
data = pd.read_csv("student-mat.csv", sep=";")
# filter the dataframe to contain observations for only the attributes of our choi... |
c955d038f96e71d0d3f922f6847a04919c059b1b | Daherson/Homework | /HomeW4/ex4p4.py | 117 | 3.75 | 4 | the_list = [1, 2, 2, 3, 3, 5, 4, 6, 6]
new_list = [el for el in the_list if the_list.count(el) < 2]
print(new_list) |
b80a060ca182aae19a06ed3f26bb25043be4aa88 | tawfung/FlirtAnalyzer | /EDfT/detector/deep_learn/learn.py | 2,759 | 3.859375 | 4 | from keras.models import Sequential
from keras.layers import Dense
from keras.utils.np_utils import to_categorical
import numpy as np
import tensorflow as tf
from keras import backend as K
import os
class Trainer:
def __init__(self):
pass
def start(self):
tf_session = tf.Session()
K.se... |
6aa3a50035148a43fb7fe2e8fd5c76e9ac8a3f07 | Mrquoc2409/Pham-Quoc-Anh-C4T8 | /Session8/eg16.py | 191 | 3.65625 | 4 | Movies = ["Spider-man", "Infinity war","Dragon ball"]
print(*Movies, sep = " | ")
i = int(input("The number do you want to DELETE."))
Movies.pop(i)
print("Updated:", *Movies, sep = " | ") |
26404ac7241a1a168e9b0cf77b8ad99cca883deb | chariotrequiem/python-learning | /code/chap5操作列表/5.1遍历整个列表.py | 1,761 | 4.34375 | 4 | # 当前版本 : python3.8.2
# 开发时间 : 2021/8/23 21:58
# 你经常需要遍历列表的所有元素,对每个元素执行相同的操作。
# 需要对列表中的每个元素都执行相同的操作时,可使用Python中的for循环。
# 用for循环来打印魔术师名单中的所有名字
magicians = ['alice', 'david', 'carolina']
# 这行代码让Python从列表magicians中取出一个名字,并将其存储在变量magician 中。
for magician in magicians:
print(magician)
# 1.在for循环中执行更多操作
magicians = ['al... |
9d0060fc4977ecf9cf6243bdccc64c5328870f0b | frictious/codewars_kata | /multiples_of_3_and_5.py | 925 | 4.375 | 4 | '''If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.
Note: If the number is a multiple of both 3 and 5, only count it once. Also, if... |
7e97400c36732d1e99650098ca9c6783a293af84 | aleksey-masl/hello_world | /set_methods.py | 261 | 3.96875 | 4 | cities = {'Las Vegas', 'Paris', 'Moscow'}
print(cities)
print('\n')
cities.add('Burma')
print(cities)
cities.add('Moscow')
print(cities)
cities.remove('Moscow')
print(cities)
print(len(cities))
for city in cities:
print(city)
print('Paris' in cities) |
51333a65eb60c36780fba875c0bdbc20f4301a2a | iamsamitdev/BasicPythonExercise | /first.py | 959 | 3.75 | 4 | # เครื่องหมาย comment
print("Hello Python")
print("สวัสดีภาษาไพทอน")
# การรับค่าในภาษา python
name = input("กรุณาป้อนชื่อของคุณ: ")
print("สวัสดีคุณ " + name)
print(2+8)
print("\tHello World")
print("Python\n" * 3)
data = """
คำอธิบายบรรทัดที่ 1
คำอธิบายบรรทัดที่ 2
คำอธิบายบรรทัดที่ 3
"""
print(data)
print("In Pyt... |
ed0926ebae978ba031486dbcc6e9f83bbe968584 | owalton/Python | /ex21.py | 787 | 4.15625 | 4 | #!/usr/bin/python
#Author: Octavius Walton
#Date:
#Purpose Exercise 21 Functions Can Return Something
def add (a, b):
print "adding %d + %d" % (a, b)
return a + b
def subtract(a, b):
print "Subtracting %d - %d" % (a, b)
return a - b
def multiply(a, b):
print "Multiplying %d * %d" % (a, b)
return a * b
def ... |
60c95d3295e42cdd92811a3e83c2398156324080 | banana-galaxy/challenges | /challenge12(day)/solutions/one.py | 354 | 3.53125 | 4 | def solution(day, date_1, date_2):
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
date_a, month_a, date_b, month_b = map(int, date_1.split('/') + date_2.split('/'))
date_diff, month_diff = date_b - date_a, month_b - month_a
return days[((days.index(day.lower())) + ... |
d12f69a5ac8e89be702a9eb24405eb0dbe748bc0 | akaruihoshi/project-euler | /euler4.py | 1,157 | 3.640625 | 4 | x = 999
y = 999
number = x * y
numberlen = len(str(number))
is_palindrome = False
z = 0
pal = 0
while number > 10000 and is_palindrome == False:
while x > 100 and is_palindrome == False:
while y > 100 and is_palindrome == False:
is_palindrome = True
while numberlen > 0 and is_palind... |
40817c6d3d28f1e57dd6801021be30d06e10ce27 | StephaneBranly/TicTacToe-AI | /ai.py | 4,634 | 3.5 | 4 | import numpy as np
import pygame
print("ai.py imported")
class Neural_Network(object):
def __init__(self):
# Nos paramètres
self.inputSize = 9 # Nombre de neurones d'entrée
self.outputSize = 9 # Nombre de neurones de sortie
self.hidden1Size = 3 # Nombre de neurones cachés
... |
09fdf2c1650f4dd53a26a4d8e16a0112e64d52ee | Neelaksh-Singh/NeoAlgo | /Python/dp/EditDistance.py | 2,271 | 3.875 | 4 | """
Edit Distance using dp
m: length of first string
n: length of second string
Time Complexity : O(m*n) (Looping through both strings)
Space Complexity : O(m*n) (Matrix distance)
"""
def editDist(firstString, secondString):
# Length of both strings
firstLength = len(firstString)
secondLength = len(secondString... |
d3887b5d0da4c31d749db8979fb8d68d58cc9a42 | zkself/homework3 | /calculate.py | 2,853 | 3.546875 | 4 | #-*- coding: utf-8 -*-
import random
from fractions import Fraction
import sys
import time
def initFix():#生成表达式(能生成随机数量的操作符1-10个)
tmp = []
opers = ['+', '-', '*', '/']
n = random.randint(3, 10)
flag = 1
while n >= 0:
if flag == 1:
tmp.append(random.randint(1, 100))
... |
96d978b8195544e5d62047c6fce102292a059225 | pegu1shekhar/jango | /main.py | 3,340 | 3.53125 | 4 | #HI,welcomes you in spy_chat
import spy_details,chat #calling chat file
while 1==1:
print"###WELCOME TO SPY_CHAT###" #greetings
print "IF YOU WANT TO CONTINUE AS A DEFAULT USER OR SIGN FOR NEW-USER?"
print"SELECT OPTION"
print"\t1.DEFAULT USER:\n\t2.SIGN ... |
82324f1b119a34edde69a69269b4b9dc2a396052 | hufman/SmartList | /smartlist/multilistlist.py | 5,879 | 3.53125 | 4 | import sys
PY2 = sys.version_info[0] == 2
if PY2:
irange = xrange
else:
irange = range
class MultiListFromList(object):
def __init__(self, list, transform=None, untransform=None, filter=None):
self.list = list
if transform:
self.transform = transform
if untransform:
self.untransform = untransform
if ... |
36dee6214028ea1f04ec496e8b1c5550a78e5142 | fhfhfhd26/PyCharm | /ch02inout/ch02-02pen.py | 1,014 | 3.890625 | 4 | import turtle
import random
# 함수 선언 부분
def screen_left_click(x, y) :
global r, g, b
turtle.pencolor((r, g, b))
turtle.pendown()
turtle.goto(x,y)
def screen_right_click(x, y) :
turtle.penup()
turtle.goto(x, y)
def screen_mid_click(x, y) :
global r, g, b
t_size = random.randrange(1, ... |
f8883160b58a857f428e85c2b9e25fbd9c78443e | parthnvaswani/Hacktoberfest-2020-FizzBuzz | /Python/FizzBuzz-Shout.py | 711 | 4.40625 | 4 | # Author: @carol975
# Shout the fizz buzz word using python speech to text
# The numbers preceding a fizz, buzz or fizzbuzz number add up
# to the volume of saying the word.
# Make sure to adjust the audio volume level of your device!!
# You need to install pyttsx3: https://pypi.org/project/pyttsx3/
import pyttsx3
e... |
7bc9bb87a9e647d2734c8ea3c3a8501286962e6a | Shantabu44/pythonProgramming | /shan.py | 6,627 | 3.640625 | 4 | # Exercise 1
print ("Exercise 1")
aircrafts = {
"x": 567.888,
"y": 895.11
}
f = open("exercise_1.txt", "w")
f.write("X -" + str(aircrafts["x"]) + ", Y -" + str(aircrafts["y"]))
f.close()
print ("X -", aircrafts["x"], ", Y -", aircrafts["y"])
multipleAircrafts = [{"x": 123.345, "y": 234.567},
... |
f2b431c508a1438da50420ab7de68a1b2ae6f4cf | VIJAY-CH/MyProject | /add.py | 308 | 3.859375 | 4 | ## This is my python script 123
x=5
y=10
def addition():
z= x+y
a=x*y
b=y-x
c=y/x
d=y%x
print("Addition is: ", z)
print("Multiplication is: ", a)
print("Subtraction is: ", b)
print("Division is: ", c)
print("Modulor is: ", d)
#print ("Hi")
def main():
addition()
main()
|
e6b5b064d7678e1fd413bfe65e064dbfedf48346 | jigs-bot/InstaLikeBot | /instabottt.py | 3,873 | 3.546875 | 4 | """I suggest you guys not to copy paste the code from here instead try to write each line
by yourself. writing code make you understand things better"""
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
import time
import random
impo... |
1972b0c66d56e414370732bcc7ae2b89bcf85b6e | elsasharon/Student-Database-Management-System | /database3.py | 1,852 | 3.609375 | 4 | import sqlite3
def StudentData():
con=sqlite3.connect("student1.db")
cur = con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS student1(id INTEGER PRIMARY KEY ,StdID text , Firstname text , Surname text ,Semester text , Payment text , Status text )")
con.commit()
con.close()
... |
072c1b062e1c2af808377674f7172deeb2bcb872 | Liviere97/PythonCourse-Arrays | /exercises/names.py | 348 | 3.8125 | 4 | #hacer una funcion que muestre el nombre
#lista de nombres
#por cada nombre en la lista ejecutar la funcion
#tener todo en una funcion
def get_nombre(nombre_list):
print (nombre_list)
def nombres():
lista= [
'livi',
'felipe',
'sahara',
]
for nombre_list in lista :
get_nombre(no... |
394b6c51f15899ba60267cb5e43419927ea51171 | ravenusmc/town | /human.py | 4,982 | 4.125 | 4 | class Human():
def __init__(self, name, age, gender):
self.name = name
self.age = age
self.gender = gender
self.life = 15
self.hunger = 14
self.boredom = 0
self.bathroom = 0
self.money = 50
self.dating = False
def walk(self):
print(self.name + " is walking!")
self.hung... |
e4e47a6cf6e69ba633a9cd1b73a1d1ba11896f89 | PilarNew/pybasic | /17-POO-constructor/auto.py | 1,862 | 4 | 4 | """
Constructor: Método especial dentro de una clase y se acostumbra usar para darle un valor a los atributos del objeto al crearlo. Es el primer método que se ejecuta al crear el objeto y se llama automáticamente al crearlo.
Como cualquier otro método puede recibir parámetros. Se le pasan los parámetros cuando se invo... |
efd63800504032e860300866edbfa1f2185f58f6 | 4dHacker/SchachComputer | /a.py | 3,601 | 3.78125 | 4 | class Figure:
def __repr__(self):
return " "
def get_moves(self, board, x, y):
return []
def __init__(self):
self.empty = True
# TODO
class Bishop(Figure):
def __repr__(self):
return "B" if self.white else "b"
def __init__(self, white):
Figure.__init__(se... |
77c5cfc9187b5a4a3f86983eed14a3efbb03cf90 | lzkelley/zcode | /zcode/math/numeric.py | 24,436 | 3.796875 | 4 | """General functions for mathematical and numerical operations.
Functions
---------
- spline - Create a general spline interpolation function.
- cumtrapz_loglog - Perform a cumulative integral in log-log space.
- extend - Extend the given array by extraplation.
- sa... |
b85aa7b073aa0481d844a0904f1aa4c623a61a08 | iamanobject/Lv-568.2.PythonCore | /HW_9/Anton_Dmytryshyn/Home_Work9_Task_2.py | 281 | 3.9375 | 4 | DayNumbers = {
1:"Monday", 2:"Tuesday",
3:"Wednesday", 4:"Thursday",
5:"Friday", 6:"Saturday", 7:"Sunday",
}
try:
number = int(input("Enter the number of the day: "))
print (DayNumbers[number])
except:
print("Error, day number can be only between 1 and 7") |
745c5c41dca143deb08dc889b96b65309e040c39 | Jonathanimmanuel03/UG9_A_71210815 | /3_A_71210815.py | 315 | 3.6875 | 4 | data1 = 'teh'
data2 = 'susu'
d1 = input(str('Masukan Daftar Belanjaan 1 : '))
d2 = input(str('Masukan Daftar Belanjaan 2 : '))
d3 = input(str('Tambahkan Daftar Belanja 1 : '))
d4 = input(str('Tambahkan Daftar Belanja 2 : '))
print('Daftar Belanjaan 1 : ',d1,'dan',d3)
print('Daftar Belanjaan 2 : ',d2,'dan',d4)
|
7feaaaae0c6a6b8a411aad5ec0580f91996be4e3 | Jackson-Pike/PythonTerm2 | /HumanClass.py | 1,106 | 3.828125 | 4 | import random
class Human(object):
questions = ["What is 2 + 2?", "Who is the president of the United States?"]
def __init__(self, name, hair_color, eye_color, height, weight, iq, gender, race):
self.name = name
self.hair_color = hair_color
self.eye_color = eye_color
self.heigh... |
35d5026d9b4f89fbb73c8d85a99f0b235ecd72a0 | poitrek/Project-Euler-Problems | /common/primes.py | 2,779 | 4.34375 | 4 | from math import ceil, sqrt
def is_prime(n):
"""Checks if n is a prime individually (without any global structure)
When to use: (TODO)
Time complexity: O(sqrt(n))
:returns True if n is prime, False otherwise"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
... |
22473b9c8c2bf6d5cdcbf29b4791eefcf7de9f12 | silentpete/python-programming | /python_crash_course_2nd_edition/ch4_working_with_lists/players.py | 689 | 4.125 | 4 | players = ['charles', 'martina', 'michael', 'florance', 'eli']
# list elements start at index 0
# print from 0 index to index 3
print(players[0:3])
# print index 1 - 4
print(players[1:4])
# print starting at the beginning up to the 4th index
print(players[:4])
# print from index 3 to the end
print(player... |
0878fa119bba502ddd87592b588f0d44b6090ce0 | GuiRodriguero/pythonFIAP | /1 Semestre/Aula13/VinteNumeros.py | 387 | 3.859375 | 4 | cont = 2
num1 = 0
maior = 0
menor = 0
num1 = int(input("Digite um número: "))
print("Número 1 de 20")
menor = num1
while cont <= 19:
num1 = int(input("Digite um número: "))
print("Número ", cont, " de 20")
if num1 > maior:
maior = num1
if num1 < menor:
menor = num1
cont += 1
p... |
42117500f98888079f13815f63affea328bf5819 | jwood91/Python-Crash-Course | /8 Functions/excercises/magicians.py | 553 | 3.625 | 4 | def show_magicians(magicians, greatest_magicians):
for magician in magicians:
print(magician.title())
for magician in greatest_magicians:
print(magician.title())
def make_great(magicians, great_magicians):
while magicians:
magician = magicians.pop()
great_magician = "Great ... |
7e2dcf3312db9f04dc86c7b87569f7ad94a3cc0f | stoyaneft/HackBulgariaProgramming-101 | /week0/2.Harder_problems/magic_square.py | 661 | 3.546875 | 4 | def magic_square(matrix):
row_sums = list(map(sum, matrix))
if len(set(row_sums)) != 1:
return False
square_size = len(matrix)
columns = []
forward_diagonal = []
backward_diagonal = []
for i in range(square_size):
columns.append([row[i] for row in matrix])
forward_dia... |
9338c750f3f00d2a2a47f5c0ee477dce5fc92d79 | JUNYOUNG31/TIL | /day2/control_flow.py | 301 | 4.0625 | 4 | #홀짝을 구분하는 조건문을 작성을 해보자.
x = 19
# if x % 2 == 1:
# print("홀수입니다.")
# else:
# print("짝수입니다.")
if x % 2:
print("홀수입니다.")
else:
print("짝수입니다.")
# 양수 / 0 / 음수
# if
# elif
# else
#반복문
#for
#while
|
5f81cac5eba06c7a31d1777f66b7987276a5c681 | ybroze/humpy | /utils.py | 873 | 3.65625 | 4 | """
Utilities for working with pitches, durations, etc.
"""
PC = [0, 2, 4, 5, 7, 9, 11]
def pitch_to_midinote(pitch):
"""Convert a humdrum pitch string such as 'AA#'
to a MIDI note number.
"""
note = ''.join( c for c in pitch if c not in '#-n' )
if note.isupper():
octave = 5 - len(note... |
75e9a6339d0623ec4587855f1102b7e35706acbc | edneipdemelo/1stWeek | /010.py | 186 | 4 | 4 | # Leia uma velocidade em km/h e apresente-a convetida em m/s.
print('Digite a velocidade em km/h:')
kmh = float(input())
ms = kmh / 3.6
print(f'A velocidade convertida em m/s é: {ms}') |
707e8c9d09f56ba5aac35f14cd2c105a8a79448f | G-Vicky/hackerrank-challenges | /python lists.py | 608 | 3.859375 | 4 | if __name__ == '__main__':
N = int(input())
mylist = []
for i in range(1, N+1):
command, *value = input().split()
if command == "append":
mylist.append(int(value[0]))
elif command == "insert":
mylist.insert(int(value[0]), int(value[1]))
elif command ==... |
96874c63901a593e8e4f4968c76fdb037297e363 | emanoelmlsilva/ExePythonBR | /Exe.Funçao/Fun.01.py | 150 | 3.90625 | 4 | def imprimi(n):
for i in range(n+1):
for x in range(i):
print(i,end=' ')
print()
num = int(input("digite o numero desejado: "))
imprimi(num)
|
ae0a0cbb4e8148421a7ff9bec215404ae707aa0d | sgerogia/anagrams | /anagrams-python/anagrams.py | 887 | 3.921875 | 4 | #!/usr/bin/python
import sys
import os.path
from trie import Trie
from triepath import fromWord
def main(argv):
if len(argv) < 1:
print("Usage: anagrams.py <dictionary file location>\n" +
"\tDictionary must have one word per line and all words in the same case (e.g. lower-case)")
sys... |
9c04d68187ff495faea1b67910544348667236e2 | daniil-tol/python | /pythonProject/lesson1 task4.py | 213 | 3.640625 | 4 | s = int(input("Введите число? "))
print(s)
a0 = 0
maxn = 0
while s % 10 != 0:
a = s % 10
s = s//10
if a >= a0:
a0 = a
print(f"Cамая большая цифра в числе {a0} ") |
9e256ae90a5091d84ede3414af05a534854716ee | avanetten/cresi | /cresi/data_prep/road_speed.py | 34,943 | 3.609375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 23 19:30:30 2019
@author: avanetten
https://community.topcoder.com/longcontest/?module=ViewProblemStatement&rd=17036&pm=14735
https://arxiv.org/pdf/1807.01232.pdf
Appendix A: The SpaceNet Roads Dataset Labeling Guidelines
The SpaceNet Roads Datas... |
4d8cc6786057683865fcdc32ed63560f257e9f2a | romanBeya11/Jarvis.py | /JarvisRealDeal.py | 5,067 | 3.515625 | 4 | import random
import speech
import time
import datetime
import sys
import os
class Jarvis:
def __init__self(self):
pass
def initialization(self):
speech.say('Initializing')
print 'Initializing...'
time.sleep(3)
speech.say('Configuring Settings')
print 'Configuring Settings...'
time.sleep(3)
speech... |
43ed9d3b2fb43e1502beb96236f8592a33ce90d5 | nehadeep/hardeep-python | /Users/HardeepKaur/PycharmProjects/hardeep-python/app.py | 529 | 3.90625 | 4 |
# def age_program():
# user_age = input("please enter you age: ")
# age_Seconds = int(user_age) * 364 * 24 * 60 * 60
# print("your age in seconds is {}".format(age_Seconds))
#
# age_program()
import pymongo
uri = "mongodb://127.0.0.1:27017"
client = pymongo.MongoClient(uri)
database = client['hardeepsta... |
65b57d04a54740d5b580c2699d610e0ea70a2db0 | tiagotakeda/cpp_workshop | /Exercises/answer_keys/python/mmc.py | 416 | 4.125 | 4 | def mmc (a, b):
if a > b:
maior = a
tmp = a
menor = b
else:
maior = b
tmp = b
menor = a
while (maior%menor != 0):
maior += tmp
return maior
def main():
a, b = input ("Give me 2 numbers: ").split()
a = int (a)
b = int(b)
pr... |
0e0af9bdc4d2d0e76560f7649e1b9760db8877fe | ankita-y/HackerRankProblemSolutions | /List.py | 560 | 3.578125 | 4 | if __name__ == '__main__':
n = int(input())
l = []
for i in range(n):
s = input().split()
cmd = s[0]
a = s[1:]
if cmd == 'insert':
l.insert(int(a[0]),int(a[1]))
elif cmd == 'pop':
l.pop()
elif cmd == 'append':
l.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.