blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
d79bf4cac924c1394dd1a786cc710691a6dbffae | AdamZhouSE/pythonHomework | /Code/CodeRecords/2716/60717/261459.py | 372 | 3.953125 | 4 | input()
a=input().split('"')[1]
b=input().split('"')[1]
input()
count=1
if a[0]=="/":
count+=1
if a[len(a)-1]=="\\":
count+=1
if b[0]=="\\":
count+=1
if b[len(b)-1]=="/":
count+=1
summ=-1
if a[0]=="\\":
summ+=1
if a[len(a)-1]=="/":
summ+=1
if b[0]=="/":
summ+=1
if b[len(b)-1]=="\\":
summ... |
f14f0df1924716f2fb52e5d642c09f8d37e9c6ec | devmacrile/algorithms | /graph-search/graph.py | 4,318 | 4.03125 | 4 | """
Implementation of a graph as a dictionary of dictionaries
"""
import random
class Graph(dict):
"""
A Graph is a dictionary of dictionaries. The outer dictionary maps from a
vertex to an inner dictionary. The inner dictionary maps from other vertices
to edges.
For vertices a and b, gra... |
f82013f94ff5312ac6999b9845e8ced8d4c793a3 | beppe712/honours-project | /DICE/rand_dna_gen.py | 486 | 3.578125 | 4 | import sys
from random import randint
def gen_rand_dna(str_len, file_name):
outfile = open(file_name,'w+')
alphabet = ['A','C','G','T']
string = ""
for i in range(str_len):
string += alphabet[randint(0,3)]
outfile.write(string)
outfile.close()
def main():
str_len = int(raw_input("Insert string length: ")... |
5a61db5d88afe5644cb975a3bb043bb7cb325c29 | DuncanDHall/PL2016 | /homework1.py | 16,528 | 3.625 | 4 | ############################################################
# HOMEWORK 1
#
# Team members: Duncan Hall, Jordan Van Duyne
#
# Emails: duncan.hall@students.olin.edu, jordan.vanduyne@students.olin.edu
#
# Remarks:
#
#
# Expressions
#
class Exp (object):
pass
class EInt... |
d1739570855e957aae8e9cb912bc92ccdc4ad211 | AnastasiaAlekseevna/mobile_systems | /1 lab/Parser/Parser.py | 1,271 | 3.515625 | 4 | import csv
import math
data = {'outCalls': [], 'inCalls': [], 'sms': []} # Array for storing incoming, outgoing calls and the number of SMS
def csv_dict_reader(file_obj,ph_number): #Function for parsing a csv - file and filling the array with data
reader = csv.DictReader(file_obj, delimiter=',')
for line in... |
9854e2fc2a7a105c633c4b92944002f751809e19 | ppcmdgames/Statistics-Application | /MainSample.py | 750 | 4.375 | 4 | from tkinter import *
window=Tk()
# Code to add widgets
# Syntax for Button: Variable = Button(window, attributes)
# Place specifies location. Syntax: Variable.place(x= x position, y= y position)
# Position is an integer value
btn1=Button(window, text="Button 1", fg="blue")
btn1.place(x=150, y=250)
btn2=Button(window, ... |
32b9c52dde509864194dbc049a5d84a3d251891d | averycordle/csce204 | /exercises/jan19/graphical-math.py | 487 | 3.796875 | 4 | #Author: Avery Cordle
import turtle
#relativity
turtle.bgcolor("skyblue")
turtle.setup(500,500)
#set up pen
pen = turtle.Turtle()
pen.color("black")
pen.fillcolor("white")
#define the size
#turtle.numinput("Title", "Prompt", "default", "min", "max")
size = turtle.numinput("Snowman", "Size (1-4): ",3,1,4)... |
68707ac2c0c20922c33d8c98e3d660ff2bb31644 | driellevvieira/ProgISD20202 | /JoaoPaulo/Aula4/Aula4 - Contextualizado/contextualizada4.py | 15,105 | 3.875 | 4 | #variaveis
habituado = 0
recompensa = 0
distancia = 30 #centimetros
toques = 0
som1 = 0
barra_esquerda = 0
vezes = 0
tempo = 0
contador_barra_esquerda = 0
contador_vezes = 0
contador_toques = 0
print("Informe se o animal está habituado")
habituado = int(input("Se o animal estiver habituado, digite 1. Caso contrário, ... |
f65e694ce7796e7f88a52cda4294e663c24fb4ef | harshadajog/python-problemsolving | /PairThatSumsTo.py | 604 | 3.75 | 4 | def main():
print("Inside main")
arr = [6,3,5,2,1,7]
findPair(arr, 9)
def findPair(arr, X):
print("Inside findPair")
new_dict = dict()
i=0
while i < len(arr):
num = arr[i]
if(num > X):
i = i + 1
if(num < X):
y = X - num
if y in new... |
887594cd09febf98a6fdc10d0ecfedc3fd9efdf0 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2223/60595/241842.py | 150 | 3.96875 | 4 | num=input()
#用例有点诡异。。。
if(num=="1,2,4,7"):
print("[0, -4]")
elif(num=="1,2,2,4"):
print("[2, 3]")
else:
print("[2, 1]")
|
0a2262b370c3e48cec4fc59981c3b7999d6fe146 | MrHamdulay/csc3-capstone | /examples/data/Assignment_5/chnjea007/question2.py | 942 | 3.90625 | 4 | total = eval(input("Enter the cost (in cents):\n"))
paid = 0
while paid < total:
deposit = eval(input("Deposit a coin or note (in cents):\n"))
paid += deposit
totalChange = paid - total
ones, fives, tens, twentyFives, hundreds = 0, 0, 0, 0, 0
if totalChange != 0:
while totalChange >= 100:
hundreds +... |
c2182bb2f641f6f21f28e35540270ec505c96921 | fpavanetti/python_lista_de_exercicios | /aula20_explicação.py | 1,643 | 4.65625 | 5 | '''
Aula 20 - Funções (Parte 1)
As funções estão relacionadas às rotinas. Exemplos: print(), len(), input(),
int(), float()...
>> Criamos funções para executar rotinas que realizamos constantemente em nossos
códigos, de modo a otimizar nosso tempo - e muito mais. Nem todas as funções de
que possamos vir a p... |
555020e9ec8d6ca977dff869cfb0392d11c329da | fatecoder/Python-practices | /cat_mouse5.py | 2,655 | 3.890625 | 4 | #!/bin/python
import random
p = ''
letras = ['a','b','c']
tablero = [[' ',' ',' '],[' ',' ',' '],[' ',' ',' ']]
def input_usuario():
if espacios() is True:
coor = raw_input("Ingresa posicion: {Ejemplo: %s," %random.choice(letras) + "%i}: " %random.randrange(1,4))
if len(coor) == 3 and coor[1] == ... |
a322fad368cf494168c54b75c94aa782b2c172c7 | Tomek2340/Python-lessons | /Functions If, Else, Elif.py | 280 | 3.84375 | 4 | #równe
print(5 == 5)
#różne
print(5 != 1)
#mniejsze lub równe
print(5 <= 5)
a = input('Podaj liczbę a: ')
b = input('Podaj liczbę b: ')
if int(a) > int(b):
print('a Większe b')
elif int(a) < int(b):
print('a Mniejsze b')
else:
print('a równe b') |
e5044699dc89309c2ad10237f78de2951f0864d1 | janus-magnus/Miniproject_CSN | /Tests/test2.py | 437 | 3.515625 | 4 | import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)# set de modes van pin nummering
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)#dit zet pin 11 op als input met een interne pulldown circuit
GPIO.setup(12, GPIO.OUT)# dit zet pin 12 als output, hier zit de LED op
GPIO.output(12, 0)
try:
while True:
GP... |
34587b44c051cced0d2831ee4487d1b36e178b56 | softwaresaved/data_management_plan_investigation | /merge_outcomes.py | 2,029 | 3.625 | 4 | #!/usr/bin/env python
# encoding: utf-8
import pandas as pd
import numpy as np
import csv
import os.path
DATA_FILE_DIR = "./data/"
def import_csv_to_df(filename):
"""
Imports a csv file into a Pandas dataframe
:params: get an xls file and a sheetname from that file
:return: a df
"""
return ... |
b5d35baf3429daad5cf68075579dba00e13f8a72 | SashaMargaryan/Basic-IT-2 | /Homework-N7/xnt251.py | 74 | 3.625 | 4 | x = [1,2,6,3,4,5,]
y = 0
for i in x:
if i > y:
y = i
print(y) |
0092e683762530b6438246fd1ad72ebe867e5451 | BillyGareth/DataScienceScrapestar | /jumiaphones.py | 1,423 | 3.5 | 4 | from bs4 import BeautifulSoup as soup
from urllib.request import urlopen, Request
url="https://www.jumia.co.ke/smartphones/"
req=Request(url, headers={"User-Agent":"Mozilla/5.0"})
webpage=urlopen(req).read()
page_soup = soup(webpage,"html.parser")
containers = page_soup.findAll("div",{"class":"info"})
filename = ... |
d62fcda9ed8eca4150a9800f87dfa7c76ef6b8a3 | codebind-luna/exercism_python | /difference-of-squares/difference_of_squares.py | 299 | 3.9375 | 4 | def square_of_sum(upto):
sum = 0
for i in range(1, upto + 1):
sum += i
return sum ** 2
def sum_of_squares(upto):
sum = 0
for i in range(1, upto + 1):
sum += (i ** 2)
return sum
def difference(upto):
return square_of_sum(upto) - sum_of_squares(upto)
|
4d1c57822ca0e87902c1346b9e9e3ee51a5dbba9 | arsh09/semantic_analysis_on_quora_dataset | /scripts/Train_Classifier.py | 4,305 | 3.53125 | 4 |
# -*- coding: utf-8 -*-
"""
The script trains the classifier on the sentence-vectors and their labels (similar or not)
The classifiers are SVM and KNN. They are saved in different files using pickle.
Arshad
"""
Debug = True
if Debug: print ("Importing the modules..")
import numpy as np
from sklearn i... |
6dbb514b798ac808e9591d6bc4fd983e47e50cc3 | oliversus/calculate-coins | /countNCoins/testCountCoins.py | 2,078 | 3.75 | 4 | '''
Created on Sep 7, 2016
@author: oliver
'''
import unittest
from countNCoins.Coins import Coins
class coinsTest(unittest.TestCase):
def setUp(self):
# initialize coins object
self.coins = Coins(1.11, "Euro")
def tearDown(self):
# destroy object after use
self.coins = No... |
1c3cfddc93f350545cc40a99f73f43f22fe10254 | ArthurZey/toyproblems | /templates/newfile.test.py | 718 | 3.546875 | 4 | #!/usr/bin/env python3
from newfile import *
import unittest
class MyTestCases(unittest.TestCase):
def setUp(self):
# Create instances of the class or of an input_to_output array, if required.
pass
def tearDown(self):
# Delete instances of the class or of an input_to_output array, if required.
pa... |
d46a6e75fb26fd65edc6cfedf28a6d2fc26a0e07 | VictorSimao/TrabalhosPython | /Estudo/Codility/lesson4-3.py | 226 | 3.6875 | 4 |
def solution(A):
if max(A) < 1:
return 1
for numero in range(1, max(A) + 2):
if numero not in A:
return numero
A = [1, 3, 6, 4, 1, 2]
print(solution(A))
A = [1,2,3]
print(solution(A)) |
1c1b5590e911be0a8d50f696516d7ce4159bd295 | DimpleOrg/PythonRepository | /GeeksforGeeks/vAnil/03. List Programs/9.py | 468 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 7 10:31:39 2021
@author: ANIL
"""
'''
Given a list of numbers, the task is to write a Python program to find the smallest number in given list.
Examples:
Input : list1 = [10, 20, 4]
Output : 4
Input : list2 = [20, 10, 20, 1, 100]
Output : 1
'''
lis... |
e5970fd34c5187389bc565bc8731c8110c9e9342 | johngschulz/caesar | /helpers.py | 640 | 3.84375 | 4 | def alphabet_position(letter):
alphabet = "abcdefghijklmnopqrstuvwxyz"
ualphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if letter.isupper():
position = ualphabet.index(letter)
else:
position = alphabet.index(letter)
return(position)
def rotate_character(char, rot):
alphabet = "abcdefghi... |
237a896046c473e73ecd9fdd1133cb930206739c | khuang428/CSE101 | /lab5.py | 3,556 | 3.65625 | 4 | # Karen Huang
# KARHUANG
# 111644515
# CSE 101
# Lab #5
# In this part of the file it is very important that you write code inside
# the functions only. If you write code in between the functions, then the
# grading system will not be able to read your code or grade your work!
# Part I
def sequence(n):
retStr = ... |
71cf3eb92aa636683ae0508c99d33116740a713d | jihwankimqd/Coursework-and-Projects | /numerical_integrals/Q2_Adaptive_Simpson_Weierstrass.py | 1,780 | 3.796875 | 4 | import numpy as np
import matplotlib.pyplot as plt
import math
# def weierstrass(x):
def f(x):
result = 0
for i in range(0,101):
result += (a**i)*(np.cos((b**i)*np.pi*x))
return result
N = 2
a = 0.0
b = 0.5
# 3) Adaptive Simpson
# Simpson's method was highly inaccurate for values of N, which wer... |
e2bd5ce37428f264c345ca19912eea676375ec4f | YingyingHan1994/final_project_2020Sp | /museum_data.py | 10,986 | 3.703125 | 4 | import json
import re
import pandas as pd
# Collect data and extract info needed for analysis
# 1. Museum dataset
# A) The Metropolitan Museum of Art (MET)
met_raw_headers = ['Object Number', 'Is Highlight', 'Is Public Domain', 'Is Timeline Work', 'Object ID',
'Department', 'AccessionYear', 'Object... |
2ab03902259e3298a6b435bcbdbf402136d23d61 | szels/recommender_system | /simple.py | 1,137 | 3.78125 | 4 | # read https://www.datacamp.com/community/tutorials/recommender-systems-python
import pandas as pd
# Load movies metadata
metadata = pd.read_csv('../data/movies_metadata.csv', low_memory=False)
#print metadata.head(3)
# C is the mean vote across the whole report
C = metadata['vote_average'].mean()
#print C
# m is ... |
781bdb6cc0727bc246faf631a469472071e609e4 | Stanislav-Stashevskiy/cryptographer | /cipher3.0.py | 335 | 3.890625 | 4 | crypto_letter = []
while True:
what = input('Введите букву:')
d = {'a': 'n', 'b': 'o'}
print(d.get(what, 'буква не найдена'))
if what == 'stop':
print(crypto_letter)
crypto_letter.clear()
continue
crypto_letter.append(d.get(what, ''))
continue
|
35d7e932836377a90f88a949aeea37ec95593a3d | dayfine/kata | /implementations/algo/merge-sort.py | 676 | 3.859375 | 4 | from collections import deque
def merge_sort_main(arr):
return merge_sort(arr, 0, len(arr)-1)
def merge_sort(arr, low, high):
if low < high:
middle = (low + high) // 2
merge_sort(arr, low, middle)
merge_sort(arr, middle + 1, high)
merge(arr, low, middle, high)
def merge(arr, l... |
4dc3dcb551cd55a181302e3a7f2469cdebd5cb24 | jennings1716/Datastructure | /simple stack.py | 993 | 4.09375 | 4 | class stack:
def __init__(self):
self.stack=list()
def append(self,data):
self.stack.append(data)
def pop(self):
return self.stack.pop()
def display(self):
print(self.stack)
option = input("Enter the option \n 1. Create a List \n 2. Push an element"+
"\... |
569dea798d9a18c87ff9c38e3e568aa2616cfd69 | jorc-n/python_stack | /python/fundamentals/funciones_intermedias/main.py | 432 | 3.8125 | 4 | import random
def randInt(min=0, max=100 ):
if (max < 0):
max = max * (-1)
print("Se consideró valor absoluto de número")
if(min>max):
max=min
min=0
print("Se reasignaron los valores máximo y mínimo")
num = random.random()*max + min
return round(num)
print(randInt... |
aa42a86f26ef8f57485bea6d284b509d47430b5e | Krypanzer-xz/fricked-your-mom | /madlib.py | 834 | 3.78125 | 4 | # # goal is to create a madlib
print ("Python is pretty ______ that I wish to _______. seriously, you can never just go one day without feeling like ___________, \
I really wish this could be _____ so it would just make work a lot easier. oh, and subscribe to _________. they're \
great.")
adj = input ("Enter a ... |
d31210a1bf77e69091b8da46ae9391e9f6c4e36a | erin-koen/python-morsels | /add/add.py | 1,787 | 4 | 4 | def add(*args):
# args is an iterable that contains lists that contain lists.
# each outer list is an iterable that contains two lists
# each inner list is an iterable that contains a certain number of integers
# want to get to a point where we have
# [[[1,2], [-2, -1]], [[-3, 0], [4, -1]]]
# ^^... |
8c8f3774877d7ff56dbb74578d058c859e519ccd | mjsonofharry/apriori | /py/apriori/node.py | 3,451 | 3.578125 | 4 | import abc
class AbstractNode(metaclass=abc.ABCMeta):
def display_children(self):
print([child.mLabel for child in self.get_children()])
@abc.abstractmethod
def add_child(self, label):
pass
@abc.abstractmethod
def get_child(self, label):
pass
@abc.abstractmethod
... |
d05c149bb79923d3ffc407a84b87255eadeefb79 | UBC-MDS/DSCI_522-Group-403-Student-Performance | /src/data-download.py | 3,041 | 3.953125 | 4 | # Author(s): Kenneth Foo, Brayden Tang, Brendon Campbell
# Date: January 17, 2020
"""This script downloads and extracts a .zip file from a specified
web URL to a given file path provided by the user. This script assumes that it will be run
in the root of the project directory.
Usage: data-download.py <url_link> --f... |
d2259949d129072b9ac80bd2d4a02edb2c605f70 | mashikro/code-challenges | /group_anagrams.py | 978 | 3.828125 | 4 | # Prompt: Given an array of strings, group anagrams together.
# All inputs will be in lowercase.
# The order of your output does not matter.
# TestCase:
# Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
# Output:
# [
# ["ate","eat","tea"],
# ["nat","tan"],
# ["bat"]
# ]
def signature(s):
ret = list(s)
... |
a3a3f53cc90d02a36fc0f9cb49860afb5e47cc5c | GGMagenta/exerciciosMundo123 | /ex065.py | 826 | 4.03125 | 4 | # Pegue varios números e calcule a média, o maior e menor valor, perguntando se quer por mais números
maior = 0
menor = 0
cont = 1
soma = 0
media = 0
opcao = 's'
n = int(input('Digite um número: '))
maior = menor = soma = media = n
while opcao == 's':
opcao = input('Quer digitar outro valor?[s/n] ').lower... |
67e387a4efdbf76030b33240ad1a3dedc13039c6 | antbz/MNUM | /metodos/euler.py | 1,928 | 3.59375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 11 14:16:00 2019
@author: antonio
"""
from math import exp
def f(x, y):
return -0.25 * (y - 42)
def fy(x, y, z):
return z
def fz(x, y, z):
return 2 + x ** 2 + x * z
def fC(t, T, C):
return -exp(-0.5/(T+273)) * C
def fT(t, T,... |
0bdbc55a01d8b35bd4ab590370bfe1166c28c204 | cvibanez/DataPreparationStockMarketData | /MergingAndStoringData.py | 16,244 | 3.5 | 4 | # Conrad Ibanez
# Merging and Storing Data
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import sqlite3
#from bs4 import BeautifulSoup
def createDatabaseTables(fundamentalsDf,pricesSplitAdjustedDf,securitiesDf,webDataDf,apiDataDf):
'''
I will merge the following ... |
632ed57d8757e20642a72b1f1d5206ad4599782c | kangwonlee/16pfa_kangwonlee | /ex33_while/ex33.py | 489 | 4.15625 | 4 | # -*-coding:utf8
# http://learnpythonthehardway.org/book/ex32.html
i = 0
numbers = []
while i < 6:
print("At the top i is %d" % i)
numbers.append(i)
i = i + 1
print("Numbers now: " + str(numbers))
print("At the bottom i is %d" % i)
print("The numbers: ")
for num in numbers:
print(num)
# 여... |
0c980002c32b4e9fcdd9560fb7041556757d84cc | adityad30/Linked-List-1 | /48ReverseLinkedList.py | 1,534 | 4.1875 | 4 | """
// Time Complexity :O(n) for traversing till the end of the list
// Space Complexity :O(1)
// Did this code successfully run on Leetcode : Iterative - YES/ Recursive-NO
// Any problem you faced while coding this : Not able to assign
pointer1.next values in recursive
//Explanation:
#iterative
Use 3 pointers - point... |
416dbff77897e3f9af99938929a05915d92adcf1 | filipmalecki94/Python | /Task_lists/pazdziernik/pazdz18.py | 68 | 3.53125 | 4 | i = 0
while i < 10:
i += 1
if i % 2:
continue
else:
print(i) |
6c2e54cafff24860b499088dc6f68c6bc369d988 | GuilhermeRamous/python-exercises | /Números e suas propriedades.py | 2,069 | 3.765625 | 4 | from math import ceil
def par_ou_impar(x):
if x % 2 == 0:
return "par"
else:
return "ímpar"
def positivo_ou_negativo(y):
if y > 0:
return "positivo"
else:
return "negativo"
def int_ou_dec(z):
if ceil(z) == z:
return "inteiro"
else:
... |
6239e4b4bda6b58abc5b7b8421e929de7937f086 | Jerrydds/UnitTest | /Func/calc.py | 442 | 3.9375 | 4 | # 1. 通过Python语言编写一个运算的类(Calc),类中包含两个函数:
#
# 1) add(self,a,b) 返回a+b之和
# 2) sub(self,a,c) 返回a-c之差
# 自定义运算类
class Calc(object):
# 自定义求和函数
def add(self, a, b):
return a + b
# 自定义求减函数
def sub(self, a, c):
return a - c
if __name__ == '__main__':
print(Calc().add(5, 5))
pri... |
9016373800c2c5bd23b05c481e0b3704296b26d4 | Jayshri-Rathod/function | /sum average.py | 326 | 4.21875 | 4 | # def sum_average():
# a=int(input("enter first number"))
# b=int(input("enter second number"))
# c=int(input("enter third number"))
# sum=a+b+c
# average=sum/3
# average=int(average)
# print("sum of three numbers",sum)
# print("average of three number",average)
# sum_average()
... |
02981937fcf7f2f290c1fb47ed93dcf2c5834c7c | laken11/AirlineManagementSystem | /FlightManger.py | 2,033 | 3.640625 | 4 | from flight import Flight
class FlightManager():
Flights = []
file = open("flights.txt","a+")
def __init__(self,acmgr):
self.acmgr=acmgr
self.file.seek(0)
for Flight_line in self.file:
self.Flights.append(Flight.parse(Flight_line))
def list(self):
for avalFli... |
1ffc7a03f81b4c7d8a4118cf4b391b3db6d80595 | munjolla/fractals | /fraktal_9.py | 864 | 3.703125 | 4 | from turtle import *
screensize(5000,4000, 'black')
color = ("gainsboro", "light gray", "silver", "dark gray", "gray", "dim gray", "white smoke")
speed(0)
def ciklus():
for i in range(1500):
pencolor(color[i%7])
forward(i/2)
left(6787)
backward(i)
right(90)
left(189)
... |
4a2405270eb61c079b4939856478f774b320ab39 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_97/1605.py | 1,297 | 3.84375 | 4 | #!usr/bin/env python
# -*- coding: iso-8859-1 -*-
#Function to generate list of digits of an integer.
def getlist(n) :
N=n
l=[]
L=[]
while N>0 :
l.append(N%10)
N=N//10
for i in range(len(l)) :
L.append(l[N-i-1])
return L
#Function to generate a number from an entered list.
def getnum(l) :
N... |
f89c02c40bfbc85dca2f9b83e3205187bc949c6b | gilbutITbook/006936 | /Unit 14/if_else_number.py | 383 | 3.515625 | 4 | if 0:
print('참')
else:
print('거짓') # 0은 거짓
if 1:
print('참') # 1은 참
else:
print('거짓')
if 0x1F: # 16진수
print('참') # 0x1F는 참
else:
print('거짓')
if 0b1000: # 2진수
print('참') # 0b1000은 참
else:
print('거짓')
if 13.5: # 실수
print('참') # 13.5는 참
else:
print('거짓')
|
bae369ec2146063afaa7c1ffda37c85826580f97 | Gyagya00/python_ex | /3회/성적내는 알고리즘.py | 221 | 3.796875 | 4 | score = int(input("성적을 입력하세요 : "))
if score>=100:
print("AAAAAAAAAAAAAAAAAAAAAA")
elif score==90:
print("BDBD")
elif score>59:
print("C")
elif score==40:
print("D")
else:
print("F") |
6748e28f9b7896359735f5881486f67c487c0d00 | Ganben/algo_solution | /algorithm_problems/41-first_missing_positive.py | 992 | 3.828125 | 4 | # -*- coding: utf-8 -*-
# ganben
#
import unittest
import math
'''
https://leetcode.com/problems/first-missing-positive/description/
Given an unsorted integer array, find the smallest missing positive integer.
Example 1:
Input: [1,2,0]
Output: 3
Example 2:
Input: [3,4,-1,1]
Output: 2
Example 3:
Input: [7,8,9,11,12... |
f97b3fa6db9e99870e1458ec089f7ca1ad131d62 | nagireddy96666/Interview_-python | /COMPANIES/stringoccurance.py | 158 | 3.953125 | 4 | x=raw_input("enter a strin:")
ch=raw_input("enter a occurance to find no of occurancces")
count=0
for i in x:
if ch==i:
count=count+1
print count
|
2d7bb7947461c6c5341949575a6288d4d8eacbee | rdfriedm/math-notes | /electronics/hw/04/04.py | 153 | 3.65625 | 4 | # Author: Ben Kallus
# Reads input from stdin, prints it back case-swapped.
while 1:print("".join(chr(ord(c)+(("@"<c<"[")-("`"<c<"{"))*32)for c in input())) |
19b8270e8acee5e43bc6c452c7c35ef08f036c7b | Zapadlo13/Algorithms_and_data-_tructures_in_Python | /Lesson-1/Task-4.py | 1,206 | 4.28125 | 4 | # 4. Написать программу, которая генерирует в указанных пользователем границах:
# случайное целое число;
# случайное вещественное число;
# случайный символ.
import random
import string
ll = int(input('Нижная граница случайного целого числа: '))
ul = int(input('Верхная граница случайного целого числа: '))
print(f'Слу... |
36f22c7a90a7b8d1cf418ad67ca4ec4aed558040 | wingerlang/Eulerproject | /Python/Euler36.py | 599 | 3.625 | 4 | """
Double-base palindromes
Problem 36
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include leading zeros.)
""... |
96a051908466c3440f89e6b59ce44d07b0b0fb69 | ehiaig/contactmanager | /static_method.py | 853 | 3.890625 | 4 | import random
"""
Static Method: A method that can be called without a class instance
- A static method has @staticmethod above it.
- @staticmethod is Known as Decorator: Decorator is a function that manipulates another function before calling it
- It doesn't take (self)
It has
"""
class StringHelper:
@stati... |
38c190d66988b5f73c48a95e9f659bda2ef379f3 | naunidhsingh13/CodingQ | /Subarrays with K Different Integers.py | 1,038 | 3.859375 | 4 | """
992. Subarrays with K Different Integers
Hard
Given an array nums of positive integers, call a (contiguous, not necessarily distinct) subarray of nums good if the number of different integers in that subarray is exactly k.
(For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.)
Return the number of goo... |
5499a3d118b1260bc1a6694561bee8597d28e4d6 | YEJINLONGxy/shiyanlou-code | /interger.py | 587 | 4.0625 | 4 | #!/usr/bin/env python3
days = int(input("Enter days: "))
months = days // 30 #取整数
days = days % 30 #取余数
print("Months = {} dasy = {}".format(months, days))
###################or#####################
#days = int(input("Enter days: "))
#print("Months = {} days = {}".format(*divmod(days, 30)))
#divmod(num1, num2) 返... |
68fd80d1ab95889cf5ebbeafd3a1fe2cc79876bf | Daniyal7/Basics_code | /square_arg1.py | 294 | 3.65625 | 4 | import turtle
my_turtle=turtle.Turtle()
def square(length):
my_turtle.forward(length)
my_turtle.right(90)
my_turtle.forward(length)
my_turtle.right(90)
my_turtle.forward(length)
my_turtle.right(90)
my_turtle.forward(length)
for i in range(4):
square(50)
|
b920af0f07a019702b0560385d1e746465fd0b8d | BSmegha/functions | /calc.py | 254 | 3.84375 | 4 | import calcmodule as c
x=int(input("enter a number"))
y=int(input("enter a number"))
o=input("enter the operation")
if(o=='+'):
print(c.add(x,y))
if(o=='-'):
print(c.sub(x,y))
if(o=='*'):
print(c.prod(x,y))
if(o=='/'):
print(c.div(x,y))
|
39b109510f10b5363d160702423498576bddb563 | MachariaMark/password-vault | /user.py | 672 | 4.125 | 4 | class User:
"""
User class
Args:
login_name: To sign into the application.(str)
pin : To sign into the application.(str)
"""
user_list = []
def __init__(self, login_name, pin):
self.login_name = login_name
self.pin = pin
def save_user(self):
"""
this method appends new object to user... |
97f9e1e5698e7abc76a2a18ae5f81a1c8038a272 | DevAlone/google_foobar_solutions | /level 1/Prison Labor Dodgers/main.py | 196 | 3.609375 | 4 |
def answer(x, y):
# first should be smaller
x, y = (x, y) if len(x) < len(y) else (y, x)
ids_set = set(x)
for item in y:
if item not in ids_set:
return item |
d28ca48197116c76199eb481f2cd39fedce7c2d1 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/grains/b1266a8309ad4184a12457c5941ddd72.py | 118 | 3.53125 | 4 | def on_square(num):
return 2**(num-1)
def total_after(num):
return sum([on_square(i) for i in range(1,num+1)])
|
6f2ccd4de475bbef146816764ebec9b9d4fda102 | crazese/LeetCode | /Longest Common Prefix.py | 686 | 3.546875 | 4 | class Solution(object):
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
if len(strs) == 0 or strs[0] == '':
return ''
elif len(strs) == 1:
return strs[0]
length = len(strs[0])
res = strs[0]
for ... |
0a41d68e0e567f29683fc48b3969e0238e128845 | glenmillard/PythonProjects | /sort_fruits.py | 865 | 4.21875 | 4 | #!/usr/bin/python
#Write out alphabetically sorted fruits from input file unsorted_fruits.txt
#function does as follows:
# create and input for a file
#creates and output for a file
def sort_fruits(infile, outfile):
input = open(infile, 'r')
output = open(outfile, 'w')
unsorted = input.readlines()
#Steps ... |
66b0eb2147c1b7748fff725a5ba750ed09b020d1 | BrianFishbaugh/PythonLearning | /booleanLogic/bouncer.py | 307 | 4.3125 | 4 | #PseudoCode
#Ask For Age
age = input("How Old Are You? ")
if age:
age = int(age)
if age >= 18 and age < 21:
print("Enter, But you Need A Wristband")
elif age >= 21:
print("You're good to enter and can drink")
else:
print("Why're you here, you're too young")
else:
print("Please Enter An Age")
|
a048f40aa2da800a3f32028cecbd19f0db06557e | abhi9835/python | /questions_on_oops.py | 3,522 | 4.34375 | 4 | """Create a class C2d Vector and use it to create another class representing a 3D vector."""
class C2DVec():
def __init__(self, i, j):
self.i = i
self.j = j
def __str__(self):
return f"{self.i}i + {self.j}j"
class C3DVec(C2DVec):
def __init__(self, i, j, k):
super().__init... |
e01a2c4b48db66273c60b3a28a614ac1cd83a4b7 | ZHANGDINGREN123/numpy-pandas | /PycharmProjects/study/#20_input输入.py | 531 | 4.125 | 4 | ############可运行1############
#a_input = input('please give a number:')
#print("This input number is:",a_input)
#if a_input == '1':
# print("This is 1")
#elif a_input == str(2):
# print("This is 2")
#else:
# print("This is Other")
########################
############可运行2############
a_input = int(input('pleas... |
726914246052acf0bf2dfb876a6c52d2639d958a | dmcg89/tweetgenv2 | /sample.py | 1,283 | 4.1875 | 4 | import random
def histogram(word_list):
"""Builds histogram from text input"""
dict = {}
for word in word_list:
if word not in dict:
dict[word] = 1
else:
dict[word] += 1
return dict
def weighted_random_select(dict):
"""Takes in a histogram and generates a r... |
12091f8e099bdd5d8624e0a6c63dd073a3ea8a69 | 031205/Wave-3 | /Exercise92.py | 190 | 3.5 | 4 | def PrimeNumberIndicator(a):
if a >= 2:
for i in range(2,a):
if a % i == 0:
return False
return True
else:
return False
|
29b46b427313b0de532ccf55e0a697bd16d0ace1 | mohitdtumce/Machine-Learning-in-Python | /Plots/Lines.py | 421 | 3.5 | 4 |
# coding: utf-8
# In[1]:
import numpy as np
import matplotlib.pyplot as plt
# In[22]:
#Coordinates of the first line
x1 = [1, 2, 3, 4]
y1 = [5, 8, 11, 14]
#Coordinates of second line
x2 = [1, 2, 3, 4]
y2 = [1, 0, -1, -2]
# In[23]:
#Plotting the lines
plt.plot(x1, y1, label = 'y = 3x + 2')
plt.plot(x2, y2, ... |
7da2c0aa20736d5f2fd305fab8b7e91a4381db41 | luckysox/challenge | /square_rectangle.py | 460 | 3.9375 | 4 | class Rectangle():
def __init__(self,width,length):
self.width = width
self.length = length
def calculate_perimeter(self):
return self.width * 2 + self.length *2
class Square():
def __init__(self,s1):
self.s1 = s1
def calculate_perimeter(self):
return self.... |
6a6ef57648793c83f38e013952b5c43d963373e4 | XVXVXXX/Algorithms | /Sort/Shell.py | 604 | 3.6875 | 4 | # 希尔排序
class Shell:
def sort(self, a):
length = len(a)
h = 1
while (h<h//3):
h = h*3+1;
pass
while (h>=1):
for i in range(h, length):
for j in range(i, h-1, -1*h):
if a[j] < a[j-h]:
a[j],... |
799905b815e20ad16ee9530ddbe00ca1d2e25271 | BugHunters-bug/AlgorithmBank | /Armstrong Number/Amrstrong.py | 318 | 4.09375 | 4 | sum=0
def check_ArmstrongNumber(num):
global sum
if (num!=0):
sum+=pow(num%10,3)
check_ArmstrongNumber(num//10)
return sum
num=int(input("Enter a number:"))
if (check_ArmstrongNumber(num) == num):
print("It's an Armstrong Number.")
else:
print("Not an Armstrong Number.") |
50efb2948edaa25c1306187cf0c7fb7d84689503 | Zuiveraar/Proyectos-y-trabajos-Codecademy- | /censor_dispenser/censor_dispenser.py | 1,790 | 3.6875 | 4 |
# These are the emails you will be censoring. The open() function is opening the text file that the emails are contained in and the .read() method is allowing us to save their contexts to the following variables:
email_one = open("censor_dispenser/email_one.txt", "r").read()
email_two = open("censor_dispenser/email_tw... |
7c510534efd57b1a5fb4ed68703e3b0a6e006688 | pedroceciliocn/programa-o-1 | /monitoria/prova 1/q_2_2020_3_ordenar_negativos.py | 1,294 | 4.28125 | 4 | """
Questão 2 – Faça um programa Python para ler uma seqüência de números inteiros
negativos – a leitura para quando um número não negativo for lido. No entanto, o usuário
só deve poder digitar no máximo 300 números negativos. O programa deve imprimir as
seguintes informações como resultado (nesta ordem):
• Os núme... |
cfe8b83a560d9c8ab49a10032d54c6fc5df22def | AdamZhouSE/pythonHomework | /Code/CodeRecords/2422/58575/317908.py | 156 | 3.9375 | 4 | n=int(input())
nums=input()
if nums=="3 1 4 2 5":
print(1)
print("1 5")
elif nums=="2 4 1 5 3 6 7 8":
print(2)
print("2 6")
print("1 2") |
8b6c344ae4259e16250f211e0add96d2ff2187f1 | timxag/CG | /lab1.py | 814 | 3.71875 | 4 | import sys
import string
import matplotlib
import matplotlib.pyplot
import numpy
x_value = list()
y_value = list()
yy_value = list()
xx_value = list()
def func(a, x):
return numpy.sqrt(x**2 * numpy.sqrt((a - x) / (a + x)))
def funcc(a,x):
return -numpy.sqrt(x**2 * numpy.sqrt((a-x)/(a+x)))
A = f... |
49f715f0c3904a26ea675502e2ebb377eb3fe2ae | Olu-wafemi/First-repository-at-Dsc | /day4.py | 432 | 3.84375 | 4 | def bits_of_gray(gray):
'''This programme returns a list of gray codes in which every succesive pair of numbers differs in only one bit'''
if gray == 0:
return ['']
conv = bits_of_gray(gray-1)
print(conv)
conv_2 = conv.copy()
print(conv_2)
conv = ['0'+ i... |
c533dc67e752b8341030cd053ebd702c0666ae84 | CaptTeemo/DeepLearning | /exercise1.py | 646 | 3.546875 | 4 | # Exercise 1.
# Generate ten images with different gray levels of foreground and background and label images.
import numpy as np
import matplotlib.pyplot as plt
import pylab
from matplotlib.colors import NoNorm
def createImage(foreground):
im_image =100*np.ones((28,28), dtype=np.uint8)
im_image[1:3, 1:3] = for... |
33f5d99e0e576059a803481e6d157c086d4e44ff | lizzzcai/leetcode | /python/backtracking/0980_Unique_Paths_III.py | 4,628 | 3.921875 | 4 | '''
04/03/2020
980. Unique Paths III - Hard
Tag: Backtracking, DFS
On a 2-dimensional grid, there are 4 types of squares:
1 represents the starting square. There is exactly one starting square.
2 represents the ending square. There is exactly one ending square.
0 represents empty squares we can walk over.
-1 repr... |
e7d4c031a8efbc287cff02b7088631100deecbe9 | petiatodorova/PythonFundamentals | /conditional-statements/world_swimming_record.py | 392 | 3.828125 | 4 | world_record = float(input())
distance = float(input())
time_for_one_meter = float(input())
count_delay = distance // 15
ivans_time = distance * time_for_one_meter + count_delay * 12.5
if ivans_time < world_record:
print(f'Yes, he succeeded! The new world record is {ivans_time:.2f} seconds.')
else:
print(f'No... |
e511b359a1d0e334f3e48a45c80e34bf64824ff7 | sanamsanam/Python-Excercies- | /palindrome.py | 148 | 4.0625 | 4 | def is_palindrome(word):
word2 = ''.join(reversed(word))
if word == word2:
return True
else:
return False
print(is_palindrome('Deleveled'))
|
784f92770e500f93478074c5c507a20e60c22d37 | adalbertobrant/consultaUnimed | /unimed.py | 2,931 | 3.5 | 4 | #!/usr/local/bin/python
# -*- coding: utf-8 -*-
#
# Versão para Python 2 não funciona no Python 3
#
import os, sys
import tweepy
import re
import time
import random
from random import randint
from random import uniform
from random import random
from mechanize import Browser
from keys import keys
# Endereço a ser li... |
516f6ebaa4790403bda322dd8c24d6e58d4f6039 | dkurth/projecteuler | /prob10.py | 389 | 4.125 | 4 | import math
def is_prime(n):
r = math.sqrt(n)
for p in primes:
if p > r:
return True
elif n % p == 0:
return False
return True
if __name__ == "__main__":
primes = [2]
maxval = 2e6
x = 3
while x < maxval:
if is_prime(x):
... |
f5163d1bb284ddcb4e887768c881053ecea4bd14 | AleBark/Python-Basics | /list_03/ex_01.py | 1,045 | 4.40625 | 4 | # -*- coding: utf-8 -*-
# Develop an algorithm that informs your electoral situation, knowing that:
# A person who has < 16 years do not vote
# Voting is optional for adults between 16 and 18, or over 65 years
# Voting is mandatory for adults between 18 and 65
def main():
age_input = input("Input: ")
if age_... |
2f6a844a24b799c6f0a424429f13612daab8e51f | Bhakti110/MyPPLAssignments | /geometric.py | 261 | 3.6875 | 4 | if __name__ == "__main__" :
a = float(input("Enter first term of GP \n"))
r = float(input("Enter common ratio of GP \n"))
i = 1
print(a)
print("\n")
while i < 10 :
a = a * r
print(a)
print("\n")
i = i + 1
|
457f9ae3deaa23a8c2fbaa44534c9b94935744e3 | lastsymphonia/CS50AI | /knights/puzzle.py | 2,923 | 3.578125 | 4 | from logic import *
AKnight = Symbol("A is a Knight")
AKnave = Symbol("A is a Knave")
BKnight = Symbol("B is a Knight")
BKnave = Symbol("B is a Knave")
CKnight = Symbol("C is a Knight")
CKnave = Symbol("C is a Knave")
# Puzzle 0
# A says "I am both a knight and a knave."
Line_A_zero = And(AKnight, AKnave)
knowledge... |
0db46bb92174e475888e265b657786d5f4260bcb | nitebaron/practise | /monte_carlo_integration.py | 1,726 | 4.5 | 4 | #The Monte Carlo method is can be used to integrate functions, even when the
#functions are difficult or impossible to integrate analytically. The basis
#of the method is to surround the function to be integrated by a simple volume
#then generate sets of random numbers inside this volume and calculate the per-
#cent... |
f90e3cb15586c9422dab87fc00b447b642449203 | candlelogbi/100DProjects | /Day15.py | 477 | 3.96875 | 4 | fruit=["orange","apple","banana"]
print(len(fruit))
fruit.append("pineapple")
print(fruit)
fruit.insert(3,"strawberries")
print(fruit)
fruit.remove("orange")
print(fruit)
fruitList=fruit.copy()
fruit.pop()
print(fruit)
print(fruitList)
flist=list(fruit)
print(flist)
#remove with index or last item
fruit.... |
36629b29b00afe409474c3b82371050eca44dfc2 | makrandp/python-practice | /Other/CoderPro/AddTwoLinkedLists.py | 2,773 | 3.984375 | 4 | '''
#4
Given two numbers represented in reverse as linked list, add the two numbers together. Return in the form of a reversed linked list. Assuming no leading zeros
'''
from typing import List
# Recurse down to the bottom, recurse back up adding the numbers together
# 345 + 2567 =
# 5 -> 4 -> 3
# 7 -> 6 -> 5 -> 2
#... |
d068cfe95875e810041857798e940ae0ade7a5b9 | jwyx3/practices | /python/two-strings-are-anagrams.py | 659 | 4.03125 | 4 | class Solution:
"""
@param s: The first string
@param b: The second string
@return true or false
"""
# hash or sorting
# What is Anagram?
# - Two strings are anagram if they can be the same after change the order of characters.
# not rotate
# time: O(n)
# space: O(1)
de... |
5ff624dfd1eb64cbb8de09c83a03607fc6de5a75 | stephen-smurphy/image-processing | /opencv/draw_shapes.py | 692 | 3.5 | 4 | import cv2 as cv
import numpy as np
#create blank image
blank = np.zeros((500, 500, 3), dtype='uint8')
cv.imshow('Blank', blank)
#Paint Image a certain colour (cyan)
#blank[:] = 255, 255, 0
#cv.imshow('Painted', blank)
#Draw a rectangle
#cv.rectangle(blank, (0,0), (250,250), (0,255,0), 2)
#cv.imshow('Rectangle', bl... |
ef76e594638b0fee42f5c0780489211a8512f9c0 | Rostislav9821/Lab_rab_11 | /ind1.py | 329 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- config: utf-8 -*-
# Напечатать в обратном порядке последовательность чисел, признаком конца которой
# является 0.
def prt():
n = int(input())
if n == 0:
return
prt()
print(n)
prt() |
3ec0c221e6ff2774b0c8fce1fad4ef58acb89b34 | dundunmao/lint_leet | /mycode/lintcode/advance/3:heap&deque&windows/81 data-stream-median.py | 1,284 | 3.828125 | 4 | import heapq
class Solution:
"""
@param nums: A list of integers.
@return: The median of numbers
"""
def __init__(self):
self.num_of_ele = 0
self.min_heap = []
self.max_heap = []
def medianII(self, nums):
result = []
for j in range(0, len(nums)):
... |
d546f2cfcb8cb66eef85e96cc36eddde3013cfef | bharrison21/Final-Project | /calculations.py | 1,201 | 3.5625 | 4 | import json
import sqlite3
import os
import requests
import math
#This file joins table NBA_Stats and NBA_Season to calculate what percentage of a team's points that a player had
#The calculations are written to a file called calculations.txt
def table_join():
path = os.path.dirname(os.path.abspath(__file__))
... |
c2825c9a2209dfd3461d3bcd414d723a4a514551 | DaianaMicena/fiap-exercicios-python | /Exercicios_Python/exercicio26.py | 298 | 3.921875 | 4 | frase = str(input('Digite uma frase')).upper()
qnt = frase.count('A')
print(f'A quantidade da letra A que aparece é {qnt}')
primeiro = frase.find('A')
print(f'A primeira letra A aparece na {primeiro} posição')
ultima = frase.rfind('A')
print(f'A ultima letra A aparece na {ultima} posição')
|
6f2f2be055be6d067f8842cbc77d27609dce9374 | OmerD79/net4u | /Lotto.py | 3,198 | 3.953125 | 4 | import random
from time import sleep
def manual_lotto(NoOfPlays):
lottoform = []
while len(lottoform) < NoOfPlays:
Entry = []
while len(Entry) < 6:
num = int(input('Enter num between 1 - 37: '))
while num < 1 or num > 37 or num in Entry:
print('... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.