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 |
|---|---|---|---|---|---|---|
0022ccacb12aa987acb3530c0af49c45b1cbf1f9 | sidprobstein/xtractemail | /extractemail/extractemail.py | 4,509 | 3.546875 | 4 | #############################################
# extractemail
# extracts email messages from text files and writes them into XML records with fielded metadata.
# assumptions:
# input is a file or list of files which must be text format
# output is named for the original but .xml
# metadata comes first, at most one fie... |
486a0df9f107d080ac622d0584789281209fb26c | thatshubham/pythonbasics | /guessthenumber.py | 555 | 4.03125 | 4 | #guess the nummber game\
import random
n = 0
print('Enter the name of the participant')
name = input()
print('Hello ' + name + '\n')
def inputnumber():
print('Enter the number')
n = input()
guess(n)
def guess(n):
try:
a = random.randint(1, 5)
if int(n)==a:
print('Congr... |
cb68a33602b05c94c043693f88cada20ae05b881 | tanyabudinova/hack-bulgaria-Python101 | /week3_2/music_library/test_utils.py | 1,500 | 3.5625 | 4 | import unittest
from utils import parse_length
class TestParseLength(unittest.TestCase):
def test_length_with_hours(self):
length = "3:24:34"
result = parse_length(length)
self.assertEqual((3,24,34), result)
def test_length_with_miutes_over_an_hour_without_hours(self):
length... |
dc823afc0ad87cfe8787e4dd4d179909c22fd2fb | tanyabudinova/hack-bulgaria-Python101 | /week6/Decorators/test_accepts.py | 1,348 | 3.671875 | 4 | import unittest
from accepts import accepts
class TestAccepts(unittest.TestCase):
def test_with_zero_arguments(self):
@accepts()
def print_correct():
return "Correct"
result = print_correct()
self.assertEqual("Correct", result)
def test_with_one_argument(self):
... |
8b9c3749e535c4a16ffb355b999c7ee242bbc90a | mike-stephens/foobar-with-google | /level-3/doomsday-fuel/solution_doomsday_fuel.py | 6,885 | 3.828125 | 4 | """
The first test case for this problem seems pretty straightforward. You can
follow along in your head or on paper and arrive at the answer fairly easily.
But then you hit the second test case. And you probably notice pretty quick
if you were to implement the same solution in your head you end up with what
seems lik... |
71372d46a618b89c67a048588bf44ca77d68df2f | qcri/RDFframes | /benchmark_DBpedia2020/Q11-RDFframes.py | 635 | 3.515625 | 4 |
''' Get the list of athletes in DBpedia. For each athlete, return his birthplace and the number of players who were born in the same place. '''
from rdfframes.knowledge_graph import KnowledgeGraph
graph = KnowledgeGraph(graph_name='dbpedia')
def expand_groupby_expand():
basketball_palyer = graph.entities('db... |
f37864c3a28f414c903e51ad068b82494388400f | qcri/RDFframes | /benchmark_DBpedia2020/Q1-RDFframes.py | 883 | 3.5 | 4 | ''' Get a list of films in DBpedia. For each film, return the actor, language,
country, genre, story, studio in addition to the director, producer, and title (if available). '''
from rdfframes.knowledge_graph import KnowledgeGraph
graph = KnowledgeGraph(graph_name='dbpedia')
def expand_optional():
Films = ... |
09dfd8fe1613a0bd753cbb9dbf1ce50585e725c4 | vgk616/sdseml_online_exercises | /KARL/Exercise_5_warmup.py | 741 | 3.953125 | 4 | class Clock:
def __init__(self, n):
self.n = n
self.hours = 0
self.cycles = 0
# the tick method adds one hours and if the clock completes one full cycle, it adds 1 to cycle
def tick(self):
self.hours += 1
self.cycles = self.hours // self.n
# the __eq__ dunder met... |
f3c971024787c04b8ab26f8b1ea854ca7d551196 | AshimaSEthi/50-Days-50-Python-Programs | /program5.py | 281 | 4 | 4 | #Swapping of Two numbers
num1 =4
num2 = 5
print('The value of num1 = ',num1)
print('The value of num2 = ',num2)
#how to variable assignment works in python
temp = num1
num1 = num2
num2 = temp
print('The value of num1 = ',num1)
print('The value of num2 = ',num2)
|
dc3c3b9664b03420d7e9fe5234b088b766fe7a05 | AshimaSEthi/50-Days-50-Python-Programs | /program9.py | 187 | 4.4375 | 4 | #To check if num entered is even or odd
input_entered = int(input("Enter the Number: "))
if input_entered %2 ==0:
print("It is an Even Number")
else:
print("It is an Odd Number") |
a1c6f06658a58964b48cd6f26f950b4929061da2 | jenny-df/meet2017y1lab3 | /specialCharacters.py | 299 | 3.765625 | 4 | print (" \"Hi!\" ")
print (" \'Hello!\' ")
print (" \\MEET\\Module1\\")
print ("first \n second")
print ("no tab \t tab")
print("Instructor Alex asks, \"What are you learning today?\" \n The students reply, \'We are learning how to print!\' We can type print (“\\Day1\\”) to print out \Day1\.")
|
491f89ec2fec9d6ac6c2656c02bd82b019cf9612 | mchalecki/Computer_Graphics | /Dithering/src/color.py | 912 | 3.84375 | 4 | class Color:
def __init__(self, red=0, green=0, blue=0):
self.red = int(red)
self.green = int(green)
self.blue = int(blue)
def __str__(self):
return f"Color: r={self.red},g={self.green},b={self.blue}"
def __iadd__(self, other):
self.red += other.red
self.gre... |
150747e7e7b6a368e0ac7af28d4a4d10358acdbb | mohitsharma2/Python | /Book_program/max_using_if.py | 413 | 4.59375 | 5 | # Program to accept three integers and print the largest of the three.Make use of only if statement.
x=float(input("Enter First number:"))
y=float(input("Enter Second number:"))
z=float(input("Enter Third number:"))
max=x
if y>max:
max=y
if z >max:
max=z
print("Largest number is:",max)
"""
output===>
Ent... |
0b17461c510d7fccb714c44cc312f16468c0f506 | mohitsharma2/Python | /03/city_temp.py | 118 | 3.71875 | 4 | #Temperature of City
temp=int(input('temperature of your city in Degree Celsius of the day'))
print(temp,"\u00b0 c")
|
5d7e66d5a3a836b39f5d8048299f5e6e057d2eec | mohitsharma2/Python | /game_of_rock_paper_scissors.py | 387 | 3.78125 | 4 | while(True):
inp=input('Enter only choice among rock,paper or scissors')
import random
from random import randint
a=random.choice(['rock','paper','scissors'])
print(a)
if inp in ['rock','paper','scissors']:
if inp==a:
print('wins')
elif inp!=a:
print('lost... |
bcccc5ce0b84d9da2e6c63c794973fb19ff140ef | mohitsharma2/Python | /circle.py | 198 | 4.21875 | 4 | # Area and Perimeter of Circle
radius=float(input('Take the radius of the circle'))
import math
from math import pi
math.pi
area=(pi* radius* radius)
print(area)
peri=(2 * pi * radius)
print(peri)
|
d2db2c0608a6ad6ca1f9c423c55ec4aeffef3939 | mohitsharma2/Python | /Book_program/divisor.py | 1,068 | 4.28125 | 4 | #program to find the multiles of a number(divisor) out of given five number.
print("Enter the five number below")
num1=float(input("Enter first number:"))
num2=float(input("Enter second number:"))
num3=float(input("Enter third number:"))
num4=float(input("Enter fourth number:"))
num5=float(input("Enter fifth... |
060676798aa4f01925b1d6912524b6801677d89c | mohitsharma2/Python | /01/heartrate_cal.py | 395 | 3.84375 | 4 | #Target Heart Rate Calculator
age=21
your_Maximum_Heart_Rate=220-age
print(your_Maximum_Heart_Rate,'Beats per minute')
Lower_end_of_your_Target_Heart_Rate= int(70/100*(your_Maximum_Heart_Rate))
print(Lower_end_of_your_Target_Heart_Rate,'Beats per minute')
Higher_end_of_your_Target_Heart_Rate=int(85/100*(your_Maximum_He... |
e8fc3a72648cfd8d9b857012a27031e7a08b8357 | mohitsharma2/Python | /Blackjack.py | 1,629 | 4.3125 | 4 | """
Name:
Blackjack
Filename:
Blackjack.py
Problem Statement:
Play a game that draws two random cards.
The player then decides to draw or stick.
If the score goes over 21 the player loses (goes ‘bust’).
Keep drawing until the player sticks.
After the player sticks draw two computer... |
8a7ef4cda31e1319f74f559f6026b5ffed9ce49f | mohitsharma2/Python | /automobile.py | 2,148 | 3.984375 | 4 | """
Code Challenge
Name:
Automobile Analysis
Filename:
automobile.py
Problem Statement:
(Automobile.csv)
Read the Automobile.csv file and perform the following task :
1. Handle the missing values for Price column
2. Get the values from Price column into a numpy.ndarray
3. Calculate t... |
3817d594c6261e8d7a51bd820a4c0ed2bfe36dd0 | mohitsharma2/Python | /Book_program/sqrt.py | 930 | 4.25 | 4 | # program to calculate and print roots of a quadratic equcation : ax^2 + bx + c=0 (a!=0)
import math
print("for quadratic equcation : ax^2 + bx + c=0,enter cofficient below:")
a=int(input("Enter a:"))
b=int(input("Enter b:"))
c=int(input("Enter c:"))
if a==0:
print("Value of 'a' should not be zero.")
prin... |
0f1f74514cd78b6f952e24f923975d82a18e1260 | mohitsharma2/Python | /Book_program/identify_character.py | 474 | 4.3125 | 4 | """
program to print whether a given character is an uppercase or
a lowercase character or a digit or any other special character.
"""
inp1=input("Enter the Character:")
if inp1>='A' and inp1<="Z" :
print("You entered upper case character.")
elif inp1>='a' and inp1<='z' :
print("You entered lower case c... |
260ea2d6275282bb8ecc34d2488bbdca52459a45 | mohitsharma2/Python | /gravity_cal.py | 224 | 4.21875 | 4 | # Gravity Calculator
Acceleration=float(input('enter the Acceleration in m/s^2'))
Time=float(input('enter the time in seconds '))
distance=(Acceleration*Time*Time )/ 2
print('object after falling for 10 seconds=',distance)
|
375b7134fc301b03cbf620741f0c3fb5e7eb20d9 | mohitsharma2/Python | /Book_program/index_duplicate.py | 262 | 3.84375 | 4 | #find out index of duplicate number
list2=[]
list1=[10,20,30,10,40,50,10,60,10]
for i in range(len(list1)) :
if list1[i]==10:
list2.append(i)
if len(list2)>1:
print(list2[1:])
else:
print('no duplicates ')
"""
output===>
[3, 6, 8]
""" |
43063e3e48b4b7316c4fc6eddc1fabf0855ce41a | maryign/scientific_work_university | /project/modules/frequency_dictionaries.py | 2,184 | 3.515625 | 4 | #подсчет количества одинаковых элементов в массиве
import re
def counting_the_number(setel, arrel):
counts=[]
for setstr in setel:
count = 0
smallarr=[]
for el in arrel:
if setstr==el:
count = count+1
smallarr.append(setstr)
smallarr.append(co... |
ddbb72331e6dcbbbb5d3bca9968cde6013d12eb3 | mischievousjayden/ClassifyingDriverBehavior | /src/util/fileutil.py | 524 | 3.5 | 4 | from os import listdir
from os.path import isfile, join
import csv
def getAllFileNames(path, suffix=""):
return [join(path, f) for f in listdir(path) if isfile(join(path, f)) and f.endswith(suffix)]
def readDataFile(filename, delimiter=","):
with open(filename, 'r') as f:
reader = csv.reader(f, delimi... |
2f3e36b57e85d50a337d2d1bb46d2aedca26d0f1 | LongyuYang/A-Simple-C-compiler | /Tree.py | 643 | 3.5 | 4 |
class node:
def __init__(self):
self.parent = None
self.children = []
self.data = None
self.attributes = {}
def setData(self, data):
self.data = data
def setParent(self, parent):
self.parent = parent
def addChildren(self, child):
... |
7d0a25ede3385c817646eef44f996f788a740f50 | JennyJorquera/Septiembre30_007 | /Ciclo1.py | 594 | 3.96875 | 4 | #crear ciclo for que permita ingresar n temperatura donde n es un numero ingresado por teclado
#mostrar cuantas temperaturas estan por sobre 0 y cuantas temperaturas estan bajo o igual a 0
sobrecero=0
bajocero=0
veces=int(input("Cuantas temperaturas quiere ingresar?: "))
for i in range(veces):
tempe=float(input("In... |
8efbeb29e1c23bf17d63c1aa64ce2e5b6870d5cd | bruno41bruno/InterfaceMySql | /database/bd_cod.py | 987 | 3.84375 | 4 | """ import sqlite3
parametro = "cliente = bruno"
filtro = "cliente"
banco = sqlite3.connect("data_base")
cursor = banco.cursor()
cursor.execute("SELECT * FROM clientes")
print(cursor.fetchall()) """
#criarTabela
""" cursor.execute("CREATE TABLE clientes (nome text, data text, operacao text, valor_total text, val... |
183da0636d49c9495ef930baa7ee96c2e775d58c | shubhangsrikoti/lab3-python | /main.py | 515 | 3.828125 | 4 | # Author: Shubhang Srikoti svs6959@psu.edu
# Collaborator: Geng Niu gjn5124@psu.edu
# Collaborator: Max Skeen - mls6984@psu.edu
# Collaborator: Ananya Ashwinikumar ava6290@psu.edu
# Section: 4
# Breakout Room: 7
def sum_n(num):
if num >= 1:
return num + sum_n(num - 1)
else:
return 0
def print_n(string... |
a954893cead51d582586f30411a57d7021f87848 | Praneeth2k/AI_lab | /Lab test - 1/tic-tac-toe.py | 5,070 | 4.15625 | 4 | #Implement Tic-tac-toe using a 2-agent algorithm (Computer Vs Computer)
#Board
board = ["-", "-", "-",
"-", "-", "-",
"-", "-", "-"]
game_still_going = True
winner = None
# Tells us who the current player is (Computer 1 or Computer 2)
current_player = "C1"
#Tells us what symbol the current player... |
b729166accf54e0e1d16b580423ec2fa771ead1d | dallmeyer/lc | /SqrtX/SqrtX.py | 475 | 3.625 | 4 | class Solution:
def mySqrt(self, x: int) -> int:
lo = 0
hi = x
while lo < hi:
mid = int(lo + (hi-lo)/2)+1
#print(lo,mid,hi)
if mid*mid <= x:
# mid is a lower bound for our answer, lets see if theres a better larger ans... |
4dd7c5bb8b237a9b2c4e7a0150acca6f1d6795c8 | marcemq/algorithms | /programming/strings.py | 822 | 3.734375 | 4 | # A set of strings programming problems
import sys
import string
import operator
def getFisrtCharThatAppearsOnce(myString):
""" Get the first char that appears once in the provided string.
Only alphabetic chars are considered. """
myString = "".join(myString.lower().split())
charDict = {key:[0, 0] for... |
071daf9178cb210ff8334eb8753239deb459f973 | marcemq/algorithms | /dataStructures/binarySearchTree.py | 2,777 | 3.984375 | 4 | import sys
class Node():
"""
Tree node: holds a left and right childs along with data
"""
def __init__(self, data=None):
""" Node constructor """
self.data = data
self.left = None
self.right = None
def insert(self, data):
""" Insert new node with data """
... |
112e25759e5b99582eb32ecb9dfcaa03da9a964e | ashwin015/Ashwin | /p21.py | 187 | 3.75 | 4 | x1,z1=map(int,input().split(' '))
x2,z2=map(int,input().split(' '))
x3,z3=map(int,input().split(' '))
if (x1==x2 and x2==x3) or(z1==z2 and z2==z3):
print("yes")
else:
print("no")
|
4576921adbc2a335f003fbaa121adb47667d9a1a | FranklinSuvi/CISCO | /rahugup4/Advertise-predict.py | 1,641 | 3.640625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn import preprocessing, model_selection as cross_validation, svm
csv_file = "/Users/rahulgupta/Git/machine_learning/math-for-mlv1/rahul/Advertising.csv"
df = pd.read_csv(csv_file)
data_to... |
cfaa8f2bb1b2a1ee44a696bacfbf58b607c897e4 | FranklinSuvi/CISCO | /siddhartha/Advertising_prediction.py | 2,593 | 3.65625 | 4 | # -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
data = pd.read_csv("Advertising.csv")
data.head()
# use multivarite linear regression to predict the
# a... |
eb14741707c49bc5a40e8bd5c6ca9c4c10987a3e | RufailG/Python | /es_5.py | 424 | 3.828125 | 4 | '''
Scrivere un programma che inserisca una parola in input e ne visualizzi i primi tre caratteri seguiti
da tre punti ancora seguiti dagli ultimi tre caratteri(es. Giornata visualizzazione Gio…ata)
'''
#richiesta parola all'utente
parola = input('inserisci una parola: \n')
#creazione nuova stringa
new_parola = paro... |
0849109c16321203deb0e9517f34d13995915f57 | compwizdave/hackerrank-python | /30-days-of-code/day28 | 416 | 3.5 | 4 | #!/bin/python3
import sys
import re
names=[]
N = int(input().strip())
for a0 in range(N):
firstName,emailID = input().strip().split(' ')
firstName,emailID = [str(firstName),str(emailID)]
fn = re.compile("[a-z]{1,20}")
ei = re.compile("[a-z.]{1,40}@gmail.com")
if fn.match(firstName) and e... |
b5258f9fbc8dea136a83cb2a6520c18f6b1c79b6 | jokerGin/Coin-game | /coingame.py | 314 | 3.75 | 4 | coin = 100
l = ['head', 'tail']
while True:
from random import choice
guess = input('Guess head or tail\n')
ans = choice(l)
if guess.lower() == ans:
coin += 9
print(coin)
else:
coin -= 10
print(coin)
if coin <= 0 or coin >=200:
print('Game over, coin balance, ', coin)
break
|
2d17fd6fd346fd824a4a3379656abcd803a535c8 | Josephcheng09/302-pair-program-tax-system | /PairProgramming Assignment/taxsystem_1.2.py | 4,112 | 3.875 | 4 | import sys
import tkinter
import math
basic_tax_reduction = int(132000)#
mpf_reduction = int()
tax = int()
income = int()
x = int()
def isNumber(s):
try:
float(s)
return True
except ValueError:
return False
def isInt(s):
try:
int(s)
return True
except Val... |
f4a84d8caaf8308faa1e860045650fb61d5c00f2 | therealdandong/DojoAssigments | /Python/python_stack/python_OOP/oop_text.py | 584 | 3.6875 | 4 | class users(object):
def __init__(self, name, email):
self.name = name
self.email = email
self.logged = True
def login (self):
print self.name + "welcome you are login in now."
self.logged = True
return self
def logout (self):
print self.name + "sorry ... |
777e187a33538c76282ba81db24ea42c7f1ab06e | atiluj/University | /SEM1/Python/lista8/l8z2.py | 559 | 3.671875 | 4 | from collections import defaultdict as dd #przypisanie do czegos wartosci
def wystapienie_liter(slowo):
zliczacz = dd(lambda:0)
for e in slowo:
zliczacz[e] +=1
return zliczacz
def ukladalne(slowo1,slowo2):
zliczacz1 = wystapienie_liter(slowo1)
zliczacz2 = wystapienie_liter(slowo2)
for ... |
071c56ca9ff91fe36538d4e52f1008c20eea509d | atiluj/University | /SEM1/WDI/lista11/zad1.py | 2,692 | 3.890625 | 4 | class Node:
def __init__(self, value):
self.val = value
self.left = None
self.right = None
'''
class BTS:
def __init__(self):
self.root = None
def setRoot(self, val):
self.root = Node(val)
def insert(self,val):
if(self.root is None):
self.set... |
ce3c4f4e42cac213007b2953573f8873088c75e0 | atiluj/University | /SEM1/Python/lista2/l2z2.py | 378 | 3.9375 | 4 | def koperta(n):
for i in range(2*n+1):
if i==0 or i==2*n:
print((2*n)*"*",end="")
else:
print("*",end="")
for j in range(1,2*n):
if j==i or j==(2*n-i):
print("*",end="")
else:
print(" ",end=""... |
2c0293485305f5fa836fb898f0099b4b752408b1 | egch/helloPython | /src/leetcode/2023/BinaryTreePaths.py | 938 | 3.8125 | 4 | # https://leetcode.com/problems/binary-tree-paths/description/
import TreeNode
from typing import Optional, List
class BinaryTreePaths:
def binaryTreePaths(self, root: Optional[TreeNode]) -> List[str]:
my_list: List[str] = []
self.dfs(root, my_list, '')
return my_list
def dfs(self, ro... |
2c894119b5321d953fa1346d722d42f190de8c38 | alexdavidkim/Python3-Notes | /numeric_types/booleans.py | 2,949 | 4.53125 | 5 | # All objects in Python have a Truthyness or Falsyness. All objects are True except:
# None
# False
# 0
# Empty sequences (list, tuple, string, etc)
# Empty mapping types (dictionary, set, etc)
# Custom classes that implement a __bool__ or __len__ that returns False or 0
# Therefore, every built... |
31981e806a88845bb143f49d24aaab942b79b990 | alexdavidkim/Python3-Notes | /modules_packages/datetime_pytz.py | 1,914 | 4.34375 | 4 | # https://howchoo.com/g/ywi5m2vkodk/working-with-datetime-objects-and-timezones-in-python
import datetime
import pytz
from pprint import pprint
# -------------- Dates -------------------
dean_birthday = datetime.date(2017, 5, 30)
# print(specific_date)
today = datetime.date.today()
# print(t... |
e08370a547d275fad284c9bb9d0ea01d3b340d40 | alexdavidkim/Python3-Notes | /functions/docstrings_annotations.py | 1,096 | 3.84375 | 4 | # Docstring - __doc__ in the function class. First line in a function and must be a string. Convention is to use a multi-line string even if only on a single line. Docstrings and annotation have ZERO to do with the actual code (even though it does get compiled at runtime).
# def my_func(a, b=True):
# """returns a i... |
c088211b8c94caf091b5c7817ac6259c7038660e | ranjmishra/part_manager_python | /part_manager.py | 2,020 | 3.546875 | 4 | from tkinter import *
def populate_list():
print('Populate')
def add_item():
print('Add')
def remove_item():
print('Remove')
def update_item():
print('Update')
def clear_text():
print('Clear')
# Create window object
app=Tk()
# Part
part_text = StringVar()
part_label=Label(app,text='Part Nam... |
b6d2a50e11d715fcac737bb846468cd7b312aef3 | Shoeboxam/Tensor_CAS | /app.py | 711 | 3.5 | 4 | import random
from Tensor import *
# Make a set of indices with random size between 1 and 10
ind = [Index(random.randint(1, 10)) for i in range(4)]
print('Initial Indices: ' + str(ind))
print()
# initialize tensors
A = Tensor(*ind[:2])
B = Tensor(*ind[1:3])
C = Tensor(*ind[2:])
print('Tensor A: ' + str(A))
print('Te... |
b6bdaa9f771fa9d8cd2fc102b2d27c7777ea50f6 | meriengel/PRG105-1 | /calories.py | 971 | 3.828125 | 4 | def calculatecaloriesfromfat(fatgrams):
caloriesfromfat = fatgrams * 9
return caloriesfromfat
def calculatecaloriesfromcrabs(crabsgrams):
caloriesfromcrabs = crabsgrams * 4
return caloriesfromcrabs
def calculatecaloriesfromprotein(proteingrams):
caloriesfromprotein = proteingrams * 4
return ... |
d320517aca44abba0f83e525f446fba2a0ca3425 | Cruzado77/Sistema-de-Gerenciamento-de-Voos | /search.py | 3,093 | 3.5 | 4 | # Desenvolvido por:
# JUAN JERRAH BARRETO DE OLIVEIRA
# RAPHAEL RODRIGUES DE SENA
import os
import lib
from distance import Distance
class Routes:
vet = []
caminhos = []
correspondencias = []
def __init__(self,raiz):
self.raiz = raiz
def check_road(self,node,destino):... |
3a481996e2ab64d3f486977bc0e5b016b09999a2 | saranyab9064/30_Day_Leetcode_Challenge | /23_Bitwise_AND_of_Numbers_Range.py | 849 | 3.671875 | 4 | # ============================================================================
# Name : 23_Bitwise_AND_of_Numbers_Range.py
# Author : Saranya Balakrishnan
# Mail Id : saranyab0925@gmail.com
# ============================================================================
"""
Given a range [m, n] where 0 <=... |
6dee6c0b23b41b0d00c08f91fb09155b330a348d | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 4/ejercicios-clase-04-1bim-JamilErasmo/Ejemplo02/Ejemplo03.py | 238 | 3.84375 | 4 | nombre = input("Ingrese nombre del estudiante: ")
apellido = input("Ingrese el apellido del estudiante: ")
nacimiento = input("Ingrese la fecha de nacimiento: ")
print("Datos del estudiante\n%s\n%s\n%s\n" %(nombre, apellido, nacimiento)) |
4de3d0db060775aea5962cd89151643d8478f4db | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 4/taller4-JamilErasmo/EjerciciosCuatro/Ejercicio2.py | 279 | 3.828125 | 4 | gastosh1 = float(input("Ingresar los gastos del hijo 1: "))
gastosh2 = float(input("Ingresar los gastos del hijo 2: "))
gastosh3 = float(input("Ingresar los gastos del hijo 3: "))
total =gastosh1 + gastosh2 +gastosh3
print("Los gastos totales de los 3 hijos es: %.2f$\n"%(total)) |
13af4553ad6e0c2f047724f3544170538a145d0b | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 5/taller5-JamilErasmo/Problema2.py | 324 | 3.671875 | 4 | porcentaje = float (10)
cantidadR = float (input("Ingresar la cantidad requerida: "))
preciouni = float (input("Ingresar el valor unitario: "))
total = float (preciouni * cantidadR)
if cantidadR > 50:
descuento =( total * porcentaje)/100
total = total - descuento
print("El valor total a pagar es: %.2f$" %(tot... |
1dc63cb83ef19a77a09148bea12cd77b8e5b961f | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 7/ejercicios-clase-07-01bim-JamilErasmo/EjemplosFor/Ejemplo07.py | 223 | 3.828125 | 4 | for i in range(1,21,1):
print("Tabla de multiplicar del número %d\n"%(i))
for contador in range(1,10,1):
operación = i * contador
print("%d x %d = %d\n"%(i, contador, operación,))
print("\n") |
2a464aec82c53dc4fcba783a57009ff7f5351ba2 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 6/ejercicios-clase-06-1bim-JamilErasmo/ejemplos-while/Ejemplo03.py | 192 | 3.53125 | 4 | limite = 10
contador = 1
suma = 0
while contador <= limite:
suma = suma + contador
print("contador %d\n"%(contador))
contador = contador + 1
print("La suma final es: %d\n" %(suma)) |
d3f3649d7f47267a6f6261f0fe7f409db2b93f75 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 4/ejercicios-clase-04-1bim-JamilErasmo/Ejemplo02/Ejemplo04.py | 338 | 3.65625 | 4 | nombres = input("Ingrese sus nombres: ")
apellidos = input("Ingrese sus apellidos: ")
ciudad = input ("Ingrese el nombre de la ciudad: ")
pais = input("Ingrese el nombre del país: ")
nacimiento = input("Ingrese la fecha de nacimiento: ")
print("Datos de la persona:\n%s\n%s\n%s\n%s\n%s\n" %(nombres,
apellidos, ciudad, p... |
6b9f36c53bc6abbb62b9e0c7a360c923e2249212 | IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo | /semana 6/taller6-JamilErasmo/Problema5.py | 409 | 3.5625 | 4 | contador= 1
cadenaF = ""
while contador <=4:
nombre = input("Ingresar el nombre del estudiante: ")
promedio = float(input("Ingrese el promedio del estudiante: "))
if promedio >=7:
cadenaF = "%s\t%s\t%.2f\t%s\n" %(cadenaF, nombre, promedio, "Aprobado")
else:
cadenaF = "%s\t%s\t%.2f\t%s\n... |
06e474896c6b9c0d31e40956dea1c05312725d24 | lanjing1/pytesseractimage | /changingcolorspaces.py | 18,560 | 3.53125 | 4 | #!/usr/bin/python3
# -*- coding: utf8 -*-
# learn how to convert images from one color-space to another,like BGR<->Gray,BGR<->HSV etc
import cv2
import numpy as np
from matplotlib import pyplot as plt
flags = [i for i in dir(cv2) if i.startswith('COLOR_')]
print flags
green = np.uint8([[[0,255,0]]])
hsv_green = cv2... |
cacf29ed9cffc76af5698010b76922f7c5155c2d | Will019/test | /hello.py | 320 | 4.09375 | 4 | def hello(name,age):
if age < 18:
print("Hello %s, you are a kid!" % (name))
elif age < 50:
print("Hello %s, you are an adult!" % (name))
else:
print("Hello %s, you are ooooold!" % (name))
name=str(input("What is your name?: "))
age=int(input("How old are you?: "))
hello(name,age)
|
24c1e27df18ddd8b08179d12eb9305f73536ed80 | FomalhautA/Algs | /894-All_Possible_Full_Binary_Tree.py | 1,178 | 3.546875 | 4 |
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def allPossibleFBT(self, N):
"""
:type N: int
:rtype: List[TreeNode]
"""
res = []
if N... |
7b9c15af7e1b3fc0de9c7a45fcce3dfa087c2b1b | FomalhautA/Algs | /BST.py | 4,301 | 3.59375 | 4 | import queue
class Solution(object):
def pathSum(self, root, sum):
"""
:type root: TreeNode
:type sum: int
:rtype: int
"""
if root is None:
return 0
else:
return self.core(root, sum) + self.pathSum(root.left, sum) + self.pathSum(roo... |
4c3a855ec6706d63e58fc5dfe537d7b3c0a01813 | Danielarwj/CSE | /notes/Daniel Remington- Lucky 7's.py | 952 | 3.84375 | 4 | import random
amount = 15
print("Welcome to Lucky 7's. Here is the game where you constantly try to 'keep' your money")
bet = 1
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)
roll = dice1+dice2
rounds = 0
max_money = 15
max_rolls = 0
while amount > 0:
dice1 = random.randint(1, 6)
dice2 = random.rand... |
9b4fa46fffb333a08ee59a650cd6152e8bfbb92d | Danielarwj/CSE | /notes/Daniel Remington- Medium Challenges.py | 711 | 3.796875 | 4 | # This is challenge 5
def challenge1(radius):
return 3.14*(radius**2)
print(challenge1(1.1))
# This is challenge 6
def challenge2(radius):
return(4/3)*(3.14*(radius**3))
print(challenge2(5))
# This is challenge 7
def challenge3(number):
return number+(number+number)+(number+number+number)
print(... |
f1c49d6cfef1a41b998a65747ccc7413be74fee7 | Danielarwj/CSE | /notes/Daniel Remington- Ocean's 28- Validator.py | 1,862 | 3.703125 | 4 | # import math
import csv
def validate_card_number(num: str):
if not sixteen_digits(num):
return False
last_num = int(num[15])
list_num = list(num)
list_num.pop(last_num)
for index in range(len(list_num)):
list.reverse(list_num)
list_num[index] = int(list_num[index])
... |
a77b4a28e8c8bdcbcd20d09fffc98912f7a7c504 | sdansh/Learning-Material-Dump | /python/Parseltongue/Part4/02_phonebook.py | 1,537 | 3.578125 | 4 | # **************************************************************************** #
# #
# ::: :::::::: #
# 02_phonebook.py :+: :+: :+: ... |
d3a37a70cba2e061cf8793d0415aa9412226a50b | sdansh/Learning-Material-Dump | /python/OOP/part1/ex06/classroom.py | 426 | 3.5 | 4 | class Classroom:
def __init__(self, teacher, students):
capacity = 20
self.capacity = capacity
self.teacher = teacher
self.students = students
self.student_count = len(students)
def get_info(self):
print("This classroom has a standard capacity of {} and is run b... |
51d707ebcc79a209cc8b1e2cc1d44e0757b3bf54 | Hobis/HB_Python | /Test1.py | 1,964 | 3.640625 | 4 | #print("122222222")
#import sys
#sys.stdin.encodin
# print('kim')
# print(40 * 2)
# print(43 // 2)
# print(round(2.6))
# def p_pp():
# pass
# utf-8 인코딩 파일 출력
# def p_file_print():
# try:
# with open('test.txt', 'r', encoding='utf-8') as t_fo:
# for t_ls in t_fo.readlines():
# print(t_ls)
# except ... |
0e70d35a7dd27a85a012e7684aba30a717a907c3 | liying123456/python_leetcode | /queue/offer_09_cqueue.py | 1,102 | 3.84375 | 4 | # 剑指 Offer 09. 用两个栈实现队列
# 用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除
# 整数的功能。(若队列中没有元素,deleteHead 操作返回 -1 )
class CQueue:
"""
利用两个栈实现队列功能,
列表可以模拟栈
"""
def __init__(self):
self.A = [] # 添加数据
self.B = [] # 删除数据
def appendTail(self, value: int)... |
6539773e6de4a2ee96064333bb4405eece438328 | liying123456/python_leetcode | /tree/build_tree.py | 1,428 | 3.84375 | 4 | # 从一个列表,构建一个完全二叉树
class TreeNode:
"""
定义树节点
"""
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Tree:
"""
用于构建一个二叉树
"""
lt = [] # 依次存放左右孩子未满的节点
def __init__(self):
self.root = None
def add(self, number):
"""... |
cc05ed2e3a11002fe49c74344ad066fdb6078dbd | tomaszbobrucki/tictactoe | /Problems/Find positions/task.py | 251 | 3.859375 | 4 | # put your python code here
num = input().split()
number = input()
n = num.count(number)
only = [str(i) for i in range(len(num)) if num[i] == number]
# print(only)
if len(only) > 0:
print(" ".join(only))
else:
print("not found")
|
bb0ff06071166c10ba04cd598fc4293b66859fda | tomaszbobrucki/tictactoe | /Problems/CapWords/task.py | 96 | 3.84375 | 4 | words = input().split("_")
words1 = [w.capitalize() for w in words]
print("".join(words1))
|
f9cd7da2c8c828a8de6bbd0c7249cf9c667ca81e | Ritodono/tamvu-fundamental-c4t4-btvn05 | /Session05/exe20.8.1.py | 346 | 3.578125 | 4 | x = input("Enter a sentences: ")
x = x.lower()
alphabet = 'abcdefghijklmnopqrstuvwxyz'
letter_count= {}
for i in x:
if i in alphabet:
if i in letter_count:
letter_count[i] = letter_count[i] + 1
else:
letter_count[i] = 1
keys = letter_count.keys()
for i in sorted(keys):
... |
c9fbb4402cd878f58b2f0f92c8b84059abf4508a | dingaaling/pacman | /pacman.py | 956 | 3.765625 | 4 | # Python 3 - PAC-MAN Game
# Jennifer Ding
import sys
import numpy as np
from gameFunctions import *
# Read input file for game intializations: board dim, starting position, moves, and walls
# Example: python3 pacman.py input-file.txt
def main():
args = sys.argv
fileName = str(args[1])
inputVal = []
... |
863c4b944db0ad4ce57cabb4f4de2d56546164f8 | jian6/jiancmd | /jiancmd/main.py | 1,436 | 3.71875 | 4 | #!/usr/bin/env python
""" a command line tool to do simple everyday tasks for developers
Usage:
jiancmd currency convert FROM TO [-a AMOUNT]
jiancmd currency list
jiancmd currency -h | --help
Options:
-h --help display help screen
-a --amount==AMOUNT specify the amount to be conv... |
c64e229d3c1102feca55a4d2a24a87ceb6f5de70 | henridvf/katas | /domainname.py | 319 | 3.609375 | 4 | from urllib.parse import urlparse
def domain_name(url):
if '//' in url:
parsed = urlparse(url).hostname.split('.')
return parsed[1] if 'www' in url else parsed[0]
else:
split = url.split('.')
return split[1] if 'www' in url else split[0]
print(domain_name('http://google.com')) |
4d426354ff9429e7375ebc6c60b5e9834658d976 | spabwoodle/learning_python | /coffee4.py | 3,187 | 4.34375 | 4 | # Updates coffee3.py, asks user if they want to buy coffee, fill the machine,
# take cash, ask for levels or exit. Runs on loop and updates levels throughout.
# Coffee machine contents at start:
# [dollars cash, ml water, ml milk, grams coffee beans, disposable cups]
contents = [550, 400, 540, 120, 9]
#quantities p... |
9669bc4ac2ad71a06387aabb828fbc7f9dd80b3d | xzhdream/python-lib | /asyncio-/实现yield_from.py | 374 | 3.796875 | 4 | def gen():
yield from subgen()
def subgen():
while True:
x = yield
yield x+1
def main():
g = gen()
next(g) # 驱动生成器g开始执行到第一个 yield
retval = g.send(1) # 看似向生成器 gen() 发送数据
print(retval) # 返回2
g.throw(StopIteration) # 看似向gen()抛入异常
main() |
3311adf787c649813566b939fcd56f93030684b6 | myBestFriends-selcuk/Anomaly-Detection-for-Application-Virtualizaiton-Environments | /pcaVisualize/pcaVisualize/anomaly_detection/data_cleaner.py | 684 | 3.515625 | 4 | from pyspark.sql import functions as func
import pandas as pd
# This function returns the mean values and standard deviation values of entered column.
def getStatisticsOfDataFrame(dataFrame, selectedColumns):
meanValues = []
stdValues = []
for column in selectedColumns:
df_stats = dataFrame.selec... |
86d852f07324533e0bd51fa462a7a6c25c392807 | ardiya/test_lidar_data | /mylib/util.py | 1,258 | 3.734375 | 4 | from typing import Tuple
def compute_line_intersection(p0:Tuple[float, float],
p1:Tuple[float, float],
p2:Tuple[float, float],
p3:Tuple[float, float])->Tuple[bool, Tuple[float, float]]:
"""
Compute line intersection https... |
28b111acbc7bc040fe5df3f5b84fd27caade1325 | astikagupta/HW08 | /mimsmind1.py | 860 | 3.90625 | 4 | import sys
import random
def random_with_N_digits(n):
range_start = 0
range_end = 10**int(n)-1
return random.randint(range_start, range_end)
def func1():
if len(sys.argv) == 2 :
length = sys.argv[1]
else:
length = 3
rand = random_with_N_digits(length)
print rand
i = 0
j=0
cow=0
bull=0
while... |
3fbaf84c00c1fc49b5572e770284f4c15ae1be56 | Anjali-Poornima666/Passbook | /emailValidation.py | 243 | 3.59375 | 4 |
def EmailCheck(Email):
if re.match(r"^[A-Za-z\s][^@\s]*@[^@ | ^\.\s]+\.[a-zA-Z0-9\s]*[A-za-z]$",Email):
if (Email.find('@')-Email.find('.')) == 1:
return 0
else:
return 1
else:
return 0
while True:
print(EmailCheck(input()))
|
4e23ef6e9dfee02f8a55ec2d0551a1b3510a92e1 | j-halladay/numseq | /numseq/fib.py | 261 | 3.640625 | 4 | def fib(n):
if n < 2:
return n
else:
second_to_last = 0
last = 1
result = 1
for _ in range(1, n):
result = second_to_last + last
second_to_last, last = last, result
return result
|
0e891ec591ff452293d12a21ed5083e24755e97f | Lahari-5139/Python-Codes | /set.py | 162 | 3.5625 | 4 | n = input()
hs =raw_input().split(" ")
hsnew = []
for i in range(n):
k = int(hs[i])
hsnew.append(k)
j = set(hsnew)
s = sum(j)
avg = s/len(j)
print avg
|
3c08b9d1bfedb1956bfe67ae37bcd620cdc6e80d | Lahari-5139/Python-Codes | /practice1.py | 126 | 3.921875 | 4 | n = input("enter the no. of subjects:")
sum = 0
for i in range(n):
a = input("enter the marks:")
sum +=a
print (sum/n) |
f866e480294778533328cfffb0b4425bdd2d3f08 | 13424010187/python | /源码/【31】三角形公式大师-课程资料/【31】三角形公式大师-挑战包.py | 144 | 3.8125 | 4 | '''三角形公式大师-挑战包'''
def hypotenuse(a, b):
c = (a**2+b**2)**0.5
c = round(c, 1)
return c
print(hypotenuse(3, 5))
|
b93fdf5b6e8d609e66caf118d9ca766a51d1819f | 13424010187/python | /源码/2-小小题词员/练习1.py | 288 | 3.546875 | 4 | '''小小提词员-阶段1'''
#提词器
print('己亥杂诗(其五)')
print('浩荡')
print('离愁')
print('白日斜,')
print('吟鞭')
print('东指')
print('即天涯。')
print('落红')
print('不是')
print('无情物,')
print('化作' )
print('春泥')
print('更护花。')
|
aafe4c72e528ff6d6c759527bb1252551a4c215f | 13424010187/python | /源码/【24】图像处理大师-课程资料/3.不同颜色的星空/不同颜色的星空-成果包.py | 685 | 3.75 | 4 | '''不同颜色的星空-成果包'''
#调用PIL模块
from PIL import Image
#颜色更换小程序
#读取图片文件
img = Image.open('星月夜.png')
#获取图片尺寸
width, height = img.size
#加载图片内容
img_array = img.load()
#循环处理像素点
for x in range(width):
for y in range(height):
#获取RGB值
r = img_array[x, y][0]
g = img_array[x, y][1]
b = img_array[... |
85ad942410ef6ec9a706e158c6924671e632f828 | 13424010187/python | /LearnPython3-master/22-函数返回值/test.py | 742 | 4.03125 | 4 | # 返回数值
def add(x, y):
return x + y
# print(add(10, 20))
# print(add(30, 50))
# 返回字符
# def makeDBString(ip, dbname, uid, pwd):
# connString = ""
# connString += "Server=" + ip + ";"
# connString += "Database=" + dbname + ";"
# connString += "Uid=" + uid + ";"
# connString += "Pwd=" + pwd + ";"
#... |
30ccd0d68456a1e2a057d4b6eec75b573bad78ca | 13424010187/python | /源码/9-猜数字游戏/9.py | 3,167 | 4.21875 | 4 | ''''''
'''
数据类型:字符串str 数字类型:整数int 浮点float 布尔类型:True和False
算术运算符7:/ (返回浮点类型) + - * %(求余数,返回int类型) //(向下取整,返回整数类型) **(幂运算)
赋值运算符8:= +=
逻辑运算符3:and(与):真真为真 or(或):假假为假 not(非):真为假,假为真
真、假:True False
比较运算符6:> < == >= <= !=
成员运算符2:in
查看数据类型:type(数据)
input默认返回类型:字符串
+在两种数据类型中的用法:... |
dedcb90e6e202b30be86d35e3410cd8a87c872c6 | 13424010187/python | /源码/【16】智慧画手-课程资料/【16】斑马圆-成果包(练习3).py | 816 | 3.9375 | 4 | '''练习3成果包——斑马圆'''
'''
程序中有效使用for循环。
程序中有效使用分支结构。
'''
#调用模块
import turtle as t
#画笔设置
t.speed(100)
for x in range(100, 1, -10):
t.penup()
t.goto(0, -50)
t.pendown()
if x % 20 == 0:
t.color('black')
else:
t.color('white')
t.begin_fill()
t.circle(x, 360)
t.end_fill()
t.hi... |
30ab4a544a884fa139bbbe3c31e9286cccfc3ced | 13424010187/python | /LearnPython3-master/10-range()的使用/test.py | 634 | 4.28125 | 4 | # 使用range()函数
# for val in range(5):
# print(val)
# for(int i = 0; i < 5; i++) {
# }
# 指定range()的范围
# for val in range(1, 5):
# print(val)
# for(int i = 1; i < 5; i++) {
# }
# 生成数组
# nums = list(range(1,5))
# print(range(1,5))
# print(nums)
# 奇数数组
# nums = list(range(1,11,2))
# print(nums)
# 偶数数组
# nums = l... |
68f713e762e87058a0803f44d779542b1eed12d2 | 13424010187/python | /源码/1-新世界的问候/成果包.py | 286 | 3.8125 | 4 | '''新世界的问候-成果包'''
#自我介绍练习
message1 = input('输入姓名:')
message2 = input('输入爱好:')
message3 = input('输入未来的目标:')
print('姓名:')
print(message1)
print('爱好:')
print(message2)
print('未来的目标:')
print(message3)
|
d184137b297c3bc6e68172ab55c77f13b026a603 | 13424010187/python | /源码/【36】时间大师-课程资料/【36】时间大师-练习2-工程包.py | 471 | 3.578125 | 4 | '''
日期转换器————工程包
请你合理使用mktime()和localtime()两个方法实现输入日期(年-月-日),
输出该日期是星期几和当年的第几天。
'''
import time
dic = {
0: '星期一',
1: '星期二',
2: '星期三',
3: '星期四',
4: '星期五',
5: '星期六',
6: '星期日',
}
date = input('输入日期(例 2020-3-12):').split('-')
year = int(date[0])
month = int(date[1])
day = int(date[2])
|
bc0825e547232442fc44ee47db5c52ad3d3f561e | 13424010187/python | /源码/【34】神秘逻辑-课程资料/【34】神秘逻辑-练习1-成果包.py | 199 | 3.875 | 4 | '''神秘逻辑-练习一'''
#递归求解5的阶乘
def myfac(n):
if n == 1:
return 1
else:
return n * myfac(n - 1)
num = int(input('请输入数字:'))
print(myfac(num)) |
41973df1a8dff322b5096e028e1fcf3189851345 | 13424010187/python | /2021暑假课/双色球选购/统计个数.py | 537 | 3.734375 | 4 | '''
输入一行字符,分别统计出其中英文字母、空额、数字和其他字符的个数
'''
s=input('请输入一个字符串:').strip()
letters=space=digit=other=0
for i in s:
if i.isalpha(): #判断是否是字母
letters+=1
elif i.isspace(): #判断是否是空白字符
space+=1
elif i.isdigit(): #判断是否是数字
digit+=1
else:
other+=1
print('字母=',letters,'个,空白字符... |
d84fa31140a19d15dfd356bed0654068237b7be0 | 13424010187/python | /源码/10-诡秘的数字巧合/练习1成果包——水仙花数v1.0.py | 1,012 | 4.15625 | 4 | '''练习1成果包——水仙花数v1.0'''
'''
编写程序帮助阿短来判定一个三位整数是否为水仙花数。
输入一个三位整数,输出是否为水仙花数提示信息。
如:
Input:
输入数字:123
Output:
123 不是水仙花数
'''
#判断一个数是不是水仙花数
num = int(input('输入数字:'))
number= str(num)
i = 0 # 循环计数器
daffodil = 0 # 用和原数number来对比的水仙花数
#主循环
while i < len(number):
daffodil += int(number[i]) ** 3
i += 1
if int(number) ==... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.