blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
9222b9bcabb51b3adf0e7619ab871f5b0cb15ded | RVdeported/PyAlgo | /Lesson_3/task_3.py | 706 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 18 18:16:45 2021
@author: Roman
"""
"""
3. В массиве случайных целых чисел поменять местами
минимальный и максимальный элементы.
"""
import random as r
nums = [r.randint(0,99) for n in range(10)]
print(nums)
low_num_i = 0
large_num_i = 0
for i, n in enumerate(nums):
... |
894ede2e98b4285cbd5ecf2a2cf6b512bafbbb55 | awxinmin/bt4222-burpple-reviews | /utils/preprocessing.py | 1,214 | 3.609375 | 4 | import string
from string import digits
import pandas as pd
def clean_review(review) :
'''
Removes digits, empty strings, and new lines from phrases
Parameters:
review (string): review text
Output:
review (string): processed review texttext
'''
# remove numbers
remove_di... |
e403728cb04da9fd353b4a68ea2546bb4d3a0689 | gammarayburst999/Coursera | /Python_Functions_Files_Dictionaries/Week_04/Part_B.py | 3,520 | 4.46875 | 4 | #course_2_assessment_7
#Create a function called mult that has two parameters, the first is required and should be an integer, the second is an optional parameter that can either be a number or a string but whose default is 6. The function should return the first parameter multiplied by the second.
default=6
def mult(... |
1d1778f45c1b3800d06fd029ff7f8a5a0d66102d | gammarayburst999/Coursera | /Python_Functions_Files_Dictionaries/Week_01/question_06.py | 288 | 3.65625 | 4 | #Create a list called emotions that contains the first word of every line in emotion_words.txt
fname="emotion_words.txt"
file1 = open(fname,"r")
emotions=[]
for x in file1:
a=file1.readline()
b=a.split()
emotions.append(b[0])
#print(b)
print(emotions)
file1.close()
|
9993999b54b7b5d5fba00fdc6a30cc5622ed5b80 | gammarayburst999/Coursera | /Python_Basics/Week_03/question_03.py | 473 | 4 | 4 | #Write code to count the number of strings in list items that have the character w in it. Assign that number to the variable acc_num.
items = ["whirring", "wow!", "calendar", "wry", "glass", "", "llama","tumultuous","owing"]
acc_num=0
str='w'
for i in range(len(items)):
print(items[i])
b=items[i]
print(typ... |
a5fcb149580f9c527a29e6f4062b9eb7c836d680 | gammarayburst999/Coursera | /Python_Basics/Week_04/question_01.py | 396 | 4 | 4 | #Below are a set of scores that students have received in the past semester. Write code to determine how many are 90 or above and assign that result to the value a_scores
scores = "67 80 90 78 93 20 79 89 96 97 92 88 79 68 58 90 98 100 79 74 83 88 80 86 85 70 90 100"
print(type(scores))
a=scores.split()
print(a)
a_scor... |
82fd32c3034f4dbdf66fad4254af4dfb33cd116a | Shamsullo/HackerRank_Python- | /ErrorsAndExceptions/Exceptions.py | 251 | 3.625 | 4 |
# Enter your code here. Read input from STDIN. Print output to STDOUT
t = int(input())
for i in range(t):
a,b = raw_input().split()
try:
print(int(a) // int(b))
except Exception as e:
print ("Error Code: " + str(e))
|
02c7899045560a22e7a15eb610e261b9a4d8ce15 | Petro1919/Recommender-System | /PetroMalkoun_Lab1_NonPerRecommender.py | 6,329 | 3.859375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import csv
import numpy as np
import pandas as pd
# In[2]:
# I actually read the dataset as a csv and did not build it because I want it as a DF
input_file=pd.read_csv("../../DataSets/movieratings.csv",header=0)
# In[3]:
#function that returns the n elements hav... |
039f33ba81c66c6fa00f76024bd8efb2ee29f6b0 | SnippyValson/DailyCodingProblems | /Problem1.py | 260 | 3.5 | 4 | # Solved with hint.
# Use set since look up in set is O(1)
def two_sum(lst, k):
seen = set()
for num in lst:
if k-num in seen:
return True
seen.add(num)
return False
result = two_sum([10, 15, 3, 7], 18)
print(result) |
911dc72e0e1496cde04762410f92100dea7fb942 | frankma/Sandbox | /bet/binary_expression_tree.py | 2,220 | 3.5 | 4 | from typing import Dict
class Expression(object):
def __str__(self):
raise NotImplemented
def evaluate(self, env: Dict):
raise NotImplemented
pass
class BinaryOperator(Expression):
def __init__(self, left: Expression, right: Expression):
self.left = left # type: Expression... |
de23715eae61991a6a5ff2982e0c5fc9154a2a06 | jrwalk/empath | /NLP/tf_idf.py | 1,708 | 3.5 | 4 | """Calculators for TF-IDF score for word list, taken from pre-calculated
frequency distribution from word_count.
"""
import nltk
from nltk.text import TextCollection
import pickle
import glob
import re
def tf_idf(freqdist,corpus):
"""Calculates TF-IDF score for series of words, using distribution in
freqdist for ... |
6b74fdc249485fb2fa6a0a755747346638da65de | jj131204/Excercises-python | /exercises/exercises8.py | 379 | 3.75 | 4 | lista = []
print('Ingrese números y para salir escriba "basta"')
while True:
valor = input('Ingrese valor: ')
if valor == 'basta':
break
else:
try:
valor = int(valor)
lista.append(valor)
except:
print('Dato inválido')
exit()
resultado ... |
abe3713a43c57d6564c638ceacbab2c2ce308a0a | meermm/test | /композиция.py | 908 | 4.1875 | 4 | '''
По композиции один из классов состоит из одного или нескольких экземпляров других классов.
Другими словами, один класс является контейнером, а другой класс - содержимым, и если вы удалите объект-контейнер, все его объекты содержимого также будут удалены.
'''
class Salary:
def __init__(self, pay):
self... |
e4dcddcf7daf425a58c1dc132cc78e41a8e2ce56 | 2021-jgottschalk-projects/2020_Code_Advent | /AOC_Puzzle_10_v1.py | 597 | 3.765625 | 4 | # write data from file
f = open("2020_advent_10_data.txt", "r")
content = f.read()
numbers = content.splitlines()
f.close()
# Change data to integers...
integer_list = []
for item in numbers:
item = int(item)
integer_list.append(item)
integer_list.sort()
# print(integer_list)
num_1s = 1
num_3s = 1
count = ... |
97dc5d4f60aea3eccef2bb82d1fbdcb6eba39bb1 | 2021-jgottschalk-projects/2020_Code_Advent | /AOC_Puzzle_07_v3.py | 1,166 | 3.625 | 4 | import re
# Main routine goes here
# write data from file
f = open("2020_advent_07_data.txt", "r")
content = f.read()
whole_rules = content.split(". ")
f.close()
all_rules = []
for item in whole_rules:
rules = re.split(r"contain | ,", item)
all_rules.append(rules)
total = 0
start_over = ""
colors = [... |
8fa01771b9f4a9281dc29576807ba7a3d5d7a4d9 | Ayobamidele/python_projects | /dateofbirth.py | 166 | 3.875 | 4 | from datetime import datetime , timedelta
birthyear = int(input("what is your birth: "))
current_time = datetime.now()
x = current_time.year - birthyear
print(str(x)) |
6aa1106207350a8504d987005b2fc9fcfdb308c9 | Arsalan-Habib/python-projects | /random_guesser_V2.py | 733 | 3.96875 | 4 | import random
def random_guesser():
tries=1
z=random.randint(1,10)
x=int(input("\nEnter a number from 1 till 10\n"))
win=False
while win==False:
if x==z:
print("\nMubarak Ho! Tussi Jeet Gaye Janab\nIt took you only "+str(tries)+" tries.")
check=int(input("\nPress 0 if you want to play again or pres... |
34e2f61b808885f8ef0f2a5073ba3ed90cc0d9fe | inwk6312winter2019/model-openbook2-NandanDadi96 | /prog3.py | 634 | 3.796875 | 4 | file=open("Street_Centrelines.csv","r")
def tuplelist():
for line in file:
line=line.split(',')
word=(line[2],line[4],line[6],line[7])
print(wo
def histogram():
hist=dict()
for line in file:
line=line.split(',')
word=(line[12])
if word not in hist:
hist[word]=1
else:
hist[word]+=1
print(hist)
... |
5b3a03e924c9d6e15ba1e754c8df3e2c6f101f6c | weah79/Python | /EP4.py | 4,874 | 3.71875 | 4 | Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> friend = ['Prasong','Somsak','Loong']
>>> type(friend)
<class 'list'>
>>> print(friend[0])
Prasong
>>> print(friend[1])
Somsak
>>> print(friend[-1])... |
b6737c9c7caef4ce65543c8150519c03a54d9f32 | bayan79/AlgoPythonLabs | /lab3.py | 586 | 3.53125 | 4 | from lab2 import fuzzy_compare_string
ACCURACY = 0.7
# set of tuple(question: str, answer: str)
answers = set()
def get_answer(question: str):
if question:
if question == 'exit':
exit()
for quest, ans in answers:
similarity = fuzzy_compare_string(question, quest)
... |
5c55c69148cbd5e5c8528ee7383dbf65b9e664f6 | MarcusJul/LeetCodewithPythonandCPP | /Python/Easy/69-Sqrt(x).py | 936 | 3.671875 | 4 | class Solution:
def mySqrt(self, x: int) -> int:
if x<=1:
return x
def binary(left, right):
f = int((left+right)/2)
if f*f>x: # larger than proper
if (f-1)*(f-1)<=x:
return f-1
else:
return bi... |
5f1e8aba3471c8bb3bf44663cea68d37894689d3 | MarcusJul/LeetCodewithPythonandCPP | /Python/Medium/206-Reverse Linked List.py | 773 | 3.890625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head==None:
return None
store = []
cur_node = head
while(cur_node... |
52603fe5c21f1abd2b0e7bd0a666365eab1effbe | MarcusJul/LeetCodewithPythonandCPP | /Python/Easy/21-Merge Two Sorted Lists.py | 1,051 | 3.78125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def mergeTwoLists(self, l1, l2):
head = []
if l1==None:
pass
else:
cur_l = l1
while(True):
... |
07673c2513666dd0e04a85d37376e8bb48e6216d | AnnaRehorkova/pokusy | /nasobilka.py | 121 | 3.671875 | 4 | cislo = 0
for i in range(5):
for i in range(5):
print(cislo*i, end = " ")
cislo += 1
print(end="\n")
|
e91f0477830d9570d288cb2e3383c48d93552927 | siship/flask-tutorial-asr-school-2021 | /app_test_1.py | 1,601 | 4.09375 | 4 | # Import Flask library
from flask import Flask, request
# Initialize the Flask application object, which contains data about the application and also methods, such as run().
app = Flask(__name__)
# Flask will map the HTTP requests [GET or POST] to Python functions.
# In this case, we’ve mapped one URL path (‘/’) to... |
36453e18ccf300af3c3f669007ac1e2d106284dd | jhb86253817/coursera-nlp | /week2/h1-p/part2.py | 3,860 | 3.53125 | 4 | #! /usr/bin/python
__author__ = "Haibo Jin"
import operator
import part1
#part2, exercise of week2, from coursera course NLP lectured by Michael Collins
#POS tagging with HMM model
def pre_prob():
"""calculate the probability for all the pairs of grams permutations"""
prob_index = {}
file_in = open('... |
b58e1ff0fb886bfb2bd5287762fa262f3e1d3b5e | drkwons/study | /1.py | 611 | 3.53125 | 4 | class Cal(object):
_history = []
def __init__(self, v1, v2):
self.v1 = v1
self.v2 = v2
def add(self):
result = self.v1+self.v2
Cal._history.append("add : %d+%d=%d" % (self.v1, self.v2, result))
return result
@classmethod
def history(cls):
for r... |
f4b6b9567c9029d08ab16e662169b963ce4d716b | jlindow/Python | /break.py | 456 | 3.609375 | 4 | # Break's a Caesar Shift Cipher
import sys
ciphertext = sys.argv[1]
for k in range(0, 26):
plaintextlist = []
for i in range(len(ciphertext)):
char_num = ord(ciphertext[i]) - 65 #map to 0 - 25
shifted_num = (char_num - k) % 26
plainletter = chr(shifted_num + 65)
plaintex... |
2f8c743c539735310694c173f1fe79d52a4e8d05 | Hohlenwerger/Python-Solution | /dbValidate/jsonUtils.py | 796 | 3.578125 | 4 | # Author: HohlenwergerMB
# *Indented with tabs*
# Import JSON methods
import json
def jsonReader(file):
try:
# Open JSON file with encoding UTF-8 to prevent problems with special chars
with open(file, encoding="utf8") as data_file:
return json.load(data_file)
except:
print("\nError: 'broken-database.... |
645e8b3b2344d9792dae73cd90c2d91e1f86dce5 | sichkar-valentyn/Variables_and_Branching_in_Python | /Variables_and_Branching_in_Python.py | 1,575 | 3.59375 | 4 | # File: Variables_and_Branching_in_Python.py
# Description: Variables and Branching in Python
# Environment: Spyder IDE in Anaconda environment
#
# MIT License
# Copyright (c) 2018 Valentyn N Sichkar
# github.com/sichkar-valentyn
#
# Reference to:
# [1] Valentyn N Sichkar. Variables and Branching in Python // GitHub pl... |
c9195fab307d8291d6ea8b9e7d7109d91d59d6e3 | jeantorresa190899/TrabajoFinal | /Desarrollo.py | 8,779 | 3.890625 | 4 | import os, sys
os.system("cls")
import random
# Inicio de la Aplicación
print("********* Hola, bienvenido a esta nueva plataforma de aprendizaje.***********")
nombre = str(input("¿Cuál es tu nombre? -----------> "))
print("Hola", nombre)
print("Este programa consiste en responder 20 preguntas de cultura"
+ " gene... |
11a05408872bf65359cdc304c6a331669244ee58 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_3/Week3_8.py | 125 | 3.734375 | 4 | sum = 0
for i in range (100,5001):
if(i%2==0):
sum+=i
print("Sum of even number between 100 to 5000 is {}".format(sum)) |
916526953bd5aa3d1a35cbe609fc38b3e1498290 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_4/Assignment1/prac5.py | 218 | 4.03125 | 4 | string = input("Enter string")
digit=0
letter=0
for i in string:
if i.isalpha():
letter=letter=1
elif i.isdigit():
digit=digit+1
else:
pass
print("Letters", letter)
print("Digits", digit)
|
3ac1299605142a62c6c7c9e4df09020fccb95c75 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_4/Assignment2/4.py | 731 | 4.15625 | 4 | from collections import Counter
list1 = [1, 2, 3, 2, 2, 2, 5, 6]
counter = 0
num = list1[0]
for i in list1:
current = list1.count(i)
if(current>counter):
counter=current
num=i
print("Most common element in list: ",num)
print("Count of element in list: ", counter)
tuples = ("apple", 2, 3,"apple","apple", "a... |
e1b1de73799d1d44e298b41c3f423c75cb3b4257 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_1/Practical6.py | 411 | 4.03125 | 4 | def countNotes(amount):
notes = [2000, 500, 200, 100, 50, 20, 10, 5, 1]
notes_counter = [0, 0, 0, 0, 0, 0, 0, 0, 0]
print("Note count: ")
for i,j in zip(notes, notes_counter):
if(amount>=i):
j = amount//i
amount = amount - j*i
print(i, "->", j)
amt = int(inpu... |
59e4a6bab2feb777b3bec0b1ece5c6bccf1c2433 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_1/Practical7.py | 501 | 4.21875 | 4 | choice = int(input("To covert rupees to dollar- enter 1 and to convert dollar to rupees - enter 2 "))
if(choice==1):
amt_rupees = float(input("Enter amount in rupees: "))
cnv_dollar = amt_rupees/70
print(amt_rupees, "rupees is equal to ", cnv_dollar, "dollar/s")
elif(choice==2):
amt_dollar = float(input... |
2d3d24ee9b830952d42454b324fde4225ef0aa65 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_14/Exercise5.py | 280 | 4.03125 | 4 | import random
num = random.randint(1,9)
user_num = int(input("Enter a number: "))
if user_num<num:
print("Your guess is too low")
elif user_num>num:
print("Your guess is too high")
elif user_num==num:
print("Your guess is exactly right")
print("The number is: ",num)
|
341402e6ff696fcac7b2d8c49c7023d51d8da541 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_4/Assignment2/Dictionary/a.py | 126 | 3.578125 | 4 | studentdict={
"name":"Nidhi",
"surname":"Gajjar",
"id":"18IT033"
}
if "id" in studentdict:
print("Yes, 'id' is key")
|
83b109d253ef300b87470547a79dfd0e0791a181 | nidhi2802/18IT033_IT374_PythonProgramming_Practical_Tasks | /Week_4/Assignment1/prac2.py | 176 | 3.875 | 4 | for num in range (1,101):
if(num%6==0 and num%4==0):
print("CHARUSAT_IT")
elif(num%6==0):
print("CHARUSAT")
elif(num%4==0):
print("IT")
else:
print(num) |
1c1ce2d401051d1c3018287f316fbbab98a5b53f | generative-adversarial-networks/introduction-neural-networks | /train_two_layer_neural_network.py | 6,340 | 4.40625 | 4 | """
Author: Jamal Toutouh (toutouh@mit.edu)
train-two-layer-neural-network.py contains the code to create and train a basic neural network with:
- two inputs: x1, and x2
- a hidden layer with two neurons: h1 and h2
- an output layer with a neuron: o1
"""
import numpy as np
from neuron import ActivationFunctions
from ... |
1ca2340361d2623294f76a41dc5181d62b5d17c9 | melandres8/holbertonschool-higher_level_programming | /0x06-python-classes/3-square.py | 733 | 4.375 | 4 | #!/usr/bin/python3
"""Square class"""
class Square():
"""Validating if size is an instance
and if is greater and equal to 0
Attributes:
attr1 (int): size is a main attr of a square
"""
def __init__(self, size=0):
"""isinstance function checks if
the object is an instance or... |
5f353edcbb4e50cf26f5b1ac3719426d694b0c59 | melandres8/holbertonschool-higher_level_programming | /0x0B-python-input_output/14-pascal_triangle.py | 470 | 3.921875 | 4 | #!/usr/bin/python3
""" Pascal module
"""
def pascal_triangle(n):
""" Returning a list of lists
of integer representing
the pascal's triangle of n
"""
my_list = []
if n <= 0:
return my_list
for item1 in range(1, n + 1):
number = 1
row = []
for item2 i... |
213fba542e50c8878410245e7f63ee82d4747ae8 | melandres8/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/2-uniq_add.py | 136 | 3.703125 | 4 | #!/usr/bin/python3
def uniq_add(my_list=[]):
new = set(my_list)
add = 0
for item in new:
add += item
return add
|
648d3e6898443d625148a4fa7b6a4d1836f940a8 | melandres8/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/101-remove_char_at.py | 290 | 3.828125 | 4 | #!/usr/bin/python3
def listToString(lista):
str1 = ""
for item in lista:
str1 += item
return str1
def remove_char_at(str, n):
lista1 = []
for index, char in enumerate(str):
if index != n:
lista1.append(char)
return listToString(lista1)
|
44c5024a42eaf96442266aadb0f4b4a948a2af37 | melandres8/holbertonschool-higher_level_programming | /0x02-python-import_modules/3-infinite_add.py | 267 | 3.671875 | 4 | #!/usr/bin/python3
from sys import argv
if __name__ == '__main__':
ind = 0
argv.remove(argv[0])
if len(argv) is 0:
print("{:d}".format(len(argv)))
else:
for index in argv:
ind += int(index)
print("{}".format(ind))
|
9a956a51c89fe66441040b2db5ab0b5dd3bf53fe | melandres8/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/5-text_indentation.py | 758 | 4.1875 | 4 | #!/usr/bin/python3
"""
Handling new lines, some special characters
and tabs function.
"""
def text_indentation(text):
"""
Print a text with two new line at the end
after each of these characters '.'':''?'
Args:
text: (string) Given text
Raises:
Type... |
9923d3414c6e87199ffca081c646b80967cac9d8 | melandres8/holbertonschool-higher_level_programming | /0x0A-python-inheritance/10-square.py | 445 | 4.1875 | 4 | #!/usr/bin/python3
""" Applying inheritance and super() method
"""
Rectangle = __import__('9-rectangle').Rectangle
class Square(Rectangle):
""" Defining constructor
"""
def __init__(self, size):
"""Constructor method
Args:
size: square size
"""
self.int... |
aae62d6b9cace68fca666fce4a8a4ee290f67c6c | LookerKy/Python_start | /src/section07-2.py | 1,858 | 3.734375 | 4 | # Section07-2
# 파이썬 클래스 상세 이해
# 상속 다중 상속
# 예제 1
# 상속 기본
# 슈퍼클래스 및 서브클래스 -> 모든 속성 및 메소드를 사용 가능
# 상속을 통해 코딩을하면 재사용성, 공통 속성 제거,
# 라면 -> 속성(종류, 회사, 맛, 면 종류 ,이름) : 슈퍼클래스 (공통적인부분)
# 예제 1
class Car:
"""Parent Class"""
def __init__(self, tp, color):
self.type = tp
self.color = color
def show(... |
c2581e430f7eb8be0524bc38a01ac904ae043ab3 | komararyna/homework_2 | /task5.py | 86 | 3.8125 | 4 | x=int(input('insert number of 3 digits:'))
a=x%10
b=x%100 //10
c=x//100
print(a+b+c)
|
599dbcf884a3f5fa0ac02c6af742577cff6c33fe | Rillell/2_Grade_Project | /Python/2주차/0407.py | 468 | 3.6875 | 4 | num10 = 0
sel = int(input("입력진수 : "))
num = input("값 입력 : ")
if sel == 16 :
num10 = int(num, 16)
if sel == 10 :
num10 = int(num, 10)
if sel == 8 :
num10 = int(num, 8)
if sel == 2 :
num10 = int(num, 2)
if num10 == 0:
print("입력진수는 16, 10, 8, 2 진수여야 합니다")
else :
print("16 : ", hex... |
780e738f5917bf1de28f62cecd04413f8de1fa2d | Rillell/2_Grade_Project | /Python/3주차/0414_3.py | 209 | 3.96875 | 4 | #반복문 출력 0부터 시작, 3미만까지, 1씩 증가
for i in range(0, 3, 1) :
print(i, end=', ') #end=' ' => 옆으로 출력
print()
for i in ['S',0,1.12] :
print(i, type(i))
|
54e2d54dd28d97bb6233eaacf045e9fb4c5b7fbf | Penultimatum/discord-boar-bot | /src/boarbot/modules/dice/diceroll.py | 2,759 | 3.671875 | 4 | import random, regex
def roll_dice(num_dice: int, num_sides: int) -> [int]:
num_dice = int(num_dice)
num_sides = int(num_sides)
if num_dice < 1:
raise ValueError("Number of dice less than 0", num_dice)
if num_sides < 1:
raise ValueError("Number of sides less than 0", num_sides)
roll... |
b4e03131c51c1925d26fe5703e2edcd3c06b01c1 | Wanbli83470/SCRIPT_ILLUSTRATOR | /TEXTE.py | 421 | 3.953125 | 4 | lettre = input("Indiquer la lettre en majuscule : ")
nb_page = input("indiquer nombre de page : ")
nb_page = int(nb_page)
numerotation = 1
while numerotation <= nb_page :
texte = "493165 "+ lettre + str(numerotation)+" AROMA ZONE"
numerotation += 1
print(texte)
print(texte)
"""import pyperclip
pyperclip.copy('The... |
6397f2dda17c503e09fae36399e79926821442ea | lvvvmd/leetcode | /Partition List/Solution.py | 819 | 3.84375 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def partition(self, head, x):
"""
:type head: ListNode
:type x: int
:rtype: ListNode
"""
small_list =... |
507aacd87c59aa891d10d3bc69b90134e4ad1c5d | aravindanath/Target2020PyAuto | /Assignment/tax_assignment_chinu.py | 361 | 3.78125 | 4 | def calculator(gross ,state):
state_tax={"BOS":9,"NJ":8,"TX":7,"CA":10,"NY":6}
netIncome=gross-(gross*.10)
if state in state_tax:
netIncome=netIncome-(gross*state_tax[state]/100)
print("your net income is:" +str(netIncome))
return netIncome
else:
print("enter your detai... |
05f66f08d121afec9e6ff846a5649fa30ffd2ff4 | aravindanath/Target2020PyAuto | /day4/whileDemo.py | 332 | 3.828125 | 4 | #
# l1 = []
# x=0
#
# while x <10:
# # x= x+1
# # print(x)
# x = x+1
# l1.append(x)
# continue
#
#
# print(l1)
empty = []
print(empty)
# Initialization
x = 0
# Condition
while x < 10:
# Increment
x = x +1;
print(x)
empty.append(x)
else:
print("Just broke out of the loop")
p... |
2350c2ab05499f1b40ba61f2101c51d9581d57f6 | aravindanath/Target2020PyAuto | /day4/methods.py | 155 | 3.9375 | 4 |
def addnumber(i,j):
sum= i+j
print(sum)
num1 = int(input("Enter 1st number"))
num2 = int(input("Enter 2nd number"))
z = addnumber(num1,num2)
|
e65119c8890ffa65825199cb4debb8cc20078782 | aravindanath/Target2020PyAuto | /Assignment/TaxAssignment.py | 421 | 3.640625 | 4 |
def taxCaluculator(gross,state):
state_tax={"BOS":9.9,"NJ":8.3,"Tx":7.99,"CA":10.3,"NY":6.43}
net = gross - (gross * .10)
if state in state_tax:
net = net - (gross * state_tax[state] / 100)
print("Your net income after all the heavy taxes is : " + str(net))
return net
else:
... |
7a96fb5c6d3cc968ea845478e958d64c646a9df5 | aravindanath/Target2020PyAuto | /Day3/NestedDict.py | 223 | 3.84375 | 4 | student = {"name":{"Arvind","Naina","Bhavya","Kumar"}}
print(student)
cars={"Bmw":{"model":"2020","colour":"Blue"},"Audi":{"model":"Q5","colur":"red"}}
print(cars["Bmw"]["colour"])
print(cars.keys())
print(cars.values()) |
4a81edb424f544664d9a6e279783923424e5d7bf | aravindanath/Target2020PyAuto | /day5/homeWork.py | 200 | 3.671875 | 4 |
def exception():
try:
car = {"make": "bmw", "Model": '550i', 'year': 2019}
print(car["colour"])
except:
print("Colour not found")
# raise exception()
exception() |
d1c52c1792e509f17666cf35d6c43fdf162f21c2 | KNU-CS09/Baekjoon | /2/kdh/7_2558.py | 77 | 3.65625 | 4 | a = int(input())
b = int(input())
if(0 < a < 10 and 0 < b < 10):
print(a+b) |
e89d2a1bb8619dd97424585534da78618f6c4bf7 | ml-nic/Algorithms | /src/typical_string_processing_functions.py | 1,007 | 4.125 | 4 | def is_palindrome(string: str) -> bool:
"""
Is the string a palindrome?
:param string:
:return:
"""
length = len(string)
for i in range(int(length / 2)):
if string[i] != string[-i - 1]:
return False
return True
assert is_palindrome("HelloolleH") is True
assert is_pa... |
fd48332d351fb0b6f96ddf552e760b5529c5a70c | Rojina99/DesignPatterns-Python | /project/observer.py | 1,338 | 3.515625 | 4 | class Subject:
observers = []
def Attach(self, obj):
self.observers.append(obj)
def Detach(self, obj):
pass
def Notify(self):
for observer in self.observers:
observer.Update()
# print(self.observers)
class ConcreteSubject(Subject):
def __init__(self):
... |
9b3581f4110efd5c01ce48a302015bc286ff2780 | jackie500/python | /első két szám összege egyenlő e a harmadikkal.txt | 602 | 3.765625 | 4 |
szám1 = int(input("szám1: "))
szám2 = int(input("szám2: "))
szám3 = int(input("szám3: "))
összeg1 = szám1 + szám2
összeg2 = szám1 + szám3
összeg3 = szám2 + szám3
if összeg1 == szám3:
print("igen a", szám1, "és", szám2, " összege egyenlő", szám3, "-al")
elif összeg2 == szám2:
print("igen a", ... |
b5673ec003759f8e063728be0d5d5ebaf3d11173 | jackie500/python | /26..py | 329 | 3.578125 | 4 | # 26
"""
Írj egy Python programot, amely a temp.txt szöveges fájl minden második szavát (szóközzel
elválasztott részsztringjét) a képernyőre írja!
"""
f = open("temp2.txt")
fS = f.read()
f.close()
fSList = []
fSList = fS.split(" ")
for i in range(1, len(fSList), 2):
print(fSList[i])
|
aacb52f8c34cfc45c04c4339c5c4b6d317023541 | jackie500/python | /12..py | 290 | 3.890625 | 4 | # 12. Írj egy Python programot, amely bekér egy szót (sztringet) a felhasználótól és kiírja a képernyőre a szó betűit, úgy, hogy minden betű egy új sorba kerüljön!
szó = input("adjon meg egy szót: ")
for i in range(len(szó)):
print(szó[i], end=" ")
|
81e46e52df2c2e9d9f79df2b5711150b636fc740 | jackie500/python | /6..py | 382 | 3.796875 | 4 | #6. Írj egy Python programot, amely bekér három egész számot a felhasználótól és kiírja a képernyőre, hogy mind a három páros szám-e (igen/nem)!
összeg = int(input("szám1: ")) + int(input("szám2: ")) + int(input("szám3: "))
if összeg % 2 == 0:
print("igen")
else:
print("nem")
#folytatni tovább: egyesé... |
db53c9384a2aa95036c7e4d2ad7d675a9950c1cc | jackie500/python | /main2.py | 194 | 3.875 | 4 | x = input("Írj egy számot: ")
y = input("Írj egy számot:")
z = input("Írj egy számot:")
if x > y and z:
print(x)
if y > x and z:
print(y)
if z > x and y:
print(z)
|
89217f458279e92ee6df66f495d97f41b62ee5eb | khanmaster/building_packages | /app/fizzbuzz.py | 756 | 3.765625 | 4 | class Fizzbuzz:
def __init__(self, start_of_range, end_of_range):
self.fizzrange = range(start_of_range, end_of_range)
self.fizzbuzz_list = []
self._fizzbuzz_iterator()
def _divisible_by(self, num1, num2):
if num1 % num2 == 0:
return True
else:
r... |
15c27949ec5d743e326a2f92936a2798db959939 | AbdeAMNR/python-training | /00 expose Py/matplotlib - pandas - scipy (visualisation)/visualisation.py | 1,137 | 3.640625 | 4 | import pandas
from matplotlib import pyplot
from scipy import stats
my_data = pandas.read_csv("univariate_linear_regression_dataset.csv")
print("head : ")
print(my_data.head())
print("tail : ")
print(my_data.tail())
X = my_data.iloc[0:len(my_data), 0]
Y = my_data.iloc[0:len(my_data), 1]
pyplot.xlim([0, 25])
pyplot.... |
131aab97b27accfe995276674ee6a2959f51140d | AbdeAMNR/python-training | /Lecture 03 OOP/Person.py | 1,327 | 3.96875 | 4 | class Person(object):
__first_name = ""
__last_name = ""
__age = ""
def __init__(self, first_name, last_name, age):
self.__first_name = first_name
self.__last_name = last_name
self.__age = age
def full_name(self):
return "{} {}".format(self.__first_name, self.__last... |
f4bd7f39b23698c8328b007ce20f8147d1020699 | AbdeAMNR/python-training | /Lecture 03 OOP/ClassInOneLine.py | 769 | 3.671875 | 4 | # create a class in one single line.
# pros:
# less lines of code
# dynamic class creation
# cons: the code cold be be missy: not recommended for long classes
BaseClass = type("BaseClass", (object,), {"att": 2, "att2": 5})
C1 = type("C1", (BaseClass,), {"firstAtt": "hello", "SecAtt": 52})
C2 = type("C2", (BaseClas... |
422c8cd0e2bcc3bce513c2a4b412d775b328e138 | massivetarget/mtar_a | /capping.py | 201 | 4.1875 | 4 | # this is python file for capitalisation of give string
nm = str(input("please Enter word to capitilise it: "))
print(nm.capitalize())
# this will do the real work
print("adding 23 to 34", 23 + 34)
|
8d3475b6b96b34f9f280eba1124ae6e5583a45fe | Girech/infosatc-lp-avaliativo-01 | /ex10.py | 119 | 3.953125 | 4 | km = float(input("Digite uma velocidade em Km/h:"))
ms = km/3.6
print("A velocidade de {} em M/S é: {}".format(km,ms)) |
db5e1ae7eee9779208aaf0aaa7f46e67f3a589e4 | Girech/infosatc-lp-avaliativo-01 | /ex26.py | 115 | 3.53125 | 4 | m2 = float(input("Digite o valor em m²"))
hectares = m2*0.0001
print("o valor em hectares é:{}".format(hectares)) |
1477902c7c0c5bdb2d9353ee1bad8d3f2ea6cd8e | rsamit26/AlgorithmsAndDatastructure | /EulerProject/10001st prime.py | 999 | 3.96875 | 4 | """
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that
the 6th prime is 13.
What is the 10 001st prime number?
"""
class Solution:
def isPrime(self, n):
if n == 1:
return False
elif n < 4:
return True
elif n%2 == 0:
return F... |
a20abaa8905d70a8f84992151cf381cd884f1f78 | rsamit26/AlgorithmsAndDatastructure | /algorithms/Python/sorting/bucketSort.py | 1,012 | 3.90625 | 4 | """
Bucket sort algorithm ::
"""
import math
def insertion_sort(arr):
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >= 0 and key < arr[j]:
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key
def hashing(arr):
m = max(arr)
result = [m, int(ma... |
aec494fc191d4c4ad71c109b09c2e47abb558776 | rnu/Python_Freecell | /Python_Freecell.py | 15,751 | 3.8125 | 4 | ##################################################################
# Section 3
# Computer Project #8
##################################################################
# Algorithm
# 1.Call main()
# 2. Build game board
# 3. Print Gameboard()
# 4. Ask user input.
# 5. Validate user move
# 6.... |
ec6d87abbc3b27ae1bfcac34c4c921f3c493eb69 | jsourabh1/Striver-s_sheet_Solution | /Day-12_Bits/question1_power_of_2.py | 265 | 4.03125 | 4 | class Solution:
##Complete this function
# Function to check if given number n is a power of two.
def isPowerofTwo(self,n):
if n==0:
return False
if (n&(n-1))==0:
return True
return False |
cde8cc5295ece077049c3e4c432419aa331c0c59 | jsourabh1/Striver-s_sheet_Solution | /Day-19_BinaryTree3/question1_maximum_sum.py | 736 | 3.5 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def maxPathSum(self, root: Optional[TreeNode]) -> int:
ans=-float("inf")
d... |
eb7746e1dcdccaecbde4b17f2f6db92830b0751d | jsourabh1/Striver-s_sheet_Solution | /Day-17_BinaryTree/question1_inorder.py | 1,522 | 4.09375 | 4 | class Node:
# Constructor to create a new node
def __init__(self, data):
self.data = data
self.left = None
self.right = None
# With recursion
def inorder(root):
if not root:
return
inorder(root.left)
print(root.data, end=" ")
inorder(root.right)
# With stac... |
569a69d27cd52c961e1fa7a3f63b7effe2bcdbc6 | jsourabh1/Striver-s_sheet_Solution | /Day-16_String2/question4_anagrams.py | 378 | 3.84375 | 4 |
class Solution:
#Function is to check whether two strings are anagram of each other or not.
def isAnagram(self,a,b):
a=sorted(a)
b=sorted(b)
if len(a)!=len(b):
return False
for i in range(len(a)):
if a[i]!=b[i]:
... |
776570db6172e6379b4dc91afd491c5b05871515 | jsourabh1/Striver-s_sheet_Solution | /Day-13_Stack/question3_queue_using_stack.py | 562 | 4.125 | 4 | def Push(x,stack1,stack2):
'''
x: value to push
stack1: list
stack2: list
'''
#code here
stack1.append(x)
#Function to pop an element from queue by using 2 stacks.
def Pop(stack1,stack2):
'''
stack1: list
stack2: list
'''
#code here
if stack1:
s... |
45e57b00ed86166064a52861f7249a2d68024c64 | alongigi/K-MeansClustering | /Cluster.py | 1,925 | 3.609375 | 4 | import matplotlib.pyplot as plt
import plotly.plotly as py
from sklearn.cluster import KMeans
"""
Responsible for the K-means idea as taught in class.
:Param {df} the the frame of the program
:Param {n_clusters} The number of clusters
:Param {n_init} Num of runs.
"""
def KMean(df, n_clusters, n_init):
km = KMea... |
1ba233bf6d91df731ef3347bfe864e6b353f2be8 | elinaavintisa/Python_2variants | /2uzdevums.py | 900 | 4.1875 | 4 | """
Funkcija akrs akceptē trīs argumentus - skaiļus viens, divi un trīs,
aprēķina to kvadrātu starpību un atgriež to.
Pārbaudiet funkcijas darbību ar dažādiem argumentiem,
parādot skaitli ar četriem simboliem aiz komata.
Argumenti:
viens {int vai float} -- pirmais skaitlis
... |
0d8629a72beac9a6c1320dd45867c30e60060638 | CAVIND46016/Academic-Coursework | /Artificial Intelligence/NQueens/nqueens.py | 4,091 | 4.0625 | 4 | import sys
import time
def count_on_row(board, row):
"""
Count # of pieces in given row
:param board:
:param row:
:return:
"""
return sum(board[row])
def count_on_col(board, col):
"""
Count # of pieces in given column
:param board:
:param col:
:return:
"""
... |
5bf9c62989dce3cd7176735ac06f56a8cc57fa2f | CAVIND46016/Academic-Coursework | /Strassens Matrix Multiplication/generate_test_matrices.py | 1,338 | 3.671875 | 4 | """
Creates two test matrices and writes it into
two text files ==> 'matRead1.txt' and 'matRead2.txt'
"""
import random
MATRIX_INPUT_1 = 'matRead1.txt'
MATRIX_INPUT_2 = 'matRead2.txt'
def write_random_matrix_to_file(filename, mat_dim1, mat_dim2, l_range, h_range):
"""
Writes matrix to text file
... |
79350df0310993beaf47d0dd72d3ec301e18a876 | Sebsiee/PLD-Assignment-2-SANTOS-BSCOE-1-6- | /Money & Apple.py | 575 | 3.828125 | 4 | print("Welcome!")
moneyAmount=int(input("Enter the amount of your money: "))
applePrice=int(input("What is the price of an apple? "))
totalApples=(moneyAmount / applePrice)
totalChange=(moneyAmount - applePrice )
if totalApples > 1:
print("You can buy " + str("%.0f" % totalApples) + " apples and your change is " + str... |
2c60d95891b60bc6a950004a12620d80286c4296 | RasaHQ/sphinx-markdown-builder | /sphinx_markdown_builder/depth.py | 758 | 3.609375 | 4 | class Depth:
depth = 0
sub_depth = {}
def get(self, name=None):
if name:
return self.sub_depth[name] if name in self.sub_depth else 0
return depth
def descend(self, name=None):
self.depth = self.depth + 1
if name:
sub_depth = (
s... |
71971acd89b0650884c1c909e322cf06867d5732 | mehulsharma3795/Stock-Options-Pricing-Model | /binomial_option_model.py | 975 | 3.625 | 4 | import numpy as np
def binomial_model(N, S0, u, r, K):
"""
N = number of binomial iterations
S0 = initial stock price
u = factor change of upstate
r = risk free interest rate per annum
K = strike price
"""
d = 1 / u
p = (1 + r - d) / (u - d)
q = 1 - p
# make stock price tr... |
07456dd2e3e0d57f305f7963cda5d31ecec92da6 | BhavyaTeja/Python-Mini-Projects | /GuessTheNumber.py | 684 | 4.09375 | 4 | #importing the libraries
import random
#Random function which generates the random numbers between 1 and 100
def rando():
a = random.randint(1, 100)
b = int(input('Guess the number between 1 and 100: '))
compare(a,b)
choice = input('You want to try again: Yes/No - ')
if choice == 'Yes' or choice ... |
933fcf4d71b8cbc8cb825b279feaee9a9fb5d44c | cas-gh/Black-Hole-Tutorial | /blackHole.py | 836 | 3.9375 | 4 | from decimal import Decimal
from math import sqrt
#### CONSTANTS ####
G = 6.674 * 10**-11 # in m^3 * kg^-1 * s^-2
c = 299792458 # in m/s
def blackHole():
# Uses formula for Schwarzschild radius to give size of
# black hole, photon sphere,
M = input("Enter a mass in kg: ")
rs = (2 * G * float(M... |
84bcfb6116c879af56bc8ff3e433b488259d0828 | ibrhmerdogan/emojiFindAll | /venv/Lib/site-packages/emot/core.py | 3,151 | 3.75 | 4 | import re
from emot import emo_unicode
#import emo_unicode
'''emot library to detect emoji and emoticons.
>>> import emot
>>> text = "I love python 👨 :-)"
>>> emot.emoji(text)
>>> {'value': ['👨'], 'mean': [':man:'], 'location': [[14, 14]], 'flag': True}
>>> emot.emoticons(text)
>>> {'value':... |
68a12531e11433cc86e5b6806f64e8ffa3a774a7 | RobinChien/python-study-notes | /Speed of 'while True' and 'while 1'/demo.py | 72 | 3.65625 | 4 | def add(a, b):
return a+b
c = add(1, 2)
print("Result of add:", c)
|
8aa22a1316b830c4b0c78d374adff5f099ea2bd5 | annikaheiling/CompOrgLabs | /Lab 3a - Week 7/binsearch.py | 395 | 3.953125 | 4 | def binSearch(arr, size, target):
low = 0
high = size
while(low+1 < high):
test = (low+high) // 2
if (arr[test] > target):
high = test
else:
low = test
if (arr[low] == target):
print("target found at index "+str(low))
else:
print("target not found")
arr... |
7d01b52b9d8b59a8016479921a1219282ad55d15 | 5l1v3r1/small_decipher_for_arg | /decipher.py | 573 | 3.578125 | 4 | s1 = "Fgzgrb qftc citkt om cal egdofu ykgd. 28 btakl samtk, ct ktetoxtr a loufas miam cal asdglm mit ladt.".lower()
s2 = "Nobody knew where it was coming from. 28 years later, we received a signal that was almost the same.".lower()
def decipher(s):
decoded_message = ""
for c in range(0, len(s)):
... |
0887a6ce4c4a9ef5c05529f1804c367bc95b05d7 | jijessicam/COW-analysis | /scripts/tutorial.py | 360 | 3.78125 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
pd.set_option('max_columns', 50)
# Part 1: series
# Create series with arbitrary list
s = pd.Series([7, 'Heisenberg', 3.14, -12312412512, 'Happy Eating!'])
# can specify index when creating series
print s
# reading in a CSV
from_csv = pd.read_cs... |
f5d59978eb41fa768c32f83a8270359687f00c85 | green-fox-academy/ZaitzeV16 | /python_solutions/week-02/day-2/data_structures/telephone_book.py | 1,155 | 4.53125 | 5 | """
# Telephone book
We are going to represent our contacts in a map where the keys are going to be
strings and the values are going to be strings as well.
- Create a map with the following key-value pairs.
| Name (key) | Phone number (value) |
| :------------------ | :------------------- |
| William ... |
c76f110e5956d21b2f2c0d32ed1667af9a131297 | green-fox-academy/ZaitzeV16 | /python_solutions/week-02/day-1/arrays/print_all.py | 171 | 3.953125 | 4 | # - Create an array variable named `numbers`
# with the following content: `[4, 5, 6, 7]`
# - Print all the elements of `numbers`
numbers = [4, 5, 6, 7]
print(numbers)
|
be8feb35e445c3b3e7034c0ab972fad87038d645 | green-fox-academy/ZaitzeV16 | /python_solutions/week-02/day-2/data_structures/is_in_list.py | 516 | 4.09375 | 4 | # Check if list contains all of the following elements: 4,8,12,16
# Create a function that accepts list_of_numbers as an input
# it should return "True" if it contains all, otherwise "False"
list_of_numbers = [2, 4, 6, 8, 10, 12, 14, 16]
def check_nums(list_of_numbers: list):
numbers_to_check = [4, 8, 12, 16]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.