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 |
|---|---|---|---|---|---|---|
24a9a34002a667ac5063e56f991d803ae112d1ba | mootfowl/dp_pdxcodeguild | /python assignments/lab03_madlib01.py | 506 | 3.609375 | 4 | adjective01 = input("Enter an adjective. > ")
noun01 = input("Name a noun. > ")
verb_past_tense = input("And now a past tense verb. > ")
adverb = input("How about an adverb? > ")
adjective02 = input("One more adjective. > ")
noun02 = input("And finally, one last noun. > ")
print("Today I went to the zoo and saw a... |
3967fad907d30a59282306b168bfd3fa032bfaa9 | mootfowl/dp_pdxcodeguild | /python assignments/lab10_unit_converter_v3.py | 1,466 | 4.34375 | 4 | '''
v3 Allow the user to also enter the units.
Then depending on the units, convert the distance into meters.
The units we'll allow are inches, feet, yards, miles, meters, and kilometers.
'''
def number_crunch():
selected_unit = input("Pick a unit of measurement: inches, feet, yards, miles, meters, or kilometers. ... |
d900cef1d0915808b0b213a6339636bf2dd3dcd2 | mootfowl/dp_pdxcodeguild | /python assignments/lab15_ROT_cipher_v1.py | 971 | 4.15625 | 4 | '''
LAB15: Write a program that decrypts a message encoded with ROT13 on each character starting with 'a',
and displays it to the user in the terminal.
'''
# DP note to self: if a = 1, ROT13 a = n (ie, 13 letters after a)
# First, let's create a function that encrypts a word with ROT13...
alphabet = 'abcdefghijklmnop... |
363feaccd97bf2220c50d1e26900f1e50514f112 | xdexer/ModelowanieKomputerowe | /Lista5/lorenz.py | 671 | 3.515625 | 4 | import numpy as np
import matplotlib.pyplot as plt
def lorenz(x, y, z, s=10, r=28, b=2.667):
x_dot = s*(y - x)
y_dot = r*x - y - x*z
z_dot = x*y - b*z
return x_dot, y_dot, z_dot
dt = 0.01
num_steps = 10000
xs = np.empty(num_steps + 1)
ys = np.empty(num_steps + 1)
zs = np.empty(num_steps + 1)
xs[0], ... |
65546b82ba65514c1e0fff178974a325dc270dd4 | mabuaisha/gradient-descent-python | /linear_regession.py | 2,007 | 3.515625 | 4 | # Standard imports
import os
# Third party imports
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def evaluate_cost_function(data, output, thetas):
m = len(output)
return np.sum((data.dot(thetas) - output) ** 2) / (2 * m)
def evaluate_gradient_descent(data, output, initial_thetas, a... |
1a5076cd2d4cb1c987e49461aedc4eac7516d66a | vinicius-m-santiago/python | /aniversario.py | 372 | 3.71875 | 4 | #execricio nascimento
meses = ("janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro")
data_aniversario = input("Insira a data do aniversario: ")
mes_aniversario = data_aniversario[3:5]
mes_aniversario_num = int(mes_aniversario) - 1
print("Seu anive... |
8982823fd433509659ee3fe1eb6a2414c6195b54 | MNabi2015/Kalkulator2000 | /calc2.py | 1,803 | 4.0625 | 4 | help1 = input("Добро пожаловать в наш калькулятор введите 1 чтобы включить функцию помощь нажмите 0 чтобы ее не включать")
if help1 == "1":
print("1 Введите первое число")
print("2 Нажмите 'Enter'")
print("3 Введите оператор")
print("4 Нажмите 'Enter'")
print("5 Введите Второе число")
print("6 Нажм... |
b7372899cb52561ed987c70a8cf9f675cae945d1 | gukexi/LearningPython | /create_tc/src/modules/create_tc_measure_points.py | 1,177 | 3.6875 | 4 | '''
Created on Jul 18, 2019
The module contains one function.
The function needs two input parameters.
The first input parameter is a list.
The second input parameter is txt file operating.
The function is to handling the list and save the comments to txt file.
@author: ekexigu
'''
from re import sub as s
def creat... |
67e5b41de7e06e397f62c9fb8156373d54bf8356 | FrancoValenteG/Trabajo2 | /Nueva carpeta/minisculas.py | 758 | 3.53125 | 4 | def lectura():
p = open("paises.txt","r")
paises = [linea.rstrip() for linea in sorted(set(p))]
p.close()
c = open("colores.txt","r")
colores= [linea.rstrip() for linea in sorted(set(c))]
c.close()
a = open("animales.txt","r")
animales= [linea.rstrip() for linea in sorted(s... |
1c8e6b53453f8050af95f63e889b21be04108124 | nclelw/Synonym-by-Association | /thesaurus.py | 4,268 | 3.859375 | 4 | import re
def read_common_words(filename):
'''
Reads the commmon words file into a set.
If the file name is None returns an emtpy set. If the file cannot be
opened returnes an empty set:
'''
words = set()
if filename != None:
try:
with open(filename) as fp:
... |
f29f512a17e420939afd3f9899127a43aaa3ae73 | tomgprice411/Medium_Article_Tutorial_Bar_Plotly_Python | /graph_article_script.py | 22,033 | 3.515625 | 4 | import pandas as pd
import plotly.graph_objects as go
import os
from plotly.subplots import make_subplots
#######################
# Data Transformation #
#######################
##########
# Step 1 #
##########
os.chdir("/mnt/c/Users/tom_p/Spira_Analytics/Medium_Articles/Plotly_Guide_Bar_Chart")
#read data
df_raw ... |
ad395106bc1da74199adb7776213842c504f7787 | embarced/micro-moves | /modules/chess-diagrams/draw.py | 4,961 | 3.734375 | 4 | import PIL.Image
import PIL.ImageDraw
import PIL.ImageFont
SQUARE_SIZE = 32
BORDER_SIZE = int(SQUARE_SIZE / 2)
BOARD_SIZE = int(SQUARE_SIZE * 8 + 2 * BORDER_SIZE)
BOARD_COLOR_LIGHT = 'white'
BOARD_COLOR_DARK = 'lightgray'
BOARD_COLOR_BORDER = 'darkgray'
BOARD_COLOR_KEY = 'white'
FONT_PATH = 'fonts/'
FONT_FILENAME... |
5390daf4169e82d71c1fa59a7ae42aa706fd7681 | OnyiegoAyub/SENDIT-API | /app/api/v1/models/user_models.py | 627 | 3.5 | 4 |
class User:
users = []
def create(self, username, role, email, password):
new_user = {"user_id": len(User.users) + 1,
"username": username,
"role": role,
"email":email,
"password":password
}
Use... |
e13cc147ffdbc71ac3b178974cfc8cf1e9b9f54d | Tonoyama/2020AB | /regular/112/a.py | 237 | 3.5 | 4 | from typing import List, Dict
T = int(input())
case: List[int] = [list(map(int, input().split())) for _ in range(T)]
for i in range(T):
R: List[int] = case[i][1]
L: List[int] = case[i][0]
for j in range(R):
print(j) |
e2c6e14a312b34b85b6e5f65f01ff0b5642ad418 | GioPan04/tools | /resistenze.py | 1,214 | 3.71875 | 4 | from tabulate import tabulate
COLORS = ['black', 'brown', 'red', 'orange', 'yellow', 'green', 'blue', 'purple', 'grey', 'white', 'gold', 'silver']
TOLL = {
'gold': 5.0,
'silver': 10.0,
'brown': 1.0,
'red': 2.0,
'orange': 3.0,
'green': 0.5,
'blue': 0.25,
'purple': 0.1,
'grey': 0.05,
}
HEADER = ['Colors', 'Resu... |
cc9dcf38f7b7285a08d4a92b894ea9b7ee103ea8 | DEEPESH98/Basic_Python_Programs | /reverse_string.py | 779 | 3.953125 | 4 | '''
Given a string S, check if it is palindrome or not.
Input:
The first line contains 'T' denoting the number of test cases. T testcases follow. Each testcase contains two lines of input. The first line contains the length of the string and the second line contains the string S.
Output:
For each testcase, in a new l... |
0d5ba0b5e7961f60e977a9f0f476ad6da232dfdb | MAHESHRAMISETTI/My-python-files | /mon.py | 506 | 4.0625 | 4 | num1=int(input('enter a numb\t'))
num2=int(input('enter a number\t'))
print(type(num1))
print(type(num2))
print(num1+num2)
num=int(input('enter a number\t'))
if num%2==0:
print(num,'is an even number')
else:
print(num,'is an odd number')
num=int(input('enter a number\t'))
if num>=0:
if num==0:
print('ze... |
757561a712817637e4ed8606863076259be38ece | MAHESHRAMISETTI/My-python-files | /time.py | 311 | 3.609375 | 4 | # num=int(input('enter the value'))
# for a in range (1,11):
# print(num,'x',a,'=',num*a)
# import time
# print(dir(time))
# print(time.asctime())
# import math
# print(dir(math))
# print(math.factorial(5))
import calendar
# print(dir(calendar))
print(calendar.calendar(2018,8))
#
# print('dasdasd')
|
4471df91a50681366a7f8d154aa5815a71bfb82b | goussous0/old_scripts | /iterexample.py | 696 | 3.71875 | 4 | from itertools import product
def gen_sets(set1, set2):
x1 = len(set1)
y1 = len(set2)
tmp_lst = []
for item in set1:
x = set1.index(item)
set1[x]=int(item)
for item in set2:
x = set2.index(item)
set2[x]=int(item)
## reverse the places of the set1 ... |
858422c01e9d9390216773f08065f38a124cb579 | monicaneill/PythonNumberGuessingGame | /guessinggame.py | 1,724 | 4.46875 | 4 | #Greetings
print("Hi there! Welcome to Monica's first coding project, 'The Python Number Guessing Game'!")
print("Let's see if you can guess the number in fewer steps than the computer openent. Let's begin!")
#Computer Function
def computerGuess(lowval, highval, randnum, count=0):
if highval >= lowval:
... |
6b23ea66355b94f81be58d2bd546499225c173fa | peterhchen/800_MachineLearning | /09_feature_selection/01_UnivarSelection.py | 1,108 | 3.5625 | 4 | # Univariable Selection
from pandas import read_csv
from numpy import set_printoptions
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2
path = r'..\csv_data\pima-indians-diabetes.csv'
headernames = ['preg', 'glucos', 'pres', 'skin', 'insulin', 'mass', 'diabetes', 'age',... |
0a517656681efc1b179ca047ed54e2e210567824 | tnaswin/PythonPractice | /Aug18/recursive.py | 406 | 4.21875 | 4 | def factorial(n):
if n <= 1:
return 1
else:
return n * (factorial(n - 1))
def fibonacci(n):
if n <= 1:
return n
else:
return (fibonacci(n - 1) + (fibonacci(n - 2)))
n = int(raw_input("Enter a number: "))
if n <= 0:
print("Plese enter a positive integer")
else:
print "Factorial: ", fact... |
75049954b1f4fdaf4acf1d414e3e57ba942e256e | tnaswin/PythonPractice | /Aug17/files.py | 408 | 3.578125 | 4 | my_list = [i ** 2 for i in range(1, 11)]
my_file = open("text.txt", "w")
for item in my_list:
my_file.write(str(item) + "\n")
my_file.close()
###
my_file = open("text.txt", "r")
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()
with open("text.txt", "w") as my_file:
... |
71d2b99011c006646b6fe9d40fb0a8ffc162bf05 | aisaav/ML-mini-projects | /Forest-Fire-Forecast/Module4.py | 3,339 | 3.6875 | 4 | import numpy
import pandas
from matplotlib import pyplot as plt
# region Making Printing more visible
from pandas.plotting import scatter_matrix
pandas.set_option('display.max_columns', None)
pandas.set_option('display.max_rows', None)
# endregion
# region Loading Our Data
filename = 'forestfires.csv'
names... |
0c47ce184534d698be92f724929ae23e17976754 | yiclwh/System-Design | /7_1_1_Geohash II.py | 1,440 | 3.640625 | 4 | """
This is a followup question for Geohash.
Convert a Geohash string to latitude and longitude.
Try http://geohash.co/.
Check how to generate geohash on wiki: Geohash or just google it for more details.
Example
Given "wx4g0s", return lat = 39.92706299 and lng = 116.39465332.
Return double[2], first double is lati... |
235b284c39e646997ba74bc4d7ac2539bd07786f | yiclwh/System-Design | /2_1_2_Memcache.py | 3,856 | 4.0625 | 4 | """
Implement a memcache which support the following features:
1. get(curtTime, key). Get the key's value, return 2147483647 if key does not exist.
2. set(curtTime, key, value, ttl). Set the key-value pair in memcache with a time to live (ttl). The key will be valid from curtTime to curtTime + ttl - 1 and it will be e... |
38c175384378c0872e846afc2f625e596dbcc0cd | nadahalli/algorithm-puzzles | /heapsort.py | 791 | 3.546875 | 4 | a = [1, 10, 15, 20]
b = [2, 3, 5, 10, 11, 14]
c = [100]
d = [10, 20, 30, 40, 50]
e = [1, 2, 3, 4, 5, 6, 7, 8]
arr = [a, b, c, d, e]
def heapify(arr, i, n):
left = 2 * i
right = 2 * i + 1
large = None
if left < n and arr[left] > arr[i]:
large = left
else:
large = i
if right < n ... |
35844bacab782c0d4e39c65c5aadf4f85c542723 | nadahalli/algorithm-puzzles | /mergesort.py | 761 | 3.84375 | 4 | def mergesort(a, b, start, end):
if start + 1 == end:
return
else:
mid = (start + end)/2
mergesort(a, b, start, mid)
mergesort(a, b, mid, end)
i = start
j = mid
k = start
while i < mid and j < end:
if a[i] < a[j]:
b[k] = a[i]
i += 1
... |
efb37f6b9022f9476258753e835768075e989a56 | nadahalli/algorithm-puzzles | /manual_stack_recursions.py | 733 | 3.84375 | 4 | from collections import deque
def factorial(n):
stack = deque()
stack.appendleft(n)
fact = 1
while len(stack):
i = stack.popleft()
if i == 0:
fact *= 1
break
fact *= i
stack.appendleft(i - 1)
return fact
print factorial(5)
def binsearch(a, i... |
0e5c69430dcddf93721e19e55a54d131394ca452 | montoyamoraga/nyu-itp | /reading-and-writing-electronic-text/classes/class_02/cat.py | 2,211 | 4.125 | 4 | # import sys library
import sys
# this is a foor loop
#stdin refers to the lines that are input to the program
#typical python styling is indenting with four spaces
for line in sys.stdin:
#strip() removes whitespace at the end of the line
#strip() is a method of a line object
line = line.strip()
if "yo... |
47c9f72baa7577f726046a80f338e40fd199bb61 | montoyamoraga/nyu-itp | /reading-and-writing-electronic-text/assignments/assignment_04/this.py | 2,031 | 4.1875 | 4 | #assignment 04
#for class reading and writing electronic text
#at nyu itp taught by allison parrish
#by aaron montoya-moraga
#february 2017
#the digital cut-up, part 2. write a program that reads in and creatively re-arranges the content of several source texts. what is the unit of your cut-up technique? (the word, th... |
3c662f42d4491fe70972bb45bb28cdc9668ba90a | littleironical/HackerRank_Solutions | /Python/Text Wrap.py | 304 | 3.8125 | 4 | import textwrap
def wrap(string, max_width):
for i in range(0, len(string), max_width):
newLine = [string[i:i+max_width]]
print(newLine[0])
return ""
if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
|
c77eea14ca502183ed0b6eb51e7e8c01041384b3 | littleironical/HackerRank_Solutions | /Python/Lists.py | 597 | 3.515625 | 4 | n = int(input())
lis = []
temp1, temp2 = 0, 0
for _ in range(n):
line = input().split()
if line[0] == "print":
print(lis)
elif line[0] == "sort":
lis.sort()
elif line[0] == "pop":
lis.pop()
elif line[0] == "reverse":
lis.reverse()
elif line[0] == "append":
... |
393e43f1550a44dc57f3527e5665a7b5db4e9097 | VelmirS/lesson2 | /while1.py | 585 | 4.0625 | 4 | """
Домашнее задание №1
Цикл while: ask_user
* Напишите функцию ask_user(), которая с помощью input() спрашивает
пользователя “Как дела?”, пока он не ответит “Хорошо”
"""
def ask_user():
while True:
user_input = input('Как дела?\n')
if user_input == 'Хорошо':
return ('Если у вас все хорошо,... |
e7f50e19dbf531b0af4ae651759d714278aac06b | ribeiroale/rita | /rita/example.py | 498 | 4.21875 | 4 | def add(x: float, y: float) -> float:
"""Returns the sum of two numbers."""
return x + y
def subtract(x: float, y: float) -> float:
"""Returns the subtraction of two numbers."""
return x - y
def multiply(x: float, y: float) -> float:
"""Returns the multiplication of two numbers."""
return x ... |
048180879cef5c8d0b4ae185904d72a836d195f0 | Dhinessplayz/Python | /chess/minimax.py | 2,716 | 4 | 4 | import random
class MinimaxState(object):
"""
Abstract base class of game states suitabe for minimax.
Games that fit this model have two players, and a set of terminal states
with well-defined values. One player tries to minimize the final value
(min), and one tries to maximize it (max). The... |
ed6df28cd4ffe946d3e4cb93f856b9f0f93e2cb6 | NritiNy/AdventOfCode2020 | /Day01.py | 910 | 3.609375 | 4 | #!/usr/bin/python
import sys
def part1():
with open(filename, "r") as f:
lines = f.readlines()
numbers = [int(str(line).strip()) for line in lines]
for i in range(len(numbers)-2):
for j in range(i+1, len(numbers)-1):
if numbers[i] + numbers[j] == 2020:
... |
a3d5fb2f9f597dc7e0cab5691a5a4bbd4cc4a964 | rohankokkula/streamlit-sandbox | /python-scripts/hello-streamlit-world.py | 543 | 3.84375 | 4 | # Angelo's first python script in Spyder
import streamlit as st
# To make things easier later, we're also importing numpy and pandas for
# working with sample data.
st.title('LiRA - The Linear Regression App')
st.header('H1')
st.write("Hello Streamlit World")
st.write('To start with we will simulate a Linear Function... |
299cc5fc729fef69fea8e96cd5e72344a1aa3e12 | voyeg3r/dotfaster | /algorithm/python/getage.py | 1,075 | 4.375 | 4 | #!/usr/bin/env python3
# # -*- coding: UTF-8 -*-"
# ------------------------------------------------
# Creation Date: 01-03-2017
# Last Change: 2018 jun 01 20:00
# this script aim: Programming in Python pg 37
# author: sergio luiz araujo silva
# site: http://vivaotux.blogspot.com
# ... |
00c75c7761a99938db0045e90ef7b8228a83fa45 | TonySteven/Python | /upper.py | 375 | 3.578125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# @Time : 2018/7/27 10:40
# @Author : StevenL
# @Email : stevenl365404@gmail.com
# @File : UUID.py
a = input("请输入字符:")
b = []
for n in a :
if "a"<= n <= "z":
b.append(n.upper())
# elif"A" <= n <= "Z" :
# b.append(n.lower())
elif n == " " :
... |
099a230b32ffd60a2d1b8c2732ba7ba7ba162b50 | jesadrperez/Fundamentals-of-Computing | /An Introduction to Interactive Programming in Python/Mini-project #2 - Guess the Number.py | 2,505 | 4.0625 | 4 | #http://www.codeskulptor.org/#user42_umEoHc2oUY_7.py
import random
import simplegui
num_range = 100
remaining = 7
def set_remaining():
global num_range
global remaining
if num_range == 100:
remaining = 7
else:
remaining = 10
# helper function to start and restar... |
a2b3e4e9aadfb289399d5ed98fae73126a77aa23 | jesadrperez/Fundamentals-of-Computing | /Algorithmic Thinking/Project-1.py | 3,566 | 4.40625 | 4 | '''
Python code that creates dictionaries corresponding to
some simple examples of graphs. Implement two short
functions that compute information about the distribution
of the in-degrees for nodes in these graphs.
'''
# Representing Directed Graphs
EX_GRAPH0 = {0:set([1,2]),
1:set([]),
... |
6f15774dca28c6a77b829fd983f57d46e8f183d1 | karinamonetti/curso_universidadPython | /clases.py | 2,778 | 3.78125 | 4 | class Persona:
pass # se utiliza para no agregar contenido.
print(type(Persona))
# class MiPersona:
# def __init__(self): #objeto inicializador
# parámetro <--- self.nombre="Karina" ---> atributo
# self.edad=26
# self.nacionalidad="ARG"
# ... |
89ab7388f9fc37df596b50753ecb5562392d1737 | karinamonetti/curso_universidadPython | /ejercicio_calificaciones.py | 727 | 3.96875 | 4 | def tuCalificacion():
calificacion=int(input("Ingresa una calificación entre 0 y 10: "))
nota=None
if calificacion>=0 and calificacion <6:
nota="F"
print(f"Tu calificación es de {nota}")
elif calificacion >=6 and calificacion <7:
nota="D"
print(f"Tu calificación es de {no... |
e09c64d065f889680dacc7f98bc63a247935ef94 | karinamonetti/curso_universidadPython | /notas_universidadPython.py | 599 | 3.875 | 4 | x=2
print(type(x))
title=input("Tell me the title of the book: ")
author=input("Tell me the author of the book: ")
print(title, "was write for ", author)
print(f"{title} was write for {author}") # --> idem que ${} en JS
alto=int(input("Dime el alto del rectángulo...:"))
ancho=int(input("Dime el ancho del rectángulo... |
b5f3d831f2ad273bf1f29e2e3fdd657e556bbb81 | mohitrocky/Maze-Genarator | /maze-generation/maze/visualizers.py | 520 | 3.515625 | 4 | import time
def visualize_algorithm(maze, canvas, generator, speed):
def inner():
maze.draw(canvas)
for action, (c1, c2) in generator(maze):
if action == 'connect':
maze.connect(c1, c2)
maze.draw_line_between(canvas, c1, c2, color='white')
eli... |
4d0147222d8383348fbb2760eada34089a4df4da | praveenvenkata21/pythonex | /question11.py | 243 | 4.03125 | 4 | num=input("Enter a number:")
size=len(num)
num=int(num)
temp=num
sum1=rem=0
while temp!=0:
rem=temp%10
sum1+=rem**size
temp//=10
if sum1==num:
print(num,"is a armstrong number")
else:
print(num,"is not a armstrong number")
|
61abbd616bd21aa13fa6f7d68159154e851da3ad | livochka/domain-independent-planning | /problems_generator/map.py | 4,778 | 3.78125 | 4 | from random import randint
import networkx as nx
import matplotlib.pyplot as plt
from math import floor, sqrt
class Connection:
"""
Represents a connection between two nodes in a graph
"""
FACT_CONNECTED = "(connected {} {})"
FACT_DISTANCE = "(= (distance {} {}) {})"
def __init__(self, nodes... |
d9eddfd175dd379bd8453f908a0d8c5abeef7a29 | bbullek/ProgrammingPractice | /bfs.py | 1,536 | 4.1875 | 4 | ''' Breadth first traversal for binary tree '''
# First, create a Queue class which will hold nodes to be visited
class Queue:
def __init__(self):
self.queue = []
def enqueue(self, item):
self.queue.append(item)
def dequeue(self):
return self.queue.pop(0)
def isEmpty(self):
return len(self.queue) == 0
... |
85d04146fea3cdcab3872fe34e247c7fc4b6372d | Evymendes/Modulo3 | /randomsorteio.py | 359 | 3.921875 | 4 | import random
sorteio = random.randint(1,30)
tentativas = 0
while tentativas < 3 :
tente = int(input('Digite um número de 1 à 30: '))
print(sorteio)
tentativas = tentativas + 1
if tente == sorteio:
print('Você acertou na ' + str(tentativas) + ' tentativa!')
break
else:
print('Não foi desta vez... O número ... |
7697cd46b036d982721cb4ce4d2ca85e498469ca | Evymendes/Modulo3 | /dictionary.py | 672 | 3.703125 | 4 | '''
sammy = {
'username': 'sammy-shark',
'online': true,
'followers': 987
}
1- Escreva um dicionário sobre o perfil de um usuário do Gitbub.
2- Adicione novos campos a esse dicionários
3- Exiba esse dicionário mostrando cada chave e valor.
'''
username = {
'username': 'Evelyn',
'repositorios': '19',
'follo... |
4b8238566ade0eebf17e864b2d2c13cee28ff1f2 | Evymendes/Modulo3 | /cachorroquente.py | 266 | 3.515625 | 4 | preço = int(input('Valor do Hot-Dog?\n'))
cliente = input('Nome do cliente?\n')
quant = int(input('Quantos Hot-Dog?\n'))
pagar = preço * quant
print('O cliente ' + cliente + ' comprou ' + str(quant) + ' cachorros quentes e vai pagar R$ ' + str('%.2f'% pagar )) |
e8dd510d9976126d0e835a93c8335bfb13913600 | leoua7/clu-clu-game | /game/sprites/text.py | 4,214 | 3.546875 | 4 | import pygame as pg
from game.sprites.sprite_sheet import SpriteSheet
import game.tools.constants as c
class PointsSprite(pg.sprite.Sprite):
"""Create a sprite of the 100 points text.
Attributes:
pointsImage: A Surface object to be used as the sprite's image.
passingDirection: A Directions E... |
755b7474f1481fdf7867cca3f6b5c96e32b6d387 | leoua7/clu-clu-game | /game/tools/scores.py | 1,267 | 3.703125 | 4 | import os
import game.tools.constants as c
def getHighScore():
"""Get the current high score saved in a text file in the game folder.
This function only acknowledges the six rightmost digits of a high score (i.e., it reads 1234567 as 234567,
or 6 as 000006).
If highScoreFile does not exist, this fun... |
334ecf7709cf5c968f60bed07508c489dc6eb0a4 | heoun/RPADevCourse | /libraries_and_os.py | 825 | 3.828125 | 4 | # Python RPA Developer Course
# Reading and Writing Files, OS utilities, and Libraries
# first lets define a valid file path
mypath = r"C:\Users\david\Desktop\new_file.txt"
f = open(mypath, "w")
f.write("HELLO. THIS IS A TEST")
f.close()
import os
# Get current working directory
os.getcwd()
# libraries can have su... |
e06b62fbeb573314195b22ab32b994c9a4e2ea06 | ssalamancacruz/Proyecto | /proyecto.py | 688 | 3.703125 | 4 | #Ejemplo 1
def mostrar_lista(nodo):
for i in 5:
print(nodo)
nodo = nodo.siguiente
def mostrar_backward(list):
if list is None:return
cabeza = list
cola = list.siguiente
mostrar_backward(cola)
print(cabeza, end=" ")
class Nodo:
def __init__( self , dato=None , siguiente=None ):
... |
6feab9def4c2650d2ee732b1be131306906a1b29 | guandai/ud120-projects | /datasets_questions/explore_enron_data.py | 1,987 | 3.5 | 4 | #!/usr/bin/python
"""
Starter code for exploring the Enron dataset (emails + finances);
loads up the dataset (pickled dict of dicts).
The dataset has the form:
enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict }
{features_dict} is a dictionary of features associated with that pers... |
d113dd76991f1423658901abc9b886dffed3bf94 | cooolkiddoo/python-codes | /beginner/sum of n.py | 163 | 4.09375 | 4 | number=int(input("Enter a number: "))
sum46 = 0
while(number > 0):
sum46=sum46+number
number=number-1
print("The sum of first n natural numbers is",sum46)
|
47af0ac443a0453c600cf0e8d14952e4887656b7 | cooolkiddoo/python-codes | /beginner/alpha.py | 122 | 3.875 | 4 | b=raw_input()
print(b)
if(b>='a'):ot an Alphabe
print"Alphabet"
elif(b>='A'):
print"Alphabet"
else:
print"No"
|
17f30d9b41e3bac84534424877c3fc81791ef755 | jibachhydv/bloomED | /level1.py | 498 | 4.15625 | 4 | # Get the Number whose index is to be returned
while True:
try:
num = int(input("Get Integer: "))
break
except ValueError:
print("Your Input is not integer")
# List of Number
numbers = [3,6,5,8]
# Function that return index of input number
def returnIndex(listNum, num):
for i in ... |
6ee949d690435e1d6d9d4e95b0d5b9dc0ab47a79 | Blindshooter/lits-dp-003 | /hw1/t2.py | 384 | 4.03125 | 4 | def check_parenthesis(string):
pars = 0
for s in string:
#print pars
if s in ('(','[','{'):
pars+=1
elif s in (')',']','}'):
pars-=1
if pars==0:
print '('+string.translate(None, '[](){}')+')'
return True
else:
return False
str1 = ... |
68351e4e9525343707014cb2ea5141caf43d6c35 | Palash1999/Encryption-and-Verification-of-Message | /RSA.py | 605 | 3.703125 | 4 | def rsa_encrypt(e:int, n:int, msg: str):
# Convert Plain Text -> Cypher Text
cypher_text = ''
# C = (P ^ e) % n
for ch in msg:
# convert the Character to ascii (ord)
ch = ord(ch)
# convert the calculated value to Characters(chr)
cypher_text += chr((ch ** e) % n)
retu... |
499b7a62a8a995c977ec1832d8aa1a239cf2627f | xinetzone/XinetStudio | /XinetModel/Python学习/histogram.py | 1,732 | 3.5 | 4 | #-----------------------------------------------------------------------
# histogram.py
#-----------------------------------------------------------------------
import sys
import stdarray
import stddraw
import stdrandom
import stdstats
#-----------------------------------------------------------------------
class Hi... |
649407eaeb8fc12a32b493a1afe60182dd2d4d5e | xinetzone/XinetStudio | /XinetModel/Python学习/tenhellos.py | 593 | 3.5625 | 4 | #-----------------------------------------------------------------------
# tenhellos.py
#-----------------------------------------------------------------------
import stdio
# Write 10 Hellos to standard output.
stdio.writeln('1st Hello')
stdio.writeln('2nd Hello')
stdio.writeln('3rd Hello')
i = 4
while i <= 10:
... |
823845e68fa0996387193309d60e42b2036a5cae | xinetzone/XinetStudio | /XinetModel/Python学习/grayscale.py | 974 | 3.75 | 4 | #-----------------------------------------------------------------------
# grayscale.py
#-----------------------------------------------------------------------
import sys
import stddraw
import luminance
from picture import Picture
#-----------------------------------------------------------------------
# Accept the... |
0e1c7ec440fa2e1b389466da5716f73849074703 | GrahamOHagan/python_sandbox | /dictionary_test.py | 640 | 3.90625 | 4 | stuff = ["abc", "def", "ghi", "jkl", "mno", "pqr"]
def example(i, x={}):
x[i] = stuff[i]
print(x)
return x
def another(i):
x = {}
x[i] = stuff[i]
print(x)
return x
if __name__ == "__main__":
for i in range(6):
mydict = example(i)
print()
for i in range(6):
m... |
e4a48078d125102f2a154d5c7cf387b0f087b7a8 | ScroogeZhang/Python | /day03字符串/04-字符串相关方法.py | 1,185 | 4.21875 | 4 | # 字符串相关方法的通用格式:字符串.函数()
# 1.capitalize:将字符串的首字母转换成大写字母,并且创建一个新的字符返回
str1 = 'abc'
new_str = str1.capitalize()
print(new_str)
# 2.center(width,fillerchar):将原字符串变成指定长度并且内容居中,剩下的部分使用指定的(字符:长度为1的字符串)填充
new_str = str1.center(7,'!')
print(str1,new_str)
# 3.rjust(width,fillerchar)
new_str = str1.rjust(7,'*')
print(new_str)... |
29ce22bbee4710c4d2357f0eaea7cb73588aac38 | ScroogeZhang/Python | /day02语法基础/04-运算符.py | 3,431 | 4.34375 | 4 | # 数学运算符,比较运算符,逻辑运算符,赋值运算符,位运算符
# 1.数学运算符(+,-,*,/,%,**,//)
# +: 求和
# 注意:求和操作,+两边必须是数字类型
# True --> 1 , False --> 0
print(10+20.4,True+1)
number = 100 + 11
print(number)
# - :求差
print(100-12)
# * : 求乘积
print('chengji:'+str(3.12*2))
number = 3 * 9
# / : 求商
print(4/2)
print(5/2)
# % : 取余
print(3%2)
print(101%10)
# ... |
037b5264c6d0e8be1fcc98b978a6829b4e7523d8 | ScroogeZhang/Python | /day06 列表,元祖,字典,集合/复习.py | 985 | 3.734375 | 4 | # -*- coding: UTF-8 -*-
# @Time : 2018/7/24 8:52
# @Author :Hcy
# @Email : 297420160@qq.com
# @File : 复习.py
# @Software : PyCharm
'''
列表:[1,3,'a','12abc']
元素 in 列表
+:链接
*:列表重复
都是创建一个新的列表
'''
for item in [{'a':10}, {'b':100}, {'a':1}]:
print(item)
'''
元祖:不可变,有序
(1,'yu')
'''
a = (1, 2)
print(a, type(a))
b = (1... |
61cc074563240c4e6f6835b1bf6be450b76956a9 | ScroogeZhang/Python | /day04 循环和分支/04-while循环.py | 951 | 4.1875 | 4 | # while循环
'''
while 条件语句:
循环体
其他语句
while:关键字
条件语句: 结果是True,或者False
循环体:重复执行的代码段
执行过程:判断条件语句是否为True,如果为True就执行循环体。
执行完循环体,再判断条件语句是否为True,如果为True就在执行循环体....
直到条件语句的值为False,循环结束,直接执行while循环后面的语句
注意:如果条件语句一直都是True,就会造成死循环。所以在循环体要有让循环可以结束的操作
python 中没有do-while 循环
'''
# 死循环
# while True:
# print('aaa')
flag = ... |
b4fe332072fd7009bf1e921226829a130c458d45 | ScroogeZhang/Python | /day12 面向对象基础1/01-迭代器和生成器.py | 1,471 | 3.828125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2018/7/31 8:52
# @Author :Hcy
# @Email : 297420160@qq.com
# @File : 01-迭代器和生成器.py
# @Software : PyCharm
"""
生成器:a.可以看成一个可以西存储多个数据的容器。
需要里面的数据的时候就生成一个,里面的数据只能从前往后一个一个的生成
不能跳跃,也不能从后往前。生成的数据,不能再生成了
b.获取生成器里面的数据,需要使用__next__()方法
c.只要函数生命中有yield关键字,函数就不在是一个单纯的函数,而变成一个生成器
... |
79c4584eb2cae10c882162f315f213dcaa734949 | ScroogeZhang/Python | /day03字符串/05-if语句.py | 1,131 | 4.5 | 4 | # if语句
# 结构:
# 1.
# if 条件语句:
# 条件语句为True执行的代码块
#
# 执行过程:先判断条件语句是否为True,
# 如果为True就执行if语句后:后面对应的一个缩进的所有代码块
# 如果为False,就不执行冒号后面的一个缩进中的代码块,直接执行后续的其他语句
#
# 条件语句:可以使任何有值的表达式,但是一般是布尔值
#
#
# if : 关键字
if True:
print('代码1')
print('代码2')
print('代码3')
print('代码4')
# 练习:用一个变量保存时间(50米短跑),如果时间小于8秒,打印及格
time = 7
if time <... |
d7785df08f821469f287bfe9854fc977a539c425 | ScroogeZhang/Python | /day05 练习和列表/01-作业.py | 2,697 | 3.671875 | 4 | # 1.
number = 1
for i in range(0,20):
number *= 2
print(number)
# for 循环中,如果for后面的变量在循环体中不需要,这个变量命名的时候可以用'_'命名
# for _ in range(20)
# 2的20次方
# 2.
# sum1 = 0
# num = 1
# while num <= 100:
# if ((num%3==0) or (num%7==0)) and (num%21 != 0):
# sum1 += 1
# num += 1
# print(num)
# 能被3或7整除 且不能被21整除得数
# 1.求1到100之... |
fca406d84960938a40a1d2216983f2c07efa374e | Suraj-S-Patil/Python_Programs | /Simple_Intrst.py | 246 | 4.125 | 4 | #Program to calculate Simple Interest
print("Enter the principal amount, rate and time period: ")
princ=int(input())
rate=float(input())
time=float(input())
si=(princ*rate*time)/100
print(f"The simple interest for given data is: {si}.")
|
ee361861525868e58f690106aa7c13ce67850a80 | 26point2Newms/data-structures-and-algorithms | /python/CNLRUCache.py | 1,278 | 3.796875 | 4 | '''
Created on July 15, 2020
@author: charles newman
https://github.com/26point2Newms
'''
from collections import OrderedDict
class LRUCache(object):
'''
Implementation of a Least Recently Used Cache (LRU Cache) which discards
the least recently used items first.
'''
def __init__(self, capacity)... |
f6cc44b114538fec05ab11e704eb441deb8a7d86 | 26point2Newms/data-structures-and-algorithms | /python/testQuickSort.py | 551 | 3.796875 | 4 | '''
Created on Aug 3, 2020
@author: charles newman
https://github.com/26point2Newms
'''
import unittest
import CNQuickSort
class Test(unittest.TestCase):
def setUp(self):
self.numbers = [54, 789, 1, 44, 789, 321, 852, 32456, 2, 88, 741, 258, 369, 951, 753]
def testQuickSort(self):
print("Before sort:")
prin... |
c74d43ba97660057da398e186e9abca78cd381ec | dvisionst/quiz-game-start | /main.py | 737 | 3.640625 | 4 | from question_model import Question
from data import question_data
from quiz_brain import QuizBrain
# Creating variables in order to loop through the question_data list
# loop will populate a new list with Question object and respective attributes
question_bank = []
for dictionary in question_data:
text_q = dicti... |
f315e9320453868c93587bf014d8d0751b90633d | FeuerFeuer/2015Computing-Lab-Practice2 | /q05_find_month_days.py | 534 | 3.859375 | 4 | months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec"]
n = int(input("Enter year: "))
m = int(input("Enter month: "))
n1 = n % 4
n2 = n % 100
n3 = n % 400
if m == 1 or m == 3 or m == 5 or m == 7 or m == 8 or m == 10 or m == 12:
print(months[m-1],n,"has 31 days")
elif m == 4 ... |
d552de01cad51b019587300e6cf5b7cbc5d3122f | Cherol08/finance-calculator | /finance_calculators.py | 2,713 | 4.40625 | 4 | import math
#program will ask user if they want to calculate total investment or loan amount
option = """ Choose either 'investment' or 'bond' from the menu below to proceed:\n
Investment - to calculate the amount of interest you'll earn on interest
Bond - to calculate the amount you'll have to pay on a home loan\n "... |
f8249149f1eede2fa7e00b129bb427c2383b8f2f | jasonskipper/CompetitiveProgramming | /AlgoExpert/python/ValidateSubsequence.py | 281 | 3.546875 | 4 | def isValidSubsequence(array, sequence):
array_index = 0
sequence_index = 0
while array_index < len(array) and sequence_index < len(sequence):
if array[array_index] == sequence[sequence_index]:
sequence_index += 1
array_index += 1
return sequence_index == len(sequence)
|
53ff749da41ea256ca021cee5b8247da41ad81b1 | gkanishk44/Python-Projects | /temperature converison.py | 115 | 4 | 4 | celsius=int(input("Enter the temperature in celcius:"))
f=(celsius*1.8)+32
print("Temperature in farenheit is:",f)
|
7c8d1c98423ee1839302522f2071155f1f7cfd98 | gkanishk44/Python-Projects | /rockpaperscissors.py | 2,113 | 3.828125 | 4 | from tkinter import *
import random
root = Tk()
root.geometry('400x400')
root.resizable(0,0)
root.title('DataFlair-Rock,Paper,Scissors')
root.config(bg ='seashell3')
Label(root, text = 'Rock, Paper ,Scissors' , font='calibri 20 bold', bg = 'violet').pack()
user_take = StringVar()
Label(root, text = 'choose any one... |
520890a37552ea6c4cc3c2ef12daa6f432b93de4 | gargchirayu/Algorithmic-Toolbox | /week3_greedy_algorithms/1_ change.py | 476 | 3.53125 | 4 | # Uses python3
import sys
def get_change(m):
n = 0
iter = 0
while (m != 0):
if iter == 2:
n = n + m
m = 0
elif iter == 1:
fives = m // 5
n = n + fives
m = m % 5
iter = 2
else:
tens = m // 10
... |
8efede982b64c7276e24e6d6db21cc04583f81be | amithjkamath/codesamples | /python/lpthw/ex8.py | 529 | 4.03125 | 4 | # This is an example with more text manipulation than before.
# Amith, 01/02
formatter = "%r %r %r %r"
print formatter % (1,2,3,4) # This prints numbers using %r
print formatter % ('one', "two", 'three', "Four") # This prints numbers as text using %r
print formatter % (True, False, True, False) # This prints boolean ... |
90c6247ac1d1a579952fb0a9900e3ce93ead122e | amithjkamath/codesamples | /python/lpthw/ex11.py | 438 | 4.0625 | 4 | # This exercise introduces command line inputs.
# Amith, 01/03
print "How old are you?"
age = raw_input()
print "How tall are you (in centimeters)?"
height = raw_input()
print "How much do you weigh (in lbs)?"
weight = raw_input()
print "So, you're %r years old, %r centimeters tall, and %r lbs heavy!" % (
age, height... |
462321abc830736f71325221f81c4f5075dd46fb | amithjkamath/codesamples | /python/lpthw/ex21.py | 847 | 4.15625 | 4 | # This exercise introduces 'return' from functions, and hence daisy-chaining them.
# Amith, 01/11
def add(a, b):
print "Adding %d + %d" % (a,b)
return a + b
def subtract(a, b):
print "Subtracting %d - %d" % (a,b)
return a - b
def multiply(a,b):
print "Multiplying %d * %d" % (a,b)
return a*b
... |
d0479ee3d6fbce482ccebef07edc9814564baed3 | SAV2288/card-game-21 | /21_oop.py | 4,732 | 3.640625 | 4 | import importlib
from random import shuffle
class Croupier:
"""Модель Крупье"""
cards = importlib.import_module('cards').cards
dict_cards_points = importlib.import_module('cards').points
def shuffle_the_deck(self):
"""Перетасовать колоду"""
shuffle(self.cards)
def give_card(sel... |
f0b314804a12280947dcc7ffeeb6282e11c4df22 | asantinc/practice_algos | /sorting/sorting/binary_search.py | 1,132 | 4.09375 | 4 | def binary_search_recursive(array, item, low=None, high=None):
low = low if low is not None else 0
high = high if high is not None else len(array)
mid = (low+high)/2
if low<mid:
if array[mid] > item:
return binary_search_recursive(array, item, low=low, high=mid)
elif array[mid] < item:
return binary_sear... |
5819eeef3987a90dc81a2e1a18be309406266cb1 | lisuizhe/algorithm | /leetcode/python/Q0133_Clone_Graph.py | 720 | 3.703125 | 4 | import queue
# Definition for a Node.
class Node(object):
def __init__(self, val, neighbors):
self.val = val
self.neighbors = neighbors
class Solution(object):
def cloneGraph(self, node):
"""
:type node: Node
:rtype: Node
"""
visited = dict()
def... |
588b68b13395c2753c0e78a92ef36ed6f2c03617 | lisuizhe/algorithm | /lintcode/python/Q0038_Search_a_2D_Matrix_II.py | 750 | 3.859375 | 4 | class Solution:
"""
@param matrix: A list of lists of integers
@param target: An integer you want to search in matrix
@return: An integer indicate the total occurrence of target in the given matrix
"""
def searchMatrix(self, matrix, target):
# write your code here
count = 0
... |
2e44cccb057aa7d0934d477bb9c521b21359a17b | lisuizhe/algorithm | /lintcode/python/Q0124_Longest_Consecutive_Sequence.py | 545 | 3.640625 | 4 | class Solution:
"""
@param num: A list of integers
@return: An integer
"""
def longestConsecutive(self, num):
# write your code here
numSet = set(num)
maxLength = 0
for i in numSet:
if (i - 1) not in numSet:
currentNum = i
c... |
9231f612a25f7efff978e90a571d335ef86c7970 | lisuizhe/algorithm | /lintcode/python/Q1172_Binary_Tree_Tilt.py | 701 | 3.84375 | 4 | """
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: the root
@return: the tilt of the whole tree
"""
def findTilt(self, root):
# Write your code here
self.tota... |
0d0af8973a5fb1eee0d42781bbb72f0a8a3f4319 | lisuizhe/algorithm | /lintcode/python/Q0024_LFU_Cache.py | 1,922 | 3.515625 | 4 | from collections import OrderedDict
class MyValue:
def __init__(self, value, frequency):
self.value, self.frequency = value, frequency
class LFUCache:
"""
@param: capacity: An integer
"""
def __init__(self, capacity):
# do intialization if necessary
self.capacity = capacity... |
f7fec4f76f44ec7f0d295176a10288d983f16ab2 | PreferredNerd/CMPSC132 | /Recursive Triangle.py | 1,472 | 4.0625 | 4 | #Lab #7
#Due Date: 02/22/2019, 11:59PM
########################################
#
# Name: Nicholas C. Birosik
# Collaboration Statement: Just Me, and my day off in this Happy Valley!
#
########################################
#### DO NOT modify the triangle(n) function in any wa... |
e896cb10efafca03e2bec2c1c69acb05d2e9f17f | PreferredNerd/CMPSC132 | /Max Heap Priority Queue.py | 6,202 | 3.625 | 4 | #Lab #12
#Due Date: 03/24/2019, 11:59PM
########################################
#
# Name: Nicholas C. Birosik
# Collaboration Statement: None, just me and TA Larry.
#
########################################
class MaxHeapPriorityQueue:
def __init__(self):
self.heap... |
15650e95e626831dd3fa569fb6fe8128e5529a15 | PreferredNerd/CMPSC132 | /Merge Sort.py | 3,259 | 4.0625 | 4 | #LAB 15
#Due Date: 04/05/2019, 11:59PM
########################################
#
# Name: Nicholas C. Birosik
# Collaboration Statement: Just me and Larry Lee. I also consulted Arron for help with the floor division aspect of the
# Second part of the assignment. I thought I had seen this concept dealt with in the heap ... |
ccd06d530f018d9471124a1b274ac5871dc75726 | Lucas210996/noyadeseche | /Exemple sans interface.py | 5,370 | 3.546875 | 4 |
from math import*
def jourexist(): #on crée une fonction qui permet de définir si le jour entré existe
if (jour >31 or jour <1):
return False
print("Veuillez saisir un jour correct")
return True
... |
bbc1d886fefc5e253fc83cf6abc507ba923af8c3 | lowks/ubelt | /ubelt/util_list.py | 1,976 | 4.09375 | 4 | # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import itertools as it
def take(items, indices):
r"""
Selects a subset of a list based on a list of indices.
This is similar to np.take, but pure python.
Args:
items (list): some indexab... |
cd935299254d7686c7faa052bc3a45ec874e7660 | frazermills/GCSE-Computer-Science-Homework | /Practicle-2/GUI-Calculator/Menu_System.py | 15,500 | 3.984375 | 4 | # Author: Frazer Mills
# Date: 05/03/21
# program name: 'Menu_System.py'
# Python 3.9.2
# Description: This module contains the Menu class, which handles the buttons and text rendering and processing.
import pygame
# ------------------------------------------- Menu Class ----------------------------------------- #
cl... |
be978ea10344389577386068b79cbf5c258916ae | BenDu89-zz/MoveWebsite | /media.py | 938 | 3.8125 | 4 | import webbrowser # To open urls in a webbrowser in the def show_movie
class Movies():
''' The class movie contains the basic data of the movie, as title, storyline, trailer url and poster image url'''
VALID_RATINGS = ["G","PG","PG-13","R"] # diffrent posible rankings for the movies
def __init__(self, ti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.