blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
29e12f026d3472eec9ffe7633221ff6d65c71454 | Br111t/pythonIntro | /pythonDict.py | 2,116 | 4.09375 | 4 | pythonDict = {
"input()":"reads user input to terminal",
"a**b":"raises a to the power of b",
"%":"Moudlo, returns the remainder of division",
"*":"Multiplication",
"-":"Subtraction",
"+":"Addition",
"=":"Assignment Operator",
"==":"Equality Boolean (T or F)",
"<=":"Less than or equal to",
... |
36f15556fe3b80d57d301dcdf9a447b1b0130e17 | sridivyapemmaka/PhythonTasks | /Project_atoz.py | 6,944 | 4.25 | 4 | print("Letter 'a'")
print()
for row in range(4):
for col in range(5):
if (row==0 and col%3!=0 and col!=4) or (row==1 and col%3==0) or (row==2 and col%3==0) or (row==3 and col%3!=0):
print("*",end="")
else:
print(" ",end="")
print()
print()
print("Letter 'b'")
p... |
ae8625f20b0eaf3537880e56b8c54c8dcab9e41f | shyams1993/qrcodegenerator-alternate | /qrimageusingpyqrcode.py | 542 | 3.65625 | 4 | import pyqrcode #import pyqrcode module
link_to_post = "https://www.google.com" #create variable link_to_post and save the target URL in that
url = pyqrcode.create(link_to_post) #create the URL as a qrcode by using pyqrcode.create() function
url.png('url.png', scale=8) #save the im... |
7e9dedbc3e7cb99bea3c4abf3c6682c629744432 | dttung2905/Pysnake | /PythonGame Final.py | 9,084 | 4.15625 | 4 | from pygame.locals import *
import pygame
import time
import random
pygame.init()
display_width = 800
display_height = 600
snake_width = 10
snake_height= 10
snake_margin= 1
snake_length= 10
# define all the color that is used in the game
black = (0, 0, 0)
white = (255, 255, 255)
red = (200, 0, 0)
green... |
0095aebe124388bac3f4f21b64827ac70854ea68 | antonskourides/lightenn | /usage_examples/feature_selection/feature_select.py | 6,438 | 3.984375 | 4 | ######################################################################
# Below we perform feature selection by logistic regression analysis.
#
# Our training set consists of vectors of randomly generated pixels,
# with intensities in the range [0, 255].
#
# Each vector has either a bright top-most pixel (at index 0) an... |
a622a57d15244b0970afca79752b6b05b3ed837d | CIgnacio-dev/Ejercicios-b-sicos-py | /Oferta.py | 568 | 3.6875 | 4 | cuadernos=int(input("Ingrese la cantidad de libros que va a comprar: "))
if cuadernos < 12:
print ("Ningun obsequio")
elif cuadernos >=12 and cuadernos <24:
lucas= int(cuadernos / 4)
print("Obsequio: ",lucas," lapiceros Lucas de regalo")
elif cuadernos >=24 and cuadernos <36:
cross=int(cuadernos/4)*2
... |
03de1f38d94cddc49adda15bcfa0ae2f502165ff | dhellmann/presentation-zenofpy | /string_methods.py | 191 | 3.671875 | 4 | print ' string value '.split()
print ' string value '.strip()
print 'str' in ' string value '
print 'CHUGALUG'.startswith('C')
print 'CHUGALUG'.endswith('end')
print ':'.join(['a', 'b', 'c']) |
8114ace35fb3bb5ff108b76f48523443332f1c44 | liuxingrichu/python_2018 | /00lesson_practice/class_practice/fib_sequence.py | 972 | 4.0625 | 4 | """
功能:用面向对象编程方式,编写斐波那契数列程序,并调用运行,输出运行结果 :
"""
class Fibonacci(object):
"""
生成斐波那契数列
"""
def get_in_number(self, number):
"""
功能:获取指定数值内的斐波那契数列
"""
a, b = 0, 1
tmp_list = []
while b < number:
tmp_list.append(str(b))
a,... |
7a6b1bd0dcb4b79d8b20402f4e4f275694c8a690 | liuxingrichu/python_2018 | /00lesson_practice/function/even_element.py | 406 | 3.640625 | 4 | """
编写列表元素偶数之和函数
"""
def get_sum(seq):
"""
功能:获取列表中的偶数元素之后
参数:
seq:列表
返回值:偶数之和
"""
sum = 0
for i in seq:
if not i % 2:
sum += i
return sum
if __name__ == "__main__":
test_list = [i for i in range(101)]
print(get_sum(test_lis... |
3fe7c95082cdfa53061deafc74519c4e911b2997 | liuxingrichu/python_2018 | /00lesson_practice/data_structure/del_repeat_element.py | 1,035 | 3.671875 | 4 | """
删除列表中的重复元素
"""
lst = [1, 2, 4, 1, 2, 3, 3, 5]
# 方法一:利用集合去除重复元素
# print(lst)
# lst = list(set(lst))
# print(lst)
# 方法二:将数据排序,删除相应重复元素
# print(lst)
# lst.sort()
# for i in lst:
# index = lst.index(i)
# if index < len(lst) - 1:
# if lst[index] == lst[index + 1]:
# del lst[index+1]
# ... |
bf8978a5608d10675685330ce63b91957dee64c8 | bpsullivan3/CSC1800_FamilyTree_Python | /Carlock.py | 12,354 | 4.15625 | 4 | #! /usr/bin/python3.6
"""
Authors:
Meghan Carlock
Justin Graham
Patrick Sullivan
"""
import sys
def create_person(name, parent1, parent2):
"""
Create a dictionary for a 'Person'. If the person has no parents, the
parent arguments should be None.
:param name: String
:param parent1: Dict
:p... |
1c83d150e233d3eb87858d6691bcaafd064fc5b7 | alinebarbosasilva/exerciciosPythonLogicaDeProgramacao | /exercicio_43(e).py | 397 | 3.8125 | 4 | # Faça com que sejam pedidos e armazenados cinco números. Informe quantos
# números dez foram informados pelo usuário
lista_de_numeros = []
for contador in range(0, 5, 1):
lista_de_numeros.append(int(input("Informe um número: ")))
contador_de_dez = 0
for index in range(0, 5, 1):
if lista_de_numer... |
0341fe2df5ce7d584c65c0dcfdfd656641288dd8 | alinebarbosasilva/exerciciosPythonLogicaDeProgramacao | /exercicio_34(b).py | 882 | 3.9375 | 4 | #Cotações do dia 05/10/21
opcoes_conversor = float(input("Informe qual conversão você gostaria de realizar: [1 = Real para Dólar] [2 = Dólar para Real] [3 = Real para Euro] [4 = Euro para Real]: "))
valor_converta = float(input("Insira o valor: "))
if opcoes_conversor == 1:
resultado_conversao = valor_conve... |
a3c10263b96a37a61361ddc6326a2befe0661de5 | alinebarbosasilva/exerciciosPythonLogicaDeProgramacao | /exercicio_32(d).py | 519 | 4.15625 | 4 | numero_1 = int(input("Informe o primeiro número: "))
numero_2 = int(input("Informe o segundo número: "))
numero_3 = int(input("Informe o terceiro número: "))
if numero_1 < numero_2:
if numero_1 < numero_3:
print(numero_1)
else:
print(numero_3)
elif numero_2 < numero_1:
if numero... |
0ebcf4917a763bca64ee3d0424c743e9b0e79c38 | alinebarbosasilva/exerciciosPythonLogicaDeProgramacao | /exercicio_43(a).py | 206 | 3.703125 | 4 | #Crie um vetor contendo cinco cidades, em seguida exiba seus valores.
cidades = ["Bastos", "Blumenau", "Toronto", "Berlim", "Los Angeles"]
for index in range(0, 5, 1):
print(cidades[index])
|
6dd41aaba81ad71b85d328bfbea3dc47ece10144 | iverberk/advent-of-code-2018 | /day-07/part1.py | 240 | 3.53125 | 4 | import networkx as nx
G = nx.DiGraph()
with open('input') as f:
for line in f:
instruction = line.strip().split()
G.add_edge(instruction[1], instruction[7])
print("".join(list(nx.lexicographical_topological_sort(G))))
|
3795a57e4b3e5821193ed18f8fe939a4dadd65b1 | zssvaidar/code_py_book_data_structures_and_algo | /chap04_sequences/linkedlist2.py | 8,671 | 4.21875 | 4 | # https://stackabuse.com/linked-lists-in-detail-with-python-examples-single-linked-lists/
__doc__ = """Basics
Array is
- not dynamic, memory has to be allocated in advance
- difficult(slow) to insert|remove an item (need to update a large num of items)
- able to directly access an item (aka. random accessible ... |
027545decd78678d7fecda020f1bb30963680a2f | zssvaidar/code_py_book_data_structures_and_algo | /chap04_sequences/pylist.py | 3,969 | 3.609375 | 4 | # Requires Python 3.7.*
from __future__ import annotations
from typing import List, Union, Iterator, Optional
IntOrNone = Optional[int]
IntIteratorOrNone = Optional[Iterator[int]]
IntList = List[int]
IntOrNoneList = List[Union[int, None]]
class PyList:
"""
For the sake of simplicity, this class only supports... |
b3d41974c057b7ada1015d39946eba2b91429447 | zssvaidar/code_py_book_data_structures_and_algo | /chap04_sequences/linkedlist.py | 4,066 | 4.34375 | 4 | class LinkedList:
"""Serves a different purpose in comparison to built-in list."""
# Inviside to the outside (by using two underscores)
class __Node:
def __init__(self, item, next=None):
"""
One node has two parts, one is the value itself (item),
the other half p... |
d46f1e1bb386abb12a447a3b05042d6ce8236936 | iatechristmas/cs-sprint-challenge-hash-tables | /hashtables/ex3/ex3.py | 1,001 | 3.9375 | 4 | def intersection(arrays):
"""
YOUR CODE HERE
"""
# Your code here
cache = {}
result = []
# loop through arrays
for array in arrays:
# loop through subarray
for num in array:
# if num not in the cache
if num not in cache:
# add to ... |
42d93242b84a272928f12b24d56b793d42745173 | Marcus893/algos-collection | /linkedlist/copy_list_with_random_pointer_138.py | 2,114 | 4.03125 | 4 | A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
# Definition for singly-linked list with a random pointer.
# class RandomListNode(object):
# def __init__(self, x):
# self.label = x
# ... |
ea817c693111736dcdb5b2573fa18a20a567e4f3 | Marcus893/algos-collection | /binary_search/shifted_array_search.py | 1,707 | 3.921875 | 4 | A sorted array of distinct integers shiftArr is shifted to the left by an unknown
offset and you don’t have a pre-shifted copy of it. For instance,
the sequence 1, 2, 3, 4, 5 becomes 3, 4, 5, 1, 2, after shifting it twice to the left.
Given shiftArr and an integer num, implement a function shiftedArrSearch that finds
... |
0c4d18cd5026291649bda81ae7cbc5900ae48551 | Marcus893/algos-collection | /array/number_of_islands_II.py | 1,745 | 3.921875 | 4 | Given a n,m which means the row and column of the 2D matrix and an array of pair
A( size k). Originally, the 2D matrix is all 0 which means there is only sea in
the matrix. The list pair has k operator and each operator has two integer A[i].x,
A[i].y means that you can change the grid matrix[A[i].x][A[i].y] from sea t... |
61c76486b40b55f995d3c055016f602b510f2762 | Marcus893/algos-collection | /linkedlist/swap_nodes_in_pairs_24.py | 911 | 4.0625 | 4 | Given a linked list, swap every two adjacent nodes and return its head.
Example:
Given 1->2->3->4, you should return the list as 2->1->4->3.
Note:
Your algorithm should use only constant extra space.
You may not modify the values in the list's nodes, only nodes itself may be changed.
# Definition for singly-linked... |
4633040b0936b9ebb451d99c245fa20e0d86693e | Marcus893/algos-collection | /dp/fibFrog.py | 3,571 | 4.0625 | 4 | The Fibonacci sequence is defined using the following recursive formula:
F(0) = 0
F(1) = 1
F(M) = F(M - 1) + F(M - 2) if M >= 2
A small frog wants to get to the other side of a river. The frog is initially
located at one bank of the river (position −1) and wants to get to the other bank
(position N). The f... |
d34b287a06ab92c5274a8bd309dbc0378b09088c | Marcus893/algos-collection | /array/Kth_largest_element_in_an_array_215.py | 1,104 | 4.09375 | 4 | Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
Example 1:
Input: [3,2,1,5,6,4] and k = 2
Output: 5
Example 2:
Input: [3,2,3,1,2,4,5,5,6] and k = 4
Output: 4
class Solution(object):
def findKthLargest(self, nums, k):... |
98640bd602031422992cff87889db4d185c66e04 | Marcus893/algos-collection | /cracking_the_coding_interview/8.6.py | 790 | 4.1875 | 4 | Towers of Hanoi: In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of
different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order
of size from top to bottom (Le., each disk sits on top of an even larger one). You have the following
constraints:
(1) O... |
0efea5ef4988f47b3a27a0a57372fc17283ed791 | Marcus893/algos-collection | /cracking_the_coding_interview/1.7.py | 412 | 3.875 | 4 | Rotate Matrix: Given an image represented by an NxN matrix, where each pixel in the image is 4
bytes, write a method to rotate the image by 90 degrees. (an you do this in place?
from copy import deepcopy
def rotateMatrix(matrix):
res = deepcopy(matrix)
for i in range(len(matrix)):
for j in range(len(... |
9e10f2d45237c62e42612809d8f075e781c7658b | Marcus893/algos-collection | /interval/non-overlapping-intervals.py | 1,340 | 4.28125 | 4 | Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Note:
You may assume the interval's end point is always bigger than its start point.
Intervals like [1,2] and [2,3] have borders "touching" but they don't overlap each other.
Exam... |
acd797cb4ac20e5ef8c2b28a79d6b218cef0a9d2 | Marcus893/algos-collection | /cracking_the_coding_interview/10.2.py | 390 | 4.03125 | 4 | Group Anagrams: Write a method to sort an array of strings so that all the anagrams are next to
each other.
class Solution(object):
def groupAnagrams(self, strs):
"""
:type strs: List[str]
:rtype: List[List[str]]
"""
ans = collections.defaultdict(list)
for s in strs:... |
d8351a1779d683d595b9f156d8fc216a6a5139ae | s3icc0/Tutorials | /DBTut/Lesson 011 Static and Exception Handling/pytut_011_004.py | 297 | 3.546875 | 4 | try:
alist = [1, 2, 3]
# index 3 does not exist therefore will raise error
print(alist[3])
# except(IndexError, NameError):
# print('Multiple errors handled here')
except IndexError:
print('Sorry that index does not exist.')
except:
print('An unknown error occured.')
|
fd75c06301270085400823acc521a5977305d5e0 | s3icc0/Tutorials | /Corey Schafer Tutorial/Logging 1 Employee.py | 700 | 3.625 | 4 | import logging
logging.basicConfig(
filename='logging_employee.log',
level=logging.INFO,
format='%(lineno)d : '
'%(levelname)s : '
'%(message)s')
class Employee:
"""A sample Employee class"""
def __init__(self, first, last):
self.first = first
self.last = l... |
2a2769ff43da76ae887cd2970430076d4a74399b | s3icc0/Tutorials | /DBTut/Lesson 001 Learn to Program/pytut_001_003.py | 1,116 | 4.3125 | 4 | # CALCULATOR
# Enter Calculation: 5 * 6
# 5 * 6 = 30
print()
print('Whole numbers simple calculator')
print()
# Store the user input of 2 numbers and the operator
num1, operator, num2 = input('Enter calculation and hit ENTER \n'
'(make sure you separate entries with space)'
... |
085c54e3879cbce9cc9d2daa8973557187ba4fc5 | s3icc0/Tutorials | /DBTut/Lesson 002 Looping/pytut_002_002.py | 230 | 4.3125 | 4 | # FLOAT numbers
your_float = input('Enter a float: ')
# convert value to float
your_float = float(your_float)
# :.2f will show 2 decimal numbers after the floating point
print('Rounded to 2 decimals: {:.2f}'.format(your_float))
|
a65c3ae03fdd63e5cf0a0deab5d68bb8ee4b7adf | s3icc0/Tutorials | /DBTut/Lesson 012 Lambda Map Filter Reduce/pytut_012_001.py | 608 | 3.859375 | 4 | def mult_by_2(num):
return num * 2
# assign function to variable and execute from the variable
# (variable becomes a function)
times_two = mult_by_2
print('4 * 2 = ', times_two(4))
def do_math(func, num):
return func(num)
# assign a function as an attribute to another function ...
print('8 * 2 = ', do_mat... |
e680225e94a698e0c1c908b3e7b3e49434255f29 | s3icc0/Tutorials | /Corey Schafer Tutorial/OOP 6 Property Decorators - Getters, Setters, Deleters.py | 975 | 3.796875 | 4 | """ Python Object-Oriented Programming
https://www.youtube.com/watch?v=ZDa-Z5JzLYM
"""
"""
getter -
setter -
deleter -
"""
class Employee:
def __init__(self, first, last):
self.first = first
self.last = last
@property
def email(self):
return '{}.{}@company.com'.format(self.fir... |
0df4c0a9aafe2441f8c0da8133bd91330d2fb7ad | s3icc0/Tutorials | /DBTut/Lesson 006 Lists/pytut_006_exe_001.py | 239 | 3.671875 | 4 | #RANDOM LIST
# generate a list with 5 values between 1 and 9
import random
import math
randList = []
for i in range(100):
randList.append(random.randrange(1, 10))
for i in randList:
print('{} : {}'.format(randList.index(i), i)) |
f083379d4dc4f5e39f7b52543c6a5391c64af9b4 | s3icc0/Tutorials | /DBTut/Lesson 003 Math Strings and Exception Handling/pytut_003_004.py | 1,462 | 4.5625 | 5 | # STRINGS
# get data type returns Int as Integer
print(type(3))
# returns Float
print(type(3.14))
# returns Str as String in single quotes
print(type('3'))
# double quotes makes no difference
print(type("3"))
samp_string = 'This is a very important string'
# return whatever is on position 0 in the string
print(samp_... |
3f600a47a058bede74ed4a73e285c1839fb81c58 | rohstar/codingbat | /python/warmup2/front_times.py | 209 | 3.671875 | 4 | def front_times(str, n):
res = ''
shorterThanThree = len(str) < 3
while(n != 0):
if(shorterThanThree):
res += str
else:
res += str[0:3]
n = n - 1
return res |
1adfd86c00b58067e7dc32426d6943cd4487d783 | Dmitrii6776/python_poker_complete_project | /table.py | 1,136 | 3.78125 | 4 | import random
class Table:
def build_deck(self) -> list:
"""build deck of 52 card"""
cards = [card for card in range(2, 10)]
suits = ["♠", "♤", "♡", "♥", "♣", "♧", "♢", "♦"]
characters = ["T", "J", "Q", "K", "A"]
all_cards = []
for card in cards:
for su... |
34fea0c7c9bb1ad4638ec8af94f01eff1ae2fa4d | helderseixas/doutorado-ipe | /lista_2_questao_2.py | 1,430 | 3.6875 | 4 | import itertools
import random
def gerar_conjunto(a, b):
conjunto = []
for x in list(range(a+1)):
for y in list(range(b+1)):
ponto = (x, y)
conjunto.append(ponto)
return conjunto
def imprimir(evento, quantidade_sorteada, probabilidade):
print(f"Evento: {evento} - Nº eve... |
cb587ccc356365fa5c2764c2f28a1ee442411106 | anupampydey/evolution | /Math_is_fun/Math_is_fun.py | 2,151 | 4.15625 | 4 | import string
from random_words import RandomWords
def main_display():
while True:
print('What do you want to do?')
print('a) Prints random words having 100% score')
print('b) Check the score value of your word')
print('q) Quit the program')
option = input('Please choose th... |
e8fa9b38af6d44c28674297143a53e30deb53e06 | viditvarshney/Python | /Dictionary/loop.py | 155 | 3.984375 | 4 | d=dict()
d={1:"one",2:"two",3:'three',4:'four',5:'five'}
for key in d:
print(key,d[key])
for key in d:
if d[key]=='one':
print(key,d[key])
|
d0d3e47b632a4ffd55f2f8a4502cc7b82e278481 | PalacioRestrepo/Python | /programacion/NumerosDeFibonachiPar.py | 445 | 3.734375 | 4 | def fibonachi(numero):
sumapar = 0
if numero == 0 or numero == 1:
return 0
else:
previo1 = 1
previo2 = 1
i = 2
while i < numero:
if (previo1 + previo2) % 2 == 0:
sumapar = previo1 + previo2
temporal = previo1
... |
0d76d101525c010980db72af07cb7fbff881c443 | gichiba/pythonthehardway | /ex33.py | 476 | 4.1875 | 4 |
def build_list(n, j):
i = 0
numbers = []
while i < n:
print "At the top i is %d" % i
numbers.append(i)
i = i + j
print "Numbers now:", numbers
print "At the bottom of i is %d" % i
print "The numbers: "
for num in numbers:
print num
print "How lon... |
ec29a7744d620614e5f7b30feb30b3cde208edbb | lundergust/basic | /intro/austinstory.py | 826 | 4.15625 | 4 | character_name = "Austin"
character_weight = 450
print("there once was a man named " + character_name + ",")
print("he weighed " + str(character_weight) + " pounds")
phrase = "he was so fat"
print(phrase.upper())
# give length of phrase
print(len(phrase))
# give character number in phrase
print(phrase[0])
# give fi... |
01fbb20f16872e605bb99fa08e3917334e167748 | Dzhano/Python-projects | /conditional_statements_-_lab/toy_shop.py | 492 | 3.78125 | 4 | trip_price = float(input())
puzzles = int(input())
dolls = int(input())
teddies = int(input())
minions = int(input())
trucks = int(input())
price = puzzles * 2.60 + dolls * 3 + teddies * 4.10 + minions * 8.20 + trucks * 2
toys = puzzles + dolls + teddies + minions + trucks
if toys >= 50:
price *= 0.75
rent = price... |
5887964316ebad5812a169ccae2f3e7a8e2c6b89 | Dzhano/Python-projects | /conditional_statements_advanced/hotel_room.py | 620 | 3.96875 | 4 | month = input()
nights = int(input())
if month == "May" or month == "October":
studio = 50
apartment = 65
if 7 < nights <= 14:
studio *= 0.95
elif nights > 14:
studio *= 0.7
apartment *= 0.9
elif month == "June" or month == "September":
studio = 75.20
apartment = 68.70
... |
95ddcc9b93d835e9f31246105810a3856a9a4985 | Dzhano/Python-projects | /programming_basics_online_exam_-_29_and_30_august_2020/kart_rank_list.py | 771 | 3.953125 | 4 | best_score = 9999999999
best_name = ""
best_minutes = 0
best_seconds = 0
gold_cards = 0
silver_cards = 0
bronze_cards = 0
while True:
name = input()
if name == "Finish":
break
minutes = int(input())
seconds = int(input())
time = minutes * 60 + seconds
if time < best_score:
best_s... |
c143c2b225cb40cc580d23b0345503ae27d60420 | Dzhano/Python-projects | /conditional_statements_-_exercise/world_swimming_record.py | 386 | 3.90625 | 4 | from math import floor
record = float(input())
meters = float(input())
time_meter = float(input())
time = meters * time_meter
extra_time = floor(meters / 15) * 12.5
total_time = time + extra_time
if record > total_time:
print(f"Yes, he succeeded! The new world record is {total_time:.2f} seconds.")
else:
print(f... |
f44f828f0c089936ea5a217410aaa7f4a005ae94 | Dzhano/Python-projects | /while_loop/graduation_pt.2.py | 431 | 3.859375 | 4 | name = input()
klass = 0
bad_grade = 0
total_grade = 0
while klass < 12:
grade = float(input())
total_grade += grade
if grade < 4.00:
bad_grade += 1
if bad_grade > 1:
klass += 1
print(f"{name} has been excluded at {klass} grade")
exit()
continue
... |
ef6d073b4c9fad242af6221abc98860f45aa64d2 | Dzhano/Python-projects | /programming_basics_online_exam_-_22_and_23_august_2020/everest.py | 422 | 4 | 4 | days = 1
total_meters = 5364
while True:
rest = input()
if rest == "Yes":
days += 1
elif rest == "No":
days += 0
elif rest == "END":
break
if days > 5:
break
meters = int(input())
total_meters += meters
if total_meters >= 8848:
print(f"Goal reached... |
d5767faf7a761731eec731897bdeb88366c0bb08 | Dzhano/Python-projects | /programming_basics_online_exam_-_29_and_30_august_2020/kart_center.py | 844 | 3.78125 | 4 | budget = float(input())
laps = input() # "five" или "ten"
fan_card = input() # "yes" или "no"
type_kart = input()
if laps == "five":
if type_kart == "Child":
price = 7
elif type_kart == "Junior":
price = 9
elif type_kart == "Adult":
price = 12
elif type_kart == "Profi":
... |
c4bede567cc11f709ee2612ff51a13a2d806f5ed | Dzhano/Python-projects | /while_loop/moving.py | 353 | 3.765625 | 4 | wedth = int(input())
lenght = int(input())
hight = int(input())
space = wedth * lenght * hight
command = input()
while command != "Done":
boxes = int(command)
space -= boxes
if space <= 0:
print(f"No more free space! You need {abs(space)} Cubic meters more.")
exit()
command = input()
pri... |
65132fa14cfd090918b56e7ef5c99ca7ecbb1d5e | SarthakSingh2010/PythonProgramming | /OOP in Python/prog02.py | 1,846 | 4.0625 | 4 | #create class
class Employee:
numofemp=0 #static variable or class variable
raiseAmt=1.04 #class variable (shared by all objects)
def __init__(self,first,last,pay): #constructor 2dash init (initialize)
self.first=first #self.fname=first (allowed)
self.last=last #self is like this
... |
73b76ceed88fa14c8442ff65e740cceb7a1f3afa | Cationiz3r/C4T-Summer | /Session-4/miniHack/Part-3/larger13.py | 162 | 4.1875 | 4 |
print()
n = int(input(" Input: "))
print()
if n > 13:
print(" Input is GREATER than 13.")
else:
print(" Input is NOT GREATER than 13.")
input()
|
bc3f4484e5308ab6c245b58e07e8e3dc5240ed2e | Cationiz3r/C4T-Summer | /Session-3/random/randomExcercise1.py | 210 | 3.875 | 4 | # random 0 :D
from random import *
print()
n = randrange(101)
if n < 30:
print("The weather is: Rainy")
elif n <= 60:
print("The weather is: Cloudy")
else:
print("The weather is: Sunny")
print() |
2202639d9764d29f7f23e6aaa3abd3fe26ac7e74 | Cationiz3r/C4T-Summer | /Session-9/API/Intro.py | 501 | 3.5 | 4 | import requests
import json
usersReq = requests.get("https://jsonplaceholder.typicode.com/users")
usersJson = usersReq.json()
print()
inputName = input(" Username: ")
print()
found = False
for user in usersJson:
if (user["username"] == inputName):
print(" Location:")
print(" Lat:", user["add... |
dd35e88095d6a68520f7fc05a163b8585df26cdf | Cationiz3r/C4T-Summer | /Session-4/list/update/update2.py | 176 | 3.859375 | 4 |
print()
myList = ["Games", "Games", "Still Games", "Games?"]
myList[0] = "Movies"
myList[len(myList) -1] = "Comics"
for i in myList:
print(i, end = " ")
print(), print() |
2ab98e23573ba0e8128dcde7d332dbdce11ff598 | Cationiz3r/C4T-Summer | /Session-4/miniHack/Part-2/printSequence2.py | 96 | 3.75 | 4 |
print()
n = int(input(" Input n = "))
print()
r = range(1, n +1, 2)
print(" ", *r)
input() |
f7e160480d2f1b2c2e6ca22050a0465fdeb99e27 | Cationiz3r/C4T-Summer | /Session-3/getCurrentHour.py | 272 | 3.578125 | 4 | # session 6
from datetime import *
from os import *
h = -1
while True:
if not h == datetime.now().hour:
clear = lambda: system("cls")
clear()
h= datetime.now().hour
print()
print(" The current hour is:", h)
print()
|
8bff1274b30c08c92ef9577c7e27e93d3f6abedd | Cationiz3r/C4T-Summer | /Session-5/miniHack/part2/dash.py | 169 | 3.71875 | 4 | import turtle
t = turtle.Turtle()
colors = ["blue", "red", "teal", "green"]
for i in range(len(colors)):
t.pencolor(colors[i])
t.forward(50)
turtle.mainloop() |
8ffd388f4014248b8833dc0f93f1ae9c863f791a | Cationiz3r/C4T-Summer | /Session-5/miniHack/part1/printColor.py | 226 | 4.03125 | 4 |
colors = ["blue", "red", "teal", "green"]
print()
print(" Our color list: ", end = "")
for i in range(len(colors)):
if i < len(colors) -1:
print(colors[i], end = ", ")
else:
print(colors[i])
print()
|
e335482e93ccc5168c70a94582bcf7bf788955fb | Cationiz3r/C4T-Summer | /Session-5/miniHack/part1/create.py | 482 | 4 | 4 |
colors = ["blue", "red", "teal", "green"]
print()
print(" Our color list: ", end = "")
for i in range(len(colors)):
if i < len(colors) -1:
print(colors[i], end = ", ")
else:
print(colors[i])
print()
newColor = input(" Enter a new color: ")
colors.append(newColor)
print()
print(" Our new c... |
2657d77955b04ef11684ddbefca9c879ac340a94 | miguelrochajr/DataScience | /Section_7-Matplot/testMatplot.py | 192 | 3.828125 | 4 | import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,5,11)
y = x ** 2
plt.plot(x,y,'r-')
plt.xlabel('X Label')
plt.ylabel('Y Label')
plt.title('Title!')
plt.show()
print(y)
|
5e5e132d8e987553c9727b4b543cc04351288f1e | burakkorman/Cryptology | /CaesarAlgorithm.py | 1,518 | 4.125 | 4 | letters = "abcçdefgğhıijklmnoöprsştuüvyz"
key = 0
enteredText = ""
def TakeKey():
global key
key = input("Please enter a number : ")
while not key.isdigit():
key = input("Incorrect entry. Please enter a number again : ")
def TakeText():
global enteredText
print("Enter a text : ")
ente... |
47e402804bcc9b081ccfbaf96b1ea9f57fdbb410 | CraigKnoblauch/Raymond | /cardgames/hand.py | 2,645 | 3.9375 | 4 | from cardgames import card
# Ugh, doing a game='blackjack' is a really bad way of doing this
class Hand:
def __init__(self, cards, game):
"""
A hand must start with a list of cards
"""
self.__cards = cards
self.__game = game
self.__quality = self.determin... |
79c2a4aac3e553e712f0ed08a008c23eb7bad8d3 | hila16-meet/CodeMe-repo | /PycharmProjects/Practice Exercises/minimum.py | 2,452 | 4.03125 | 4 | import random
import time
def find_min_place(the_list):
return the_list.index(min(the_list))
def find_two_mins(the_list):
# find the minimum value in the list, store it in min1_value
min1_value = min(the_list)
# find the index of this value, store it in min1
min1 = the_list.index(min1_value)
... |
761864001ad571d7f1768a2e3cd19214995f8fc7 | scottwedge/battleship | /battleship.py | 19,737 | 4 | 4 | #!/usr/bin/env python3
""" Sections of the program are:
100. Start game.
120. Random shots
140. Display shots
200. Start displaying statistics.
300. Update display with every shot.
1000. Add ability to: save game mid-session,
"""
# Import statements
from setup_battleship import *
import sys
... |
5b0d43e81d911c945b7886c86fabac5e26c12a9d | sametz/nmrsim | /src/nmrsim/plt.py | 5,374 | 3.53125 | 4 | """The plt module provides convenience functions for creating matplotlib plots,
plus applying Lorentzian distributions about signals.
The plt module provides the following functions:
* add_lorentzians: Creates lineshape data from a provided linspace (array of x
coordinates) and peaklist).
* mplplot: Creates a lines... |
b96dcddb9ca03420e590ab1ccb7573e20b73be1d | yukiyanai/algorithms | /algorithms-Python/bubble_sort.py | 345 | 3.578125 | 4 | given_list = input("Please enter the list of numbers: " )
n = len(given_list)
k = 0
while k < n-1:
i = n-1
while i > k:
if given_list[i-1] > given_list[i]:
w = given_list[i-1]
given_list[i-1] = given_list[i]
given_list[i] = w
i -= 1
k += 1
for num in g... |
ed07825a440c4b6e7bbfbc4c6b3b1c2a00368655 | egbeyongtanjong/MIT_Data_Analysis_2020 | /ProblemSet1.py | 2,948 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 8 22:15:28 2020
@author: Egbeyong Problem Set 1
Three simple programs
All answered correctly
"""
"""
ages = [12,34,56,78,90] #homogenous tupple of integers
print(ages[0:len(ages)+1]) #slicing a tupple
Jack = [23, 'Stan', 1.66]
print(Jack[0])
print(ages+Jack)
name... |
0cf88693d4c6715dca7569a89f640e53261930d7 | egbeyongtanjong/MIT_Data_Analysis_2020 | /Lecture_notes/Lecture13.py | 2,077 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 6 11:48:08 2020
@author: Egbeyong
Lecture 13
Basic probabilty and simulation
How do we think about the results of programs when the
programs themselves are stochastic (random prob distribution)
We can analyze these statistically, but may not be able to
predict pre... |
cd405e3c4e2c7dbeec93c341040dab15f482d62d | egbeyongtanjong/MIT_Data_Analysis_2020 | /Lecture_notes/Lecture6.py | 2,062 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 13 11:23:44 2020
@author: Egbeyong
Lecture 6, Recurssion
"""
"""
Keys could be associated with numbers, strings, dictionaries
tuple...
If you are going to use code in multiple places, creating a
function saves you typing/rewriting time of code and time to debug code
B... |
e5dcae5003d2bfbf7605730183e425f8faa34703 | Alokik-Mishra/DeepLearning | /Assignment1/ecbm4040/features/pca.py | 1,225 | 3.765625 | 4 | import time
import numpy as np
def pca_naive(X, K):
"""
PCA -- naive version
Inputs:
- X: (float) A numpy array of shape (N, D) where N is the number of samples,
D is the number of features
- K: (int) indicates the number of features you are going to keep after
dimensionality red... |
5114564c9c3994d31095e73d865621cf450b0c1d | architagarwal115/python_classes | /prime check.py | 188 | 4.03125 | 4 | n = int(input("give integer for prime check:"))
i = 2
while i < n:
if(n%i)== 0:
print("its not a prime number")
break
i = i+1
else:
print("its a prime number") |
3676b87fbf299e32d18539bbb967d3fab11e7230 | IvanCheng1/Problems-vs.-Algorithms | /02 Rotated Sorted Array.py | 2,482 | 4.40625 | 4 |
def rotated_array_search(input_list, number, low=0, high=''):
"""
Find the index by searching in a rotated sorted array
Args:
input_list(array), number(int), low(int), high(int):
- Input array to search;
- the target;
- lower bound index (default is 0 for initial search);
... |
bcdb326f644873837c4ed3c6814029b29ea2ba6b | helge32/python-maxHeap | /KL/heap.py | 1,686 | 3.578125 | 4 | class maxHeap:
def __init__(self):
self.heapList = [0]
self.size = 0
# ordering the heap by swapping upwards
def perc_up(self, i):
while i // 2 > 0:
if self.heapList[i][0] > self.heapList[i // 2][0]:
tmp = self.heapList[i // 2]
self.heapLi... |
d26203728487ff18b60375831066d01948f168b8 | lucasronaldi12S19036/GASchedule.py | /StudentsGroup.py | 735 | 3.765625 | 4 | # Stores data about student group
class StudentsGroup:
# Initializes student group data
def __init__(self, id, name, numberOfStudents):
self.Id = id
self.Name = name
self.NumberOfStudents = numberOfStudents
self.CourseClasses = []
# Bind group to class
def addClass(self,... |
7b17faa1c0c7c230a42a5735374dd790c6c1539d | sysad-aldama/demos | /map-coloring/utilities.py | 906 | 3.6875 | 4 | import networkx as nx
import matplotlib.pyplot as plt
def visualize_map(nodes, edges, sample, node_positions=None):
# Set up graph
G = nx.Graph(edges)
lone_nodes = set(nodes) - set(G.nodes) # nodes without edges
for lone_node in lone_nodes:
G.add_node(lone_node)
# Grab the colors select... |
406729794d161a0429594297dd323492759cd082 | marco-c/gecko-dev-comments-removed | /third_party/libwebrtc/rtc_tools/py_event_log_analyzer/misc.py | 2,083 | 3.546875 | 4 |
"""Utility functions for calculating statistics.
"""
from __future__ import division
import collections
import sys
def CountReordered(sequence_numbers):
"""Returns number of reordered indices.
A reordered index is an index `i` for which sequence_numbers[i] >=
sequence_numbers[i + 1]
"""
return ... |
79ebe9b4d90aaebed02222ea187407d1f6f8113e | Zzechen/LearnPython2.7 | /regular/regular_easy.py | 772 | 3.984375 | 4 | import re
a = 'adfbg'
if re.match('a.',a):
print ". match any true"
else:
print ". match any false"
a = 'dfhhfdhd'
if re.match('\d{*}',a):
print '* match all true'
else:
print '* match all false'
a = '010'
if re.match('\d\d\d',a):
print "\d match number true"
else:
print "\d match number fals... |
ea8332221ba09f85b839ccb72c1c53fb5efede2a | radeklskw/vigenerecipher | /vigenere.py | 6,861 | 4.3125 | 4 | exit_program = False
alphabet = {
"a": 0,
"b": 1,
"c": 2,
"d": 3,
"e": 4,
"f": 5,
"g": 6,
"h": 7,
"i": 8,
"j": 9,
"k": 10,
"l": 11,
"m": 12,
"n": 13,
"o": 14,
"p": 15,
"q": 16,
"r": 17,
"s": 18,
"t": 19,
"u": 20,
"v": 21,
"w": ... |
a7f344ffa79733af862e2d742deaeab395e07854 | sowmyayas/guvisub | /weekend.py | 276 | 4.125 | 4 | def main():
s1=input("string 1")
if((s1=="monday")or(s1=="tuesday")or(s1=="wednesday")or(s1=="thursday")or(s1=="friday")):
print("\ntrue")
elif((s1=="sunday")or(s1=="saturday")):
print("\nfalse")
else:
print("\ninvalid")
main()
|
43fde968a6f798704d8284bf4fab92bb78acb01d | sowmyayas/guvisub | /evenorodd.py | 174 | 3.84375 | 4 | #python code goes here
#python version :3
def main():
n=int(input("n"))
if((n%2)==0):
print("\neven")
else:
print("\nodd number")
main()
|
0972fb552bf719b54afb7414701ad8d87e5d8a4b | 4bd3ss4m4d/CaesarCipher | /encrypt.py | 559 | 4.0625 | 4 | # Encryption Module
def encrypt(plain_text, shift_amount, alphabet):
cipher_text = ""
for char in plain_text:
if char not in alphabet:
cipher_text += char
elif char in alphabet:
position = alphabet.index(char)
new_position = position + shift_amount
if new_position > len(alphabet):
remainder = ne... |
db758fad2d33c0c3208658f117c4573ae75839a1 | gurpreet00793/jarvis | /overloading.py | 1,877 | 4.21875 | 4 |
"""
class parrot:
def fly(self):
print("parrots can fly")
def swim(self):
print("parrots can not swin")
class penguin:
def fly(self):
print("penguins cannot fly")
def swim(self):
print("penguins can swim")
def fly_test(bird):
bird.fly()
bd=parrot()
pg=penguin()
f... |
5c9b50548a2dfa30fd2a387435535046dfa26f2b | gurpreet00793/jarvis | /operator.py | 206 | 3.921875 | 4 | a=21
b=10
c=0
c=a+b
print("value of a is",a)
print("value of b is",b)
print("value of c is",c)
c=a%b
print("value of c is",c)
a=2
b=3
c=a**b
print("value of c",c)
a=10
b=3
c=a//b
print("value of c",c)
|
a73335b0e5992f3c2310b03594d7e2a546d3b2d3 | gurpreet00793/jarvis | /exception handling.py | 607 | 3.859375 | 4 | try:
x=8
y=0
a=x/y
print(a)
except:
print("not possible")
try:
av=5+"a"
print(av)
except:
print("no way")
li=[1,2,3,4]
try:
c=8
b=0
z=c/b
print(z)
except ZeroDivisionError:
print("ZeroDivisibleError")
except IndexError:
print("IndexError")
try:... |
cb23057bc0e40a7eba2b4ef386107bf51eb3f2d6 | gurpreet00793/jarvis | /dictionary.py | 588 | 4.40625 | 4 | my_dict={}#empty dictionary
print(my_dict)
my_dict={1:'apple',2:'ball'}#dictionary with integer key
my_dict={'name':'john',1:[2,4,3]}#dictionary with mixed key
print(my_dict)
print(my_dict['name'])
print(my_dict[1])
print(my_dict.get('name'))
print(my_dict[1][0:2])
print(my_dict['name'][0:3])
my_dict=dict({1:'apple',... |
76381436e29ae1fddfcdc6aefd97cfc9bd5b7f6a | gurpreet00793/jarvis | /for loop.py | 341 | 3.890625 | 4 | """ for loop:-
syntax=: for iterating_var in sequence:
statement(s)."""
"""a="tonystark"
for t in a:
print(t)
li=["tony","steve","thor"]
for avenger in li:
print(avenger)
c={1,2,9,3,4}#while loop doesn't consider set indexing
for j in c:
print(j)
"""
a="tonystark"
for i in range(2,l... |
66afdcc085148fe900668d5fc667425479fb0d18 | gurpreet00793/jarvis | /test1.py | 93 | 3.765625 | 4 | x='tony'
y='stark'
z=x + " "+y
print(z)
x="tony" " " "stark" " " "is" " ""ironman"
print(x)
|
8a8893613efed8941118b42b5394949c157b0910 | manjupoo/manjureddy | /dicem.py | 198 | 3.78125 | 4 | import random
i=0
while i<2:
d=6
r=input("press r to roll, q to quit;")
if r=="r"
print("you got:",d)
d=d/3
r=input("press r to roll,q to quit;")
if r=="r")
print("you got:",d)
if d=d+1
|
fb98af03320c18a1d21c03b4b0eb2b2488d0d2da | bglynch/webcrawler_python | /webcrawler.py | 2,674 | 3.640625 | 4 | from bs4 import BeautifulSoup
import urllib3
import pprint
import re
# URL to be scraped
URL = 'https://wiprodigital.com/'
def format_html_to_xml_soup(url):
'''
takes in webpage url
returns the html code for that url
'''
# create HTTPResponse object using the above URL
http = urllib3.PoolMan... |
4ce63e1a96a04fc937685ccd662e2e517d9b1db4 | afrokoder/csv-merge | /Grainger_vxref.py | 377 | 3.5 | 4 | # import csv
# csv_file = open("/Users/knuchegbu/Desktop/Grainger.csv", "r")
# csv_reader = csv.reader(csv_file)
# new_file = open("/Users/knuchegbu/Desktop/Grainger_2.csv", "w")
# fieldnames = []
# csv_writer = csv.writer(new_file)
# for row in csv_reader:
# fieldnames.append(row [2])
# #csv_writer.writero... |
d41d93300fc659e924eb428277a9a368e6c5c153 | Mdbaker19/Python-basics | /own_generator.py | 984 | 3.875 | 4 | # generators save memory but is slower typically
# generators yield things not return
def simple_gen():
yield "Oh"
yield "Hello"
yield "there"
for i in simple_gen():
print(i)
correct_combo = (4, 3, 8)
found = False
for c1 in range(10):
if found:
break
for c2 in range(10):
if ... |
bb9dae16775cc27cf357c4a65364002c7779d5c9 | andrewherren/GEB | /FormalSystems/tqSystem.py | 1,457 | 3.828125 | 4 | """Encode Hofstadter's formal tq system"""
import re
class TQ(object):
"""format for working with string bound by tq rules"""
def __init__(self, inputstring: str):
"""initialize string, validate it is an axiom"""
if re.search("-*t-*q-*", inputstring):
# split regex along p and q l... |
245500fab4e6aab9b796d6c31d7ac3a19db75e45 | YossiBenZaken/Python-Scripts | /HW1_315368134.py | 2,883 | 3.703125 | 4 | """
Yossi Ben Zaken ID-315368134
"""
#-----Targil-1-----
"""
num=int(input('Enter number with 5 digits:'))
sum1=0;
if num%10%2==0:
print(num%10,end=', ')
else:
sum1+=num%10
num//=10
if num%10%2==0:
print(num%10,end=', ')
else:
sum1+=num%10
num//=10
if num%10%2==0:
print(num%10,end=', ')
else:
su... |
0efedca0d31629daf130d2a4622cc5b022bd89c0 | smallest-cock/python3-practice-projects | /Discord challenge projects/AddIntegers.py | 333 | 3.84375 | 4 | # Takes input of 10 integers. Adds them and prints the result.
total = 0
nums = []
nums.append(int(input('Enter an integer: ')))
for i in range(9):
nums.append(int(input('Enter another integer: ')))
for i in range(len(nums) - 1):
total += nums[i]
print(str(nums[i]), end='+')
print(str(nums[-1]) + ' = ' +... |
ac05c5e59ea82efce5d9f7b24ae1217d5cd08373 | smallest-cock/python3-practice-projects | /Discord challenge projects/TwoLists.py | 937 | 4.1875 | 4 | '''Take two lists, say for example these two:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
and write a program that returns a list that contains only the elements
that are common between the lists (without duplicates). Make sure your
program works on two lists of different ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.