blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
c36cfc7ea45fd4d614c7a56f09c1d0fd59e5da2b | jennahoward/CSC-and-NASA-Internship-Projects | /Python/create_student_schedule.py | 3,262 | 3.953125 | 4 | class StudentCourse:
def __init__(self, studentInfo, courseInfo, semester, year, grade):
self.studentInfo = studentInfo
self.courseInfo = courseInfo
self.semester = semester
self.year = year
self.grade = grade
def __str__(self):
return self.semester + ... |
b5a61b36636f364c963e3a553152a3afb57616b6 | C-Miranda/python-challenge | /PyBank/main.py | 2,105 | 3.734375 | 4 | import os
import csv
# Create file name
csvpath = os.path.join('.', 'Resources', 'budget_data.csv')
# Declare lists
dates = []
profit_losses = []
profit_changes = []
# Read/load file into lists
with open(csvpath) as csvfile:
# Drop header row
csvreader = csv.reader(csvfile, delimiter=',')
csv_header = ne... |
ef10fdd8a28acdedf2ad4267454a0e7fbb51d585 | Thijs-Sytema/Galgjespel | /main.py | 2,481 | 4 | 4 |
import random
word_list = ["informatica","informatiekunde","spelletje","aardigheidje","scholier","fotografie","waardebepaling","specialtieit","verzekering","universiteit","heesterperk"]
def get_word(word_list):
word = random.choice(word_list)
return word.upper()
def play(word):
word_completion = "_" * len(wor... |
bd9d6c422c494aaf7b48a9e4ccbfa28ff737e171 | JoelSantana58/curso-phyton | /venv-curso/cicloWhile.py | 49 | 3.671875 | 4 |
n=1
while n<=5:
print('mensaje')
n=n+1 |
3bf14142c9dafaf2454e50d85fd2227776c98523 | vijaychirag/EcommerceWebsite_V001 | /pythonBasics/dictionaries.py | 4,579 | 4.25 | 4 |
# Accessing Items:
dict1 = {"brand": "Ford","model": "Mustang","year": 1964}
print(dict1["model"]) # Mustang
# get() method:
dict2 = {"brand": "Ford","model": "Mustang","year": 1964}
dict3 = dict2.get("year")
print(dict3)
# extract value from key()
dict4 = {"brand": "Ford","model": "Mustang","year": 1964}
dict5 = d... |
206fb260e2b207b951f04a21b9ea96e082ed379c | carlhinderer/learning-python | /learning_python_lutz/exercises/part6.py | 13,872 | 4.25 | 4 | # 'Learning Python', by Mark Lutz
# Part 6 Exercises
# Exercise 1
# Inheritance
#
# Write a class called Adder that exports a method add(self, x, y) that prints a
# “Not Implemented” message. Then, define two subclasses of Adder that implement the add method:
# ListAdder
# With an add method that returns... |
2e4e0012235649961b56e64101e1b417ef98738e | hemanthkumar25/MyProjects | /Python/InsertionSort.py | 409 | 4.21875 | 4 | def insertionSort(list):
for index in range(1,len(list)):
currentvalue = list[index]
position = index
while position > 0 and list[position-1]>currentvalue:
list[position] = list[position -1]
position = position -1
list[position] = currentv... |
38afe1b48cade020e16180d94aa7fa2478031fbf | hemanthkumar25/MyProjects | /Python/Permutation.py | 73 | 3.59375 | 4 | import itertools
word = "123"
print list(itertools.permutations("abc")) |
d561a58d0a06e2a00a5db6ed81c8fe2801f2e4d6 | yuriy-puris/Python-Practice | /xml_test.py | 1,323 | 3.75 | 4 | import xml.etree.ElementTree as ET
import xmltodict
xml_example = """<employees>
<person ID="1234567">
<name>
<first>Kseniia</first>
<last>Krementar</last>
</name>
<address>
<city>Kiev</city>
<district>Obolon</district>
</address>
... |
011616da205d2bc8db4cfa09b8543eeb8a43f9bb | udayansk/Seltzer | /DNAND/autoDown.py | 2,283 | 3.609375 | 4 | # Automated Song Downloader through Youtube
# Run this with the name of the song you want to download
# **For spaces use dashes**
# Example: python autoDown.py young-dumb-and-broke
# The example case will download Young Dumb and Broke by Khalid
import selenium.webdriver as webdriver
from selenium.webdriver.common.ke... |
2c1d32fa816905fae2f81a5f4fcaddd79aa1a2f0 | KoreanFoodComics/dev-challenge | /chapter3_exercises.py | 439 | 3.6875 | 4 | # Exercises for chapter 3:
# Name:Bailey Johnson
#3.1/3.2 -- Funtions are executed in order. By placing the after the call, we cannot get the call.
#3.3
def right_justify(string):
str_len = len(string)
spaces = 70 - str_len
print " " * spaces + string
right_justify('allen')
line1 ="+----+----+"
li... |
765e92a506377ff880cdd94e7320a649eec91f8e | bschweiz/codewars | /python/cc_masking.py | 212 | 3.65625 | 4 | # return masked string, (my solution)
def maskify(cc):
if len(cc) < 4:
return cc
return "#" * (len(cc)-4) + cc[-4:]
# answer set solutions:
def maskify(cc):
return "#"*(len(cc)-4) + cc[-4:]
|
fb63758ef49d917c23a5ae9556136dabcb52394c | SACHSTech/livehack-3-kyliesinc | /problem2.py | 1,475 | 3.984375 | 4 | """
----------------------------------------------------------------------
Name: problem2.py
Purpose: Tony is a new DoorDash Driver and is tracking statistics for the first 100km that he's driven for the food delivery service. Write a program that allows Tony to enter the distance driven for each day until the tot... |
62ef7ee5f686e1ba394e27c0a8a496498bad1372 | danwhitston/project-euler | /python/p004.py | 368 | 3.71875 | 4 | # Euler Problem 4
# A palindromic number reads the same both ways.
# The largest palindrome made from the product of two 2-digit numbers is
# 9009 = 91 x 99. Find the largest palindrome made from the product of two
# 3-digit numbers
class Palindrome(object):
"""
docstring
"""
pass
def solve():
pas... |
c18feae7b795aadaf83b93ee1a6b6f209decaf37 | mikegajda/bullitt_lab | /log.py | 3,023 | 3.734375 | 4 | import glob, os, sys, time
class Log:
"""A generic Log class to hold any events that should be logged. Note: a .log file will always be saved.
Log by default builds a log, a human-readable history of what the script has done.
Log also introduces a change file, which is a machine-readable history of what the script ... |
a72bec9020e351bc3ef6e30d72aa3202021f2eab | severinkrystyan/CIS2348-Fall-2020 | /Homework 4/14.11 zylab_Krystyan Severin_CIS2348.py | 790 | 4.125 | 4 | """Name: Krystyan Severin
PSID: 1916594"""
def selection_sort_descend_trace(integers):
for number in range(len(integers)):
# Sets first number of iteration as largest number
largest = number
for i in range(number+1, len(integers)):
# Checks for number in list that is larger ... |
e29ba5aef2e0a93ce2709bf841aa37014885157e | severinkrystyan/CIS2348-Fall-2020 | /Homework 1/5.19 zyLab_Krystyan Severin_CIS2348.py | 1,083 | 3.734375 | 4 | """Name: Krystyan Severin
PSID: 1916594"""
print('Davy\'s auto shop services')
print('Oil change -- $35\nTire rotation -- $19\nCar wash -- $7\nCar wax -- $12\n')
services = {'Oil change': 35, 'Tire rotation': 19, 'Car wash': 7, 'Car wax': 12, '-': 'No service'}
first_service = input('Select first service:\n')
... |
6c2ec5fd0f47727d74f45c0e60ef4a12afde7f24 | severinkrystyan/CIS2348-Fall-2020 | /Homework 3/10.11 zylab_Krystyan Severin_CIS2348.py | 1,323 | 4.0625 | 4 | """Name: Krystyan Severin
PSID: 1916594"""
class FoodItem:
def __init__(self, name="None", fat=0.0, carbs=0.0, protein=0.0):
self.name = name
self.fat = fat
self.carbs = carbs
self. protein = protein
def get_calories(self, num_servings):
# Calorie formula
ca... |
5abb45d77cf7d4455701292edd46068f1ea4094c | Crabime/ershoufang | /panel/HyperLinkLabel.py | 1,492 | 3.515625 | 4 | from tkinter import *
import webbrowser
class HyperLinkLabel(Label):
"""自定义一个带有链接的label"""
def __init__(self, parent, link=None, *args, **kwargs):
Label.__init__(self, parent, *args, **kwargs)
self._link = link
self.bind("<Button-1>", self.click_callback)
self.bind("<Enter>", s... |
f289f244a11ba58e444cd193fbec2bb47f95e2aa | lebr0nli/PHPFun | /phpfun.py | 11,454 | 3.546875 | 4 | # PHPFun: ([.^])
from argparse import ArgumentParser
class PHPFun:
def __init__(self):
# simple constant
arr_str = "[].[]" # "ArrayArray"
# generate digits
nums = {0: "[]^[]", 1: "[]^[[]]"}
self.char_mapping = dict()
self.char_mapping['A'] = f"({arr_str})[[]]"
... |
43b12b51db5801d1c909a10531f8f0d95e6706f4 | techmoinak/Competitive-Coding-1 | /14_missing_number_in_sorted_list.py | 540 | 3.640625 | 4 | #Time Complexity : O(NlogN) N is the numbers present in the list
#Space Complexity : O(1)
#Did this code successfully run on Leetcode : Yes
#Any problem you faced while coding this :
#Your code here along with comments explaining your approach
def missing(arr):
start=0
end=len(arr)-1
while star... |
909235d18ee2a280743ffe0a4466a0c672f63f0a | Rozart/CodinGameSolutions | /python3/community/rubik.py | 138 | 3.828125 | 4 | import math
n = int(input())
all = int(math.pow(n, 3))
inside = 0
if n - 1 > 0:
inside = int(math.pow(n - 2, 3))
print(all - inside)
|
624cf5d84f4de775e6d36d0d781c636139fddae4 | Resesh/impl_algo | /impl_algo/k-means.py | 950 | 3.703125 | 4 | # implement k-means algo
import numpy as np
import matplotlib.pyplot as plt
comp = np.random.rand(200,2)*(10-(-10))-10
comp_num, comp_dim = comp.shape
def first_cnt(k):
first_cnt = np.ndarray((comp.shape))
np.random.shuffle(first_cnt)
return first_cnt[:k]
def kmeans(comp, k=3, iter=100):
"""
k: ... |
13460bfb09ef90a253d0b09dc708e517ef4df8ff | llsigerson/twittnet_python | /get_tweets.py | 425 | 3.515625 | 4 |
import pytz
import datetime
def get_tweets(user, startday = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)-datetime.timedelta(days=30), stopday= datetime.datetime.utcnow().replace(tzinfo=pytz.utc)):
tweets= statuses_to_df(api.user_timeline(user, count=200))
#check if oldest tweet is still younger than ... |
7c319555414c27974122e340478b27c1a7fccea0 | Vincent1127/Waste-Self-Rescue-Scheme | /雨初的笔记/备课/实训/day03/forwhile.py | 443 | 3.953125 | 4 | #coding:utf-8
'''
循环中的关键字
continue:结束本轮循环,继续下一轮
break:结束当前这个循环(整个for循环或while循环)
'''
m = 1
while(m<10):
m=m+1
if(m==5):
continue#结束本轮循环,后面的代码不会执行,跳到下一次循环
else:
print(m)
n = 1
while(n<10):
n=n+1
if(n==5):
break #结束整个循环(这里是这个while循环)
else:
print(n)
|
89d058658ca383637a76dc63c1156e98c90d5be4 | Vincent1127/Waste-Self-Rescue-Scheme | /雨初的笔记/备课/实训/day04/string3.py | 868 | 4.1875 | 4 | #coding:utf-8
#可以将字符串改为元组或者列表输出
la = 'python'
print(tuple(la))
print(list(la))
#得到字符对应的ASCII ord(str)得到ASCII码 chr(ASCII)得到字符串 ??如何随机的十位a-z的字符串??
print(ord('中'))
print(ord('a'))
#得到ASCII代指的字符
print(chr(20013))
print(chr(65))
#得到字符中某个字符的下标
print(la.index('t'))
print('y' in la)
#.strip()去除字符串中首尾的空格
strA = ' aaBcd... |
5923dae06ffd1d817a40eadf2a57ba81f65d0d4c | Vincent1127/Waste-Self-Rescue-Scheme | /雨初的笔记/备课/实训/day02/num3.py | 445 | 3.765625 | 4 | #coding:utf-8
#比较运算符
'''
< a < b 判断a是否小于b 结果返回 True 或者 False
<=
>
>=
!=
== 判断是否相等
'''
print(3<5)
print(4==4)
#逻辑运算符 与、或、非 and、or、not
print(3<5 and 3>5)
print(3<5 or 3>5)
print(not 3>5)
print("#########")
#短路
print(3 or a) #or后面的代码不执行了
print(0 and a) #and后面的代码不执行了,虽然a未定义,但是不报错
print(0 or a)
|
907ce9cc17ec58d2bbcaf601d0feebed8a130c02 | Vincent1127/Waste-Self-Rescue-Scheme | /雨初的笔记/备课/实训/day03/exe1.py | 578 | 3.703125 | 4 | #coding:utf-8
#打印九九乘法表
'''
1*1
1*2=2 2*2
1*3 2*3 3*3
'''
'''
for i in range(1,10):#决定第几行
for j in range(1,i+1):#决定每一行有多少列
print(j,'*',i,'=',i*j,'\t',end='')
print()
'''
#打印图形
'''
用户输入3时
***** i=1 2*row-1-(i-1)*2
@*** i=2 2*row-1-2
@@* i=3 2*row-1-4
用户输入4时
******* 2*row-1-0
@***** ... |
87af320ae26cb2334b54ad8882007760d75c1889 | rho2/HackerRank | /Python/BasicDataTypes/nested_list.py | 158 | 3.53125 | 4 | l = [[input(), float(input())] for _ in range(int(input()))]
s = sorted(list(set([m for n, m in l])))[1]
print('\n'.join(sorted([a for a,b in l if b == s]))) |
54c5bb9f94d5e13b3c1cd30c41025a555a632a02 | guilhermeerosa/Python | /Exercicios-CursoEmVideo/ex003.py | 242 | 3.921875 | 4 | #Realiza a soma entre os numeros informados
print('Calculadora de soma')
n1 = int(input('Informe o primeiro número: '))
n2 = int(input('Informe o segundo número: '))
print(f'A soma é {n1+n2}')
print(f'A soma entre {n1} e {n2} é {n1+n2}')
|
b195c63bdc74be6ea8a195f584612cb88cbce52e | guilhermeerosa/Python | /Exercicios-CursoEmVideo/ex008.py | 212 | 3.71875 | 4 | #Conversor de metros para centimentros e milimetros
m = float(input('Digite o valor em metros: '))
cm = m * 100
mm = m * 1000
print('Você escolheu {}m, o que equivale a {:.0f}cm ou {:.0f}mm.'.format(m, cm, mm))
|
9e47bbe84d9157a84619b279ab7680e90a7e5e74 | guilhermeerosa/Python | /Exercicios-CursoEmVideo/ex020.py | 298 | 3.78125 | 4 | #Sorteia uma ordem dos nomes apresentados
from random import shuffle
al1 = input('Primeiro aluno: ')
al2 = input('Segundo aluno: ')
al3 = input('Terceiro aluno: ')
al4 = input('Quarto aluno: ')
ordem = [al1, al2, al3, al4]
shuffle(ordem)
print('A ordem de apresentação será: {}!'.format(ordem))
|
a45d7871694012a5064bc07b6e9033f6fcb15457 | guilhermeerosa/Python | /Exercicios-CursoEmVideo/ex019.py | 335 | 3.78125 | 4 | #Escolha aleatória de 4 alunos com biblioteca random/choice
from random import choice
al1 = input('Nome do primeiro aluno? ')
al2 = input('Nome do segundo aluno? ')
al3 = input('Nome do terceiro aluno? ')
al4 = input('Nome do quarto aluno? ')
escolha = choice([al1, al2, al3, al4])
print('O aluno escolhido foi: {}!'.for... |
7392f6bd7e927f445b318d609e3fdefd885bbee6 | aroberge/import-experiments | /enforce_constants/transformer.py | 2,498 | 3.8125 | 4 | import re
# For this example, we use simple regular expressions to identify
# lines of code that correspond to variable assignments. It is assumed
# that each assignment is done on a single line of code.
# This approach can change values within triple-quoted strings
# and does not capture all the possible cases for va... |
ebf488acc24383c9dce7a14b2080e68010437317 | ayuzer/HC-Gammalyzer | /peakFitting.py | 1,244 | 3.6875 | 4 | """
This function is for fitting a Gaussian to a data set.
it would be very easy to add other functions using the same
pattern as the gauss_function function.
(also used for calibration)
"""
import math
import numpy as np
from scipy.optimize import curve_fit
def peakFitting(ydata,xdata=None):
if xdata... |
7de079577640a863a625e817b5aaed7c7fbd854d | Zulfiqar110/Python-For-Everybody | /Assignments/database_ass.py | 874 | 3.640625 | 4 | import sqlite3
connection = sqlite3.connect('mail_data.sqlite')
crs = connection.cursor()
crs.execute('DROP TABLE IF EXISTS Counts')
crs.execute('CREATE TABLE Counts (org TEXT,count INTEGER)')
name = input('Enter file name :: ')
if len(name)<3: name = 'mbox.txt'
hand = open(name)
for lines in hand:
if not lines.st... |
6024cea66342da21b88c3cb8da5a66f5baf7f51b | huyba/learning | /py/import.py | 200 | 3.609375 | 4 | import re
for test_string in ['555-1212', 'a12-1243']:
if re.match(r'^\d{3}-\d{4}$', test_string):
print test_string, 'is a valid US local phone number'
else:
print test_string, 'rejected'
|
0f40a42772e3acb9e027c7fd651e06f684a6b682 | leoking01/total_news_spiders | /baidu/baidu/info/tt.py | 1,013 | 3.640625 | 4 | #!/usr/bin/python
#!coding: utf-8
def makedict(ls):
"""
@function : makedict : 根据一个列表生成一个字典
@parameter : ls : 列表
"""
##创建一个无重复的列表
new_ls=[]
for it in ls:
if len(new_ls)==0:
new_ls.append(it)
else:
for itt in new_ls:
state=bianli(new_l... |
fbeaf00fea7890184e40e34f3e403b2121f6b289 | BriannaRice/Final_Project | /Final_Project.py | 1,201 | 4.125 | 4 | '''
I already started before I knew that they all had to go together
so some of it makes sense the rest doesn't
'''
# 3/11/19 Final Project
# Brianna Rice
print('Pick a number between 1 and 30', "\n")
magic_number = 3
guess = int(input('Enter a number:', ))
while guess != magic_number:
print('Guess again', "\n")
... |
108e92d7d755b3bb320f39f6be77dc752a6fc507 | lawrenceliu12/IAE-101 | /sierpinski(1).py | 6,148 | 4.375 | 4 | # Lawrence Liu
# 113376858
# lawliu
# IAE 101
# Fall, 2020
# Project 2 - Sierpinski Triangle
import pygame
# This is a list of predefined pygame Color objects
colors = [pygame.Color(0, 0, 0, 255), # Black
pygame.Color(255, 0, 0, 255), # Red
pygame.Color(0, 255, 0, 255), #... |
caf5f86bbc53016fc0a493df3f934883ee59ade2 | LindsayJiang/CS320 | /2/interpret.py | 7,111 | 3.5625 | 4 | #Linshan Jiang (U67862687)
#interpret
import re
#2.a. / 3.
#added compare, lessThan and greaterThan for extra credit
def evalTerm(env, t):
Node = dict
Leaf = bool
if type(t) == Node:
for label in t:
children = t[label]
if label == "Number":
x = children[0]
... |
425d7c9ae9f0de270bfdc1cddd170ee67ff74426 | paramgi/PYClass | /src/CSVEx.py | 480 | 3.875 | 4 | # ----- CSV file ---
import csv
def write(fileobj,data):
write = csv.writer(file,delimiter=',')
for line in data:
write.writerow(line)
def read(file)
read = csv.dictreader(file,delimiter=',')
print(read)
for a in read:
print(a['name'])
print(a['addr'])
print(a['phone'])
print(70*'_')
if __name__ ==... |
b676b14f4bfb884dd2a76b17f2ae270999ed8f2f | Submohr/PokeScanner | /app/data/helpers.py | 1,135 | 3.765625 | 4 | # data helper methods
from config import Config
from typing import List, Dict
def weight_int_to_str(weight: int) -> str:
if weight is not None:
return int_to_str(weight) + " kg"
return None
def height_int_to_str(height: int) -> str:
if height is not None:
return int_to_str(height) + " m"... |
ae137df8aef278719d921bdd9f17ed610e48e4bb | Austin-JL/leetcode | /Sort/179_LargestNum/179.py | 1,928 | 3.734375 | 4 | class Solution(object):
def largestNumber(self, nums):
"""
:type nums: List[int]
:rtype: str
"""
# practice selection sort
for i in range(len(nums)):
pos = i
for j in range(i+1,len(nums)):
if self.mycompare(nums[pos],nums[j]):
... |
2911af7b2f369ffcafd6aae0d0c512850ef69782 | eslao/cognos | /name_filter.py | 594 | 3.609375 | 4 | import csv
import string
filetext = open('list.txt', 'r')
itemlist = []
filterlist = []
#inverted_name_list = []
#direct_order_name_list = []
for line in filetext:
item = line.strip().split(',')
inverted_name = line.strip()
direct_order_name = item[-1] + ' ' + ' '.join(item[:-1])
#inverted_name_list +... |
35985159a0ad04d52ef08fa91630edcac4abd966 | Illidan7/Algorithmic-Toolbox | /Algorithmic Warm Up/Last Digit of the Sum of Fibonacci Numbers Again/last_digit_of_the_sum_of_fibonacci_numbers_again.py | 1,810 | 3.734375 | 4 | # python3
def last_digit_of_the_sum_of_fibonacci_numbers_again_naive(from_index, to_index):
assert 0 <= from_index <= to_index <= 10 ** 18
if to_index == 0:
return 0
fibonacci_numbers = [0] * (to_index + 1)
fibonacci_numbers[0] = 0
fibonacci_numbers[1] = 1
for i in range(2, to_index ... |
e9c26a7887d9f83dc9703416784a4ed990875830 | oscartobanche/lab-1 | /h.py | 2,581 | 3.78125 | 4 | import hashlib
def hash_with_sha256(str):
hash_object = hashlib.sha256(str.encode('utf-8'))
hex_dig = hash_object.hexdigest()
return hex_dig
def h(length,maxVal,salt,hashed):
for j in range (0,100):
for i in range(0, maxVal+1):
if length == 3:
x = ... |
a3b5a48210effb9151531ddea990188ff6a74ee6 | specq/dlav | /specq_lab2/Softmax/linear_classifier.py | 7,505 | 3.78125 | 4 | import numpy as np
from random import shuffle
def softmax_loss_vectorized(W, X, y):
"""
Softmax loss function, vectorized version.
Inputs have dimension D, there are C classes, and we operate on minibatches
of N examples.
Inputs:
- W: A numpy array of shape (D, C) containing weights.
- X: A numpy array... |
b4faf014046390f8f5807217a159d0bda12d79c8 | jankovicgd/gisalgorithms | /listing25.py | 993 | 4.53125 | 5 | # 2.5 Determining the position of a point with the respect to a line
# Listing 2.5: Determining the side of a point
# Imports
from geometries.point import *
def sideplr(p, p1, p2):
"""
Calculates the side of point p to the vector p1p2
Input:
p: the point
p1, p2: the start and end points of... |
c1da53a4528ad5a489550daef6aa4502abfaee27 | TomaszBielawski82/Narzedzia | /zadanie3.py | 319 | 3.5625 | 4 | with open('./liczby.txt') as f:
lines = f.read().splitlines()
def isPrime(string):
num = int(string);
for i in range(2, num):
if (num % i == 0):
return False;
return True
for num in lines:
if isPrime(num):
print(num, "jest liczba pierwsza")
else:
print(num) |
f31232ccf83e40692e408ef250b3f3a8bd06dc20 | Shimeshu/Login-system | /Portals/Login.py | 589 | 3.5 | 4 | import os
def Login():
print("Welcome to the Login Portal!")
name = input("Enter Your Name -> ")
cwd = os.getcwd()
if os.path.exists(f"{cwd}/Registered Users") != True:
os.mkdir(f"{cwd}/Registered Users")
try:
login_file = open("{}/Registered Users/{}.txt".format(cwd, name), 'r')
except FileNotFoundError... |
0a1893a39b6d27a4e886c48658c086bbd402e427 | ParkerCS/programming2-assignments-sturner18 | /functions_and_imports.py | 2,041 | 4.09375 | 4 | #FUNCTIONS AND IMPORTS (20PTS TOTAL)
# Be sure to comment all your functions as shown in notes
import import_me
#PROBLEM 1 (how many upper case - 4pts)
# Make a function takes a string as a parameter, then prints how many upper case letters are contained in the string.
# A loop that compares each letter to the .upper()... |
7ba7f9c2245ff2f52d58d72fa55beb49e2db1a15 | Alanis97/Clase3 | /EncuentraRaices.py | 1,639 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 28 14:02:10 2019
@author: ealaniss
"""
import Matemáticas as mat
import Lectura as lec
def fun1(x):
return x ** 3 - 2 * x ** 2 +2.25
print("\nf(x) = x ** 3 - 2 * x ** + 2.25")
print("\nIntervalo de evaluación [x0, x1]")
x0 = lec.leeReal("x0: ")
x1 = lec.leeReal("x1... |
8d6b7dcbcab449f741cabab45904f6a961c6aa57 | zhangguof/LeetCode | /longest_substring_without_repeating_characters.py | 517 | 4.09375 | 4 | #-*- coding:utf-8 -*-
#problem
# Given a string, find the length of the longest substring without repeating characters.
# For example, the longest substring without repeating letters for "abcabcbb" is "abc",
# which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
class Solution:
#... |
8b33f0751bfe710120c0a93eb20594912e8f968b | zhangguof/LeetCode | /add_two_numbers.py | 1,496 | 3.8125 | 4 | #-*- coding:utf -*-
#problem
# You are given two linked lists representing two non-negative numbers. 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.
# Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
# Output: 7 -> 0 -> 8
# Definition... |
ac7c165a038deab092371f8b70d70d766b68d542 | zhangguof/LeetCode | /two_sum.py | 1,071 | 3.828125 | 4 | #-*- coding:utf-8 -*-
#problem
# Given an array of integers, find two numbers such that they add up to a specific target number.
# The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index... |
2b25334f964ac0aa8edcfbe58ba16e7f9bc04c60 | zhangguof/LeetCode | /Longest Substring_Without_Repeating_Characters.py | 1,429 | 4.03125 | 4 | #-*- coding:utf-8 -*-
# 3. Longest Substring Without Repeating Characters
# Given a string, find the length of the longest substring without repeating characters.
# Examples:
# Given "abcabcbb", the answer is "abc", which the length is 3.
# Given "bbbbb", the answer is "b", with the length of 1.
# Given "pwwkew", ... |
6d55c6d3f78e0fb23840d817f1fef7750d999548 | zhangguof/LeetCode | /Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py | 1,870 | 4.0625 | 4 | #-*- coding:utf-8 -*-
# Given preorder and inorder traversal of a tree, construct the binary tree.
# Note:
# You may assume that duplicates do not exist in the tree.
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# ... |
4e2e4e844c991b458891fe2cd118e10d048601cc | Caroline-Wendy/Python-Notes | /STL_Text_05_P11-12.py | 1,165 | 3.71875 | 4 | # -*- coding: utf-8 -*-
# textwrap 格式化文本段落
# STL P11-12
import re
#找到所有匹配目标
text = 'abbaaabbbbaaaaa'
pattern = 'ab'
for match in re.findall (pattern, text) :
print('Found "%s"' % match)
for match in re.finditer (pattern, text) :
s = match.start()
e = match.end()
print('Found "%s" at %d:%d' % (text[... |
881597231f6e6e6cc733996ed6c10f11e0352a30 | brandong1/python-practice | /coding_exercises/frequency.py | 253 | 4 | 4 | # Write a function called frequency that accepts a list and a search term and returns the number of times the search term appears in the list.
'''
frequency([1,2,3,4,4,4], 4) # 3
'''
def frequency(list, search_term):
return list.count(search_term) |
1cbefd7f905501343bd0ecdd83a525b1a78b18af | brandong1/python-practice | /dict_pop_popitems_update.py | 789 | 4.03125 | 4 | # pop - takes a single argument corresponding to a key and removes that key-value pair from the dictionary. Returns the value corresponding to the key that was removed.
d = dict(a=1,b=2,c=3)
d.pop() # TypeError: pop expected at least 1 argument..
d.pop('a') # 1
d # {'b': 2, 'c': 3}
d.pop('e') # KeyError
# popitem - re... |
1699edc7c5f9796e159a405cc1d10154b6e99d06 | brandong1/python-practice | /algorithms/runtime_analyzer.py | 371 | 4.03125 | 4 | import random
import runtime_demos
def create_random_list(size, max_val):
random_list = []
for num in range(size):
random_list.append(random.randint(1,max_val))
return random_list
size = int(input("What size list do you want to create? ")) # cast as int
max = int(input("What is the max value of t... |
1ba8a585ffe43559ca1fdfe28d11988d4a22597f | brandong1/python-practice | /stop-copying-me.py | 156 | 3.796875 | 4 | message = input("How's it going?")
while message != "stop copying me":
print(f"{message}")
message = input("How's it going?")
print("FINE YOU WIN!") |
a066d45ba48557d5258369b3a35ffdd621a3ad5e | brandong1/python-practice | /unnecessary_else.py | 230 | 3.765625 | 4 | # Unnecessary else on line 5:
def is_odd_number(num):
if val % 2 != 0:
return True
else:
return False
# Better version:
def is_odd_number(num):
if val % 2 != 0:
return True
return False
|
5282bde4a7117d50a4da0c33dc01ac475f4bbe46 | brandong1/python-practice | /spotify_dict_example.py | 433 | 3.625 | 4 | playlist = {
'title': 'dog days',
'author': 'brandon g',
'songs': [
{'title': 'song1', 'artist': ['borkman'], 'duration': 2.5},
{'title': 'song2', 'artist': ['borkman', 'djbark'], 'duration': 5.5},
{'title': 'borkbork', 'artist': ['borky'], 'duration': 5},
]
}
# how long is this... |
b70f37cacfe13994d2e59815df01b0c31adf5bb4 | brandong1/python-practice | /clear_pop_remove.py | 310 | 3.875 | 4 | # pop - remove the item at the given index in the list and resturns it
# if no index is specified, removes and returns last item in the list
first_list = [1,2,3,4]
first_list.pop() # 4
first_list.pop(1) # 2
# remove - remove first item from list whose value is x
# throws ValueError if the item is not found. |
04248167e01abcf1bf7a4e17cd3dafd41f966db4 | hutbe/python_space | /7-Some Functions/list_comprehensions.py | 1,109 | 3.890625 | 4 | #list, set, dictionary
my_list1 = [char for char in "hello"]
my_list2 = [num for num in range(0,100)]
my_list3 = [num*2 for num in range(0, 20)]
my_list4 = [num**2 for num in range(0, 20) if num % 2 == 0]
print(" =====list====== ")
print(my_list4)
print(" ===== Using IF ELSE =====")
odd_even_list = ["even... |
b0116d2b9699ddae46d6f5f22c038b23dae7338f | hutbe/python_space | /Chapter 3/list.py | 759 | 4.09375 | 4 | numbers = ["one", "two", "three"]
print(numbers[0])
print(numbers[::-1])
print(len(numbers))
del numbers[0] # will delete the value in the appropiate position
popped_element = numbers.pop() # Pop willl help you to remove the last element
print(numbers)
print(popped_element)
alpha = ["z", "c", "a"]
alpha.sort();... |
fce81ed22628a7b25628128876bf72b480f7cfb0 | hutbe/python_space | /Chapter 4/diction_pattern.py | 147 | 3.53125 | 4 | dictionary = {
123: [1, 2, 3],
True: 'hello',
'isTrue': True,
(1, 2): [23, 4, 33]
}
print(dictionary['isTrue'])
print(dictionary[(1, 2)])
|
e9508a4b4f0811ca781e443053f9304ccb73f382 | hutbe/python_space | /11-Modules/Built-in Modules/built_in_sys.py | 394 | 3.53125 | 4 | import sys
print(sys)
# print(dir(sys))
# help(sys)
# sys.argv is the param with command line
# like your using command 'python3 ./built_in_sys.py Kevin Chen' in Terminal
# 'Kevin' and 'Chen' will pass to sys.argv
first = sys.argv[0]
second = sys.argv[1]
thrid = sys.argv[2]
# As the example above
print(first) # wi... |
858fd9f1634b03d69550a3202c2f12a7295d568b | hutbe/python_space | /8-Decorators/decorators.py | 1,017 | 4.34375 | 4 | # Decorator
# Using a wrap function to add extra functions to a function
def my_decorator(fun):
def wrap_fun():
print(f"==== Function: {fun.__name__}")
fun()
return wrap_fun
@my_decorator
def say_hi():
print(f"Hello everyone, nice to be here!")
say_hi()
@my_decorator
def generator_even_odd():
result_list = [... |
9a6cd4518c1bb000496a8aef48336b7b5179f809 | hutbe/python_space | /13-FileIO/read_file.py | 1,054 | 4.34375 | 4 |
test_file = open('Test.txt')
print("File read object:")
print(test_file)
print("Read file first time")
print(test_file.read()) # The point will move to the end of file
print("Read file second time")
test_file.seek(0) # move the point back to the head of file
print(test_file.read())
print("Read file third time")
p... |
506432175dc2612d82f856e3769cb4829760fbed | hutbe/python_space | /10-Generators/generators.py | 1,372 | 3.828125 | 4 | # interable
# iterate
# generators
# Using keyword 'yield'
print("Using keyword 'yield'")
def iteratable_fun(num):
for i in range(num):
print("Before yield")
yield i
print("After yield")
for item in iteratable_fun(4):
print(f"item print {item}")
def iterate_for(interable_item):
iterator = iter(interable... |
c7670c3f9d37e0ccda671335efb38b0a20fd4f70 | hutbe/python_space | /Chapter 8/function.py | 578 | 3.5625 | 4 | def printme( str ):
print(str)
return
printme("I'm first call user defined function")
printme("Again second call to same function")
def changeme( mylist ):
mylist.append([1, 2, 3, 4])
print(f"Get value in the function: {mylist}")
return
mylist = [10, 20, 30]
changeme( mylist)
print(f"Get value out of the functio... |
2759c20760b09c2ace3591ce5ab232a6653f6f76 | WilliamFWG/Warehouse | /python/PycharmProjects/py01/day02/99.py | 150 | 3.90625 | 4 | x=int(input('please enter a number: '))
for i in range(1,x+1):
for j in range (1,i+1):
print ('%s*%s=%s' % (i,j,i*j),end=' ')
print()
|
99f858d6dcfdeb60d3c19657ec7a5724dbff6fc0 | WilliamFWG/Warehouse | /python/PycharmProjects/py01/day04/stack.py | 890 | 4.0625 | 4 | #!/root/nsd1905/bin/python
''' stack
append stack
pop stack
show stack
'''
stack=[]
def show_menu():
menu='''
0) Push into Stack
1) Pull from Stack
2) Show Stack
3) Quit
Please Choose (0/1/2/3):'''
cmds={'0':push_stack,'1':pull_stack,'2':show_stack}
choice=''
while choice!='3':
choice=input(me... |
fbc7b42a9d36526e55794f33b3d33921916fc1bb | WilliamFWG/Warehouse | /python/PycharmProjects/py02/day01/suanshi2.py | 1,219 | 3.9375 | 4 | #!/root/nsd1905/bin/python
'+- test'
import random
def exam():
cmds={'+':lambda x,y:x+y,'-':lambda x,y:x-y}
nums=[random.randint(1,100) for i in range(2)] #random generate two numbers
result=0
nums.sort(reverse=True) # sort the list to descent
sign=random.choice("+-") #random choose + or -
... |
3f802c6e5de4a46c6b1ed20073952e0842e20678 | WilliamFWG/Warehouse | /python/PycharmProjects/py05/mysite/templates/test.py | 88 | 4 | 4 | a=int(input('enter a number:'))
if a==5:
print('ok')
elif a==6:
print('not ok')
|
b5ea8dda11bcb3ddc0ef363abb21a86e13cdd6af | PauloSeph/Curso-Python | /Firstproject/area_circulo_v6.py | 237 | 3.90625 | 4 | #!python
from math import pi
raio = input('Informe o raio: ')
print('Area do circulo', pi * float(raio) ** 2)
# Modulo principal, no caso especial que já é executado a partir do ./area_circulo_v6.py
print('Nome do modulo', __name__)
|
678ada5c41d7dbbdaf0e73fbe197d2b5f6278178 | PauloSeph/Curso-Python | /exerciciosBasicos/Aula5-14.py | 402 | 4.0625 | 4 | # Operadores aritméticos
print(2 + 3)
print(2 - 3)
print(2 * 3)
print(2 / 3)
print(2 // 3)
print(2 ** 3)
print(2 % 3)
a = 3
a = a + 7
print(a)
# a = 5
a += 5
print(a)
not 0
True or True
True and True
a = 20
b = 30
print(a != b)
abacate = 20
-abacate
print(abacate)
print(not 0)
# Operadores ternario
esta_chov... |
5a51aff10214e035f7240cb1e3a940e450f770b2 | longhushi/Python-Study | /chapter8_2.py | 583 | 3.65625 | 4 | import re
f = open('madwords.txt')
#print(f.read())
content = f.read()
f.close()
replacewords = ['ADJECTIVE','NOUN','ADVERB','VERB']
newcontent = ''
for word in content.split(' '):
regex = re.compile(r'\w+')
w = regex.search(word).group()
print(w)
if w in replacewords:
print('Enter an '+w.lo... |
23165fa69e6bbd7f967fd2a41356de26a91260ed | LinLeng/xiaoxiyouran_all | /python2/20180718零基础学习python/Python-From-Zero-to-One/unmd/课时034 丰富的else语句及简单的with语句/program000.py | 484 | 3.9375 | 4 | # 要么怎样,要么不怎样
def choose(flag):
if flag == True:
print("True")
else:
print("False")
choose(True)
# 干完了能怎样,干不完就别想怎样
def showMaxFactor(num):
count = num // 2
while count > 1:
if num % count == 0:
print("%d最大约数是%d" % (num, count))
break
count -= 1
... |
591fcb8ba888b94ee8c9e8c08d0ea725116e6d5b | LinLeng/xiaoxiyouran_all | /python3/201801821python3_7liaoxuefeng/unmd/tmp_pycharm_project/ch01/01.py | 379 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
filename: ch01/01.py
message: notes for liaoxuefeng in learning pyhon 3.7
'''
name1=input('pleas enter first num:')
name2=input('please enter second num:')
print(int(name1))
print(int(name2))
print('%s * %s=' % (name1,name2), int(name1) * int(name2))
# pleas enter ... |
39c637f7a64f2185f33fad2b58272541f45dc2d5 | LinLeng/xiaoxiyouran_all | /python2/20180718零基础学习python/Python-From-Zero-to-One/unmd/课时024 递归汉诺塔/Program000_huiwen.py | 641 | 3.90625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 28 20:10:52 2017
@author: amusi
"""
# 使用递归的方式求解“回文字符串”
def is_palindrome(n, start, end):
if start > end:
return 1
else:
#return is_palindrome(n, start+1, end-1) if n[start] == n[end] else 0
if n[start] == n[end]:
... |
d5c8b082ed261c2e01b595bbe3eb2eb6b4366300 | LinLeng/xiaoxiyouran_all | /python2/20180718零基础学习python/Python-From-Zero-to-One/unmd/课时038 类和对象 继承/review002.py | 599 | 4.15625 | 4 | # Summary:定义一个点(Point)类和直线(Line)类,使用getLen方法可以获得直线的长度
# Author: Fangjie Chen
# Date: 2017-11-15
import math
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def getX(self):
return self.x
def getY(self):
return self.y
class Line(Point):
def __init__(s... |
e3b34c0e902413ce9da26b4882debfb42fa785a9 | vivekkeshore/spoj_problems | /phonelist.py | 418 | 3.65625 | 4 | # Vivek Keshore
# http://www.spoj.com/problems/PHONELST/
inputs = int(raw_input())
for inp in xrange(inputs):
nums = int(raw_input())
numbers = []
for num in xrange(nums):
numbers.append(raw_input())
numbers.sort()
for i in xrange(1, len(numbers)):
a = numbers[i-1]
b = numbe... |
8a256205147dc3c250cdb8642ab622b710d674e3 | michaelstresing/apilabs | /apis/Exercise_04.py | 452 | 3.59375 | 4 | '''
Write a program that makes a PUT request to update your user information to a new first_name, last_name and email.
Again make a GET request to confirm that your information has been updated.
'''
import requests
source = 'http://demo.codingnomads.co:8080/tasks_api/users'
body = {
"id": 30,
"first_name":... |
edcd16b836d07e6a454f195398448451e1c02d26 | michaelstresing/apilabs | /databases/Exercise_01.py | 617 | 3.796875 | 4 | '''
All of the following exercises should be done using sqlalchemy.
Using the provided database schema, write the necessary code to print information about the film and category table.
'''
import sqlalchemy
from pprint import pprint
passw = ''
engine = sqlalchemy.create_engine(f'mysql+pymysql://root:{passw}@local... |
415462d150a208b73802c056d38351cbbfaac634 | mikeboucher/test | /foobar.py | 668 | 4 | 4 |
def foo():
"""This would be the summarry line
This is the first line of my string. (Actually it's the second)
this is a third line
and a fourth and last.
*enclosed by a single asterisks*
**Using double asterisks**
``Use this for a code sample``
"""
print "foo"
def format(**arg... |
ed8e8f7646b93809bf53f84dc4654ecc61ffbac7 | Omkar2702/python_project | /Guess_the_number.py | 887 | 4.21875 | 4 | Hidden_number = 24
print("Welcome to the Guess The Number Game!!")
for i in range(1, 6):
print("Enter Guess", int(i), ": ")
userInput = int(input())
if userInput == Hidden_number:
print("Voila! you've guessed it right,", userInput, "is the hidden number!")
print("Congratulations!!!!! You too... |
71408ad2465ff91a2b2523fd104b957601a81f2d | JohannLieberto/Easy-Hangman-Hyperskill | /hangman.py | 1,908 | 3.890625 | 4 | import random
class Hangman:
def __init__(self):
self.letter_list = []
random.seed()
self.words = ['python', 'java', 'kotlin', 'javascript']
self.check = random.choice(self.words)
self.check_copy = ["-" for i in self.check]
def __repr__(self):
return "H A N G... |
32334a97d3f7c8680fda53001fe58286e4b49988 | satanmyninjas/Pandas-Practice | /main.py | 589 | 3.65625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
# Topic: Fertility rates and their decrease over the decades
data = pd.read_csv('children-per-woman-UN.csv', usecols=[0, 2, 3])
# print(data.describe())
us_data = data[data['Entity'] == 'United States']
us_data.plot(x='Year', y='Estimates 1950 - 2015: Demographic ... |
41a6081028fa61c8a40497ef6c2d78fb0728fa43 | vaish28/Python-Programming | /Tkinter/TkinterAssignment_Calculator.py | 6,565 | 4.15625 | 4 | '''
@ author :- Vaishnavi Madhekar
A calculator for basic arithmetic operations using Tkinter
'''
#import tkinter module
import tkinter as tk
#import math module
import math
#create root window
root = tk.Tk()
#create canvas
canvas_1 = tk.Canvas(root, width = 400, height = 300)
canvas_1.pack()
# Cr... |
7fbdcfad250a949cb0575167c87d212f376e4d98 | vaish28/Python-Programming | /JOC-Python/NLP_Stylometry/punct_tokenizer.py | 405 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Punctuation tokenizer
"""
#Tokenizes a text into a sequence of alphabetic and non-alphabetic characters.
#splits all punctuations into separate tokens
from nltk.tokenize import WordPunctTokenizer
text="Hey @airvistara , not #flyinghigher these days we heard? #StayingParkedStayingSa... |
0290746b9b476109ea203930c5ccaaf2ec98bf31 | qwatro1111/common | /tests/tests.py | 1,917 | 4.125 | 4 | import unittest
from math import sqrt
from homework import Rectangle
class Test(unittest.TestCase):
def setUp(self):
self.width, self.height = 4, 6
self.rectangle = Rectangle(self.width, self.height)
def test_1_rectangle_perimeter(self):
cheack = (self.width+self.height)*2
res... |
c070bca30bc6fdfd35e3a42a25b28e08706fd493 | KhaledAchech/Problem_Solving | /CodeForces/Easy/Elements.py | 1,117 | 4 | 4 | """
Mohsen woke up late, his phone ran out of battery so it got shut down and didn't ring. He packed his things fast and left in a hurry.
After leaving home, he remembered he only took n elements that he left on his desk and he doesn't know whether the element with the value k is one of the elements on the desk or not... |
8c44895f64d1161588c25e339ff6b23c82d8290e | KhaledAchech/Problem_Solving | /CodeForces/Easy/File Name.py | 2,425 | 4.375 | 4 | """
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the s... |
ce63e853ae26f4e03b98654b6e51b7f0540bb084 | KhaledAchech/Problem_Solving | /CodeForces/Easy/Longest Prefix.py | 936 | 3.8125 | 4 | """
You are given two strings a and b. Find the longest common prefix between them after performing zero or more operation on string b. In each operation you can swap any two letters.
Input
The first line of the input contains an integer T (1 ≤ T ≤ 500), where T is the number of the test cases.
Each case has one line... |
33290292667e0df5ef32c562b2320933446a118e | KhaledAchech/Problem_Solving | /CodeForces/Easy/Helpful Maths.py | 1,112 | 4.21875 | 4 | """
Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough fo... |
25eb3f1f37afa3f64f5045b5978e3ba17335baeb | KhaledAchech/Problem_Solving | /CodeForces/Easy/Bachgold Problem.py | 880 | 4 | 4 | """
Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.
Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.