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
3c8eb76175b1d58f110926c9c813abcfcc0ffc73
arnottrcaiado/curso-python-senac
/aula2/aula2-ex22.py
289
3.90625
4
# aula2 - ex22 - Arnott Ramos Caiado # entrar com numero e identificar se eh par ou impar print("\n Testo se um numero inmteiro e' par ou impar") numero = int ( input("\n Entrar com Numero:")) if numero % 2 == 0 : print( "\n Numero par: ", numero ) else : print( "\n Numero impar: ", numero )
cd7dceac2ecefe90596a3ede22871d2b7c053961
arnottrcaiado/curso-python-senac
/aula1/aula1-ex11.py
413
4.09375
4
# aula 1 - exe 11 - Arnott Ramos Caiado # entrada de tres numeros e alguns calculos num1=int(input("\n Entrar numero 1, inteiro:")) num2=int(input("\n Entrar numero 2, inteiro:")) num3=float(input("\n\n Entrar numero (real):")) print( "\n a) O dobro do primeiro * metade do segunto", ( 2*num1)*(num2/2)) print( "\n b) ...
e6781892c726101d812e59b51acf471ad22106e6
arnottrcaiado/curso-python-senac
/aula2/aula2-ex3.py
275
3.984375
4
# aula2 - ex3 - Arnott Ramos Caiado # verifica se letra é F ou M letra = input("\n Digite F(para feminino) ou M(para masculino):") letra = letra.upper() if letra == 'F' : print("\n Feminino") elif letra == 'M' : print("\n Masculino") else : print("\n Letra Inválida")
f9823974990b5a3f2858c6fe005ddd4d2ddaaccb
Nasty-Flamingo/Lists.py
/lists.py
1,001
3.53125
4
guests = ['guest1', 'guest2', 'guest3'] print(guests,"Hey guys you are the guests i would like to invite to my party \n") print("There is a bit of problem our guest3 is not comming anymore""\n") guests.remove('guest3') print(guests," Now you guys are comming only""\n") print("Hey boys i have found so...
cfd6be31631d3a9e42ca54d6d62c50007e4d8858
Andrewmazyar/python-course-alphabet
/serialization/homework.py
4,907
3.75
4
""" Для попереднього домашнього завдання. Для класу Колекціонер Машина і Гараж написати методи, які створюють інстанс обєкту з (yaml, json, pickle) файлу відповідно Для класів Колекціонер Машина і Гараж написати методи, які зберігають стан обєкту в файли формату yaml, json, pickle відповідно. Для класів Колекціонер М...
6a24dce6ac8bb7c374d23fa73f3ebe306b9a0f1e
afansi/TT-Training
/model.py
3,140
3.9375
4
from tensorflow.keras.layers import Dense, Flatten from tensorflow.keras.layers import Conv2D, MaxPooling2D, Dropout from tensorflow.keras.models import Sequential def create_model( input_shape=(224, 224, 3), conv_list=[(2, 64), (2, 128), (3, 256), (3, 512), (3, 512)], dense_list=[4096, 4096, ...
e2ddb99740e836d268acc3912aaa7cc314987e8f
cnrmurphy/python-lessons
/exercises/session_1/sum_array.py
758
3.96875
4
''' Exercise: Write a function, sum_array, that takes an array as an argument and returns the sum of all integers in the array Considerations: Can you write the function such that it terminates gracefully given an unexepected input such as an input that is not an array or an array that contains elements that are not a...
bf1a776903b0befb342dd7b8a8ea0b26d2b307dd
cnrmurphy/python-lessons
/exercises/session_1/calc.py
2,685
4.21875
4
''' Exercise: Implement a basic calculator that supports add,subtract,multiply,divide Basic requirements: four functions that perform the aforementioned operations will suffice. Extending: Implement a function, calculator, that takes 3 inputs: operation (string), num_a, and num_b. the function, calculator, should...
cb163a174d9a88f39584f08bba3148b83a5cecb9
longnguyen1997/linear-versus-binary-search
/search_runtime_longnguyen.py
5,257
3.71875
4
#!/usr/bin/env python3 # Author: Long Nguyen {lpn@mit.edu}. 2019. import matplotlib.pyplot as plt import numpy from math import floor from random import randint from sys import maxsize from time import time # PRETASK: DEFINE FUNCTIONS. def binary_search(A, n, T): ''' Finds element T in sorted array A of...
86e3be3942ebf8a3876e4e3684bddf758e1d0e78
aditparekh/git
/python/google-python-exercises/babynames/babynames.py
3,163
4.09375
4
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re """Baby Names exercise Define the extract_names() function below and c...
a5c1932418534132648d77c240e64e839244fd70
aditparekh/git
/python/lPTHW/ex3.py
460
4.375
4
print 'I will not count my chickens:' print "Hens", 25+30/6 print "Roosters", 100-25*3%4 print 'Now I will coung the eggs:' print 3+2+1-5+4%2-1/4+6 print 4//3 print "is it true that 3+2<5-7" print 3+2<5-7 print "Waht is 3+2?",3+2 print "Waht is 5-7?",5-7 print "Ph, that's why it's False" print "How abot some mo...
2badc0380cce0cef6f0b76a76d6164e6f6b51d39
aditparekh/git
/python/lPTHW/ex25.py
837
4.28125
4
def break_words(stuff): """This function will break up words for us""" words = stuff.split(" ") return words def sort_words(words): """Sorts the words""" return sorted(words) def print_first_word(words): """Prints the firs word after popping it off""" word=words.pop(0) print word def print_last_words(words):...
83acef64efde2f6372352c4d1decb5d0dfe40974
ctrueden/puzzler
/euler/49.py
579
3.5
4
import math import gmpy2 bound = 987654 p = 1 print('-- Generating primes --') primes = [] while p <= bound: p = gmpy2.next_prime(p) primes.append(p) pset = set(primes) def digits(num): return sorted(str(num)) for i in range(1000, 10000): for j in range(1, 5000): i1 = i i2 = i + j ...
02140073954b603b06389a90fae69447bfacbe65
ctrueden/puzzler
/euler/122.py
612
3.609375
4
import itertools def can_multiply(k, available): print(f'can_multiply({k}, {available})?') if k == 1 or k in available: print('--> base case: True') return True for x in available: if can_multiply(x, available) and can_multiply(k - x, available): print('--> works for ') ...
00a4dde75ee96c483e76d905731ad9f5dffbe42d
maheravi/Assignment-5
/dic.py
2,381
3.65625
4
# init print('loading...') f = open('Trans/translate.txt') big_text = f.read() parts = big_text.split('\n') # print(parts) words = [] i = 0 while i < len(parts): my_dic = {'english': parts[i], 'persian': parts[i + 1]} words.append(my_dic) i += 2 # for i in range(len(words)): # print...
d81277da8b02ac73fa090fc35b2d6704de6395e6
jtula/crls
/binary_search.py
487
3.890625
4
#Exercise 2.3-5 CLRS 3 ed pag. 39 def recursive_binary_search(a, v, low, high): if low > high: return None mid = (low + high) // 2 if v == a[mid]: return mid elif v > a[mid]: return recursive_binary_search(a, v, mid + 1, high) else: return recursive_binary_search(a, v...
433a9ff34492c7fcb12409740cc1d943ae71e584
hainow/DRLHW
/HW1/deeprl_hw1/queue_envs.py
9,986
3.515625
4
# coding: utf-8 """Define the Queue environment from problem 3 here.""" from __future__ import (absolute_import, division, print_function, unicode_literals) import sys import numpy as np from gym import Env, spaces from gym.envs.registration import register from six import StringIO, b from g...
af06b89b7f689c64da539e5a4b67d518e7065298
qnguyen3010/Leetcode-Python
/q1.py
463
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 28 21:20:54 2017 @author: AaronNguyen """ class Solution(object): def twoSum(self,nums,target): dict = {} for i in range(len(nums)): if nums[i] in dict: return [dict[nums[i]],i] else: ...
672a366814df3b813aad582a0ed82926fce694f5
qnguyen3010/Leetcode-Python
/q206.py
863
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Aug 19 15:28:10 2017 @author: AaronNguyen """ # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def reverseList(self, head): """ ...
31bd485cc12b2993725c356a7a31ed7130002011
qnguyen3010/Leetcode-Python
/q230.py
729
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Aug 19 14:21:02 2017 @author: AaronNguyen """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def kth...
bfd401bd034b3c898eb96c9898607885dad0f3dc
MayukhSobo/Conv4RNN
/model.py
14,280
3.5625
4
import tensorflow as tf def _variable_on_device(name, shape, initializer, device='cuda'): """ Declare a variable on CPU of `shape` and initialize those with the `initializer`. """ if device == 'cuda': d = '/gpu:0' else: d = '/cpu:0' with t...
398cdc005fa78c1fd6430231daaab29a53ee6c81
Ko-ch/omikuji
/omikuji.py
606
3.640625
4
def unsei(i): if i == 0: return "大吉" if i == 1: return "中吉" if i == 2: return "小吉" if i == 3: return "吉" if i == 4: return "半吉" if i == 5: return "末吉" if i == 6: return "末小吉" if i == 7: return "凶" if i == 8: retu...
ce74ba25219080de0afd0564671b154e77f981b1
mjjackey/Python_Practice
/map_reduce_practice.py
2,807
4.0625
4
""" map reduce practice for https://www.liaoxuefeng.com/wiki/1016959663602400/1017329367486080 """ from functools import reduce """ 1. 利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字。 输入:['adam', 'LISA', 'barT'],输出:['Adam', 'Lisa', 'Bart']: """ def normalize(name): nor_name="" if (ord(name[0]) >= 97 and ord(name[0]...
8b508b5ff5ff1d3a9c09e590a58fea28568e2938
mjjackey/Python_Practice
/Newcoder/nq2.py
1,606
3.84375
4
""" Find the number of sorted sub-sequence 1st line: the number of numbers, n>=1 and n<=10^5 2st line: the numbers array, a(i)>=1 and a(i)<=10^9 In:6 1 2 3 2 2 1 Out:2 In: 9 1 2 1 2 1 2 1 2 1 Out: 5 """ import sys def fun(values): """ use state shift method :param values: num arrays :return: """ ...
3b458f6bf03e6561ac51fcd90ab0eecb5d70e300
mjjackey/Python_Practice
/Espressif/2020_Soft/es1.py
905
3.578125
4
import math def root(n,num): incre=0.005 i=1 while(i<num): prod=1 for j in range(n): # i multiply n times prod=prod*i if(prod>=num): n_root=i-incre break i+=incre print(n_root) def root2(n,num): n_root=math.exp(1/n * math.log(num))...
0be3a389bbb1d5487279ed304f9c6b70923949be
mjjackey/Python_Practice
/decorator_execute_time.py
831
3.625
4
""" The decorator practice for https://www.liaoxuefeng.com/wiki/1016959663602400/1017451662295584#0 Two layer packages 设计一个decorator,它可作用于任何函数上,并打印该函数的执行时间: """ # -*- coding: utf-8 -*- import time import functools def metric(fn): @functools.wraps(fn) def wrapper(*args, **kw): t1=time.time() fn(...
d481e08f489ea63f2a12e2d5b7997d55be916873
subasishBhatta/DataStructure
/Data Structure Using Python/Sorting Algo/04_quick_sort.py
907
3.953125
4
def print_list(arr, n): for val in range(0, n): print(arr[val], end=" ") print() # Taking high as pivot def partition(arr, low, high): pivot = arr[high] i = low-1 j = low for num in range(low, high): if arr[num] <= pivot: i = i+1 arr[i], arr[num] = arr[n...
9250bec3a8c046030146e1ab508f7c8f1f3c23f9
Chae-Eun/Codewars-Python
/py/iq_test.py
717
3.578125
4
###########################MY SOLUTION############################### def iq_test(numbers): count = 0 num = numbers.split() for i in range(len(num)): count += int(num[i])%2 if count == 1 : #odd for j in range(len(num)): if int(num[j])%2 == 1: return j+1 ...
c6b9943a2b6f73637dd745fc30ba6e50952fbef7
ricardobet12/ComputacionGrafica
/EjemplosPython/ClaseObjecto.py
225
3.71875
4
class Estudiante: #self es para referirse a todos los elementos de la clase def __init__(self,nombre): self.nombre=nombre self.apellido='perez' self.edad=30 e=Estudiante('Ana') print e.nombre
d96410728328d7382eefaae6929001873fefa702
ajaymatters/scripts-lab
/script-lab/python-scripts/PartA7/pa7.py
519
4.15625
4
def AtomicDictionary(): atomic = {"H":"Hydrogen", "He":"Helium", "N":"Nitrogen"}; x = input("Enter symbol ") y = input("Enter element name ") if x in atomic.keys(): print("Key already exists. Value will be updated") else: print("New Key with Value added") atomic[x] = y print(atomic) print("Number of el...
75474e6fce3e801ad8f01498314294fcad082110
mhdella/energy-market-deep-learning
/marketsim/model/energy_market.py
4,848
3.515625
4
class Bid(): """A bid that represents a price-quantity pair in the system.""" def __init__(self, label, price, quantity, band): self.label = label self.price = price self.quantity = quantity self.band = band def copy(self): return Bid(self.label, self.price, s...
916bd6ab26f6a5cc5f4a3d36ed7649b5846088ad
yashrajput0508/Jarivs-2.0
/feature/features/dates.py
622
3.703125
4
import datetime from datetime import date import Speech class dates: def __init__(self): self.dt=datetime self.sp=Speech.speech() def time(self): now = self.dt.datetime.now() current_time = now.strftime("%H hour,%M minute") self.sp.text_to_speech("The current ...
5ea8f88a319fbf16a9eb734d5637f44fde83a241
QKsEnterprise/Prueba-con-python
/cart.py
648
3.53125
4
# lista de compras person = [ "Name: Jonh", "LastName: Parkker", "Number: 11-4758-8092", "DNI: 31.583455", ] print(person) cart = [ "bananas", "apple", "kiwwi", "oranjes" ] # print(cart) total = [ "bananas price:300$ quantity:18", "Apple price:100$ quantity:6", "Kiwwi ...
48e6e7b141472158600e323a2f9b61a216b46940
devashishnyati/Binary-Search-2
/findPeakElement.py
1,287
3.671875
4
# Time Complexity : O(log(n)) # Space Complexity : O(1) # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : Not able to think the logic class Solution(object): def findPeakElement(self, nums): left ,right = 0, len(nums) - 1 while left <= right: ...
90ad3a88d7633704f04f92fd59a38d0d5493de70
minji-mia/data-engineering
/02 Streamlined Data Ingestion with pandas/ch3.py
5,286
3.75
4
# Import sqlalchemy's create_engine() function from sqlalchemy import create_engine # Create the database engine engine = create_engine("sqlite:///data.db") # View the tables in the database print(engine.table_names()) # Load libraries import pandas as pd from sqlalchemy import create_engine # Create the database e...
a26c52f94433b06a7d277eeb022f2dcfd4e4376a
VinceLing0529/CodingDojo_Python
/fundamentals/fundamentals/algo_day2.py
368
3.8125
4
def change(str1): str1 = str1.strip().split() expected1 ="" for i in str1: expected1 += i[0].upper() print(expected1) str1 = " there's no free lunch - gotta pay yer way. "; str2 = "Live from New York, it's Saturday Night!"; change(str1) change(str2) x = "abcdefg" rev = "" for i in range(...
afce03f3f829127316e50f004b663e44fd6bd695
a-paxton/oss-community-health
/scripts/survivor_analysis/utils/project_features.py
762
3.515625
4
import numpy as np def compute_bus_factor(commits, n_committers=5): """ Compute bus factor Parameters ---------- commits : pd.DataFrame Data Frame containing the commit information. n_committers : int, optional, default: 5 Number of committers to consider in the bus factor ...
e39aee36dedb8ed0e6d97ab5a2e83c0b39d2c51d
peter-thach/sudoku
/sudoku.py
6,614
3.875
4
import random class Board(): def __init__(self, board): self.numSolutions = 0 self.solution = [] if not board: self.board = self.generateBoard() else: self.board = board self.solver(board) def generateBoard(self): # Initialize the bo...
45a3e6550a3da260f03d518ebbce7a5f4300c382
voodoopeople42/Vproject
/Janus/python-base-unit_05/files/os.exists.test.py
418
3.65625
4
# -*- coding: utf-8 -*- # os.exists.test.py import os cwd = os.getcwd() print(cwd) # В метод os.path.exists(path) передается путь, который необходимо проверить filename = input("Введите путь к файлу: ") if os.path.exists(filename): print("Указанный файл существует") else: print("Файл не существует")
85522c222a63b8236b0af9e93404e384e89acb3a
voodoopeople42/Vproject
/phonebook1.py
2,400
4.03125
4
contacts = ( {"Имя": "Игорь", "Номер": "094-456-72-89"}, {"Имя": "Виктор", "Номер": "092-664-52-88"}, {"Имя": "Сергей", "Номер": "089-435-23-23"}, ) FORMAT_STR = '{:<15} {:>12}' def list(contacts): print(FORMAT_STR.format("Имя", "Номер")) for contact in contacts: print(FORMAT_STR.format( contact ("Имя"), ...
eeef454dbb42b30cc1c25f99d59a4a5ca9719aae
voodoopeople42/Vproject
/Janus/python-base-unit_11/oop/oop.constructor.test.py
896
4.1875
4
# oop.constructor.test.py # class Person: # def __init__(self, first_name, last_name): # self.first_name = first_name # self.last_name = last_name # конструктор класса не позволит создать объект без обязательных полей: # sam = Person("Sam", "Brown") # print(sam.first_name, sam.last_name) # class...
917c052b66306654e64eb617bc1b48163094fea5
voodoopeople42/Vproject
/Janus/conts/contact18.py
2,543
3.6875
4
# -*- coding: utf-8 -*- # contact18.py ''' Program make a simple phonegup that can add, view, modify, delete and save the records ''' import pickle FILENAME = "contacts.dat" # Importing libraries from datetime import datetime, timedelta def current_date(): # Current datetime now = datetime.now() # F...
9d90c01f8057a07dcf554814704ca1b002c1eec9
voodoopeople42/Vproject
/phonebook.py
2,646
4.03125
4
contacts = [ {"Имя": "Игорь", "Номер": "025-338-46-88"}, {"Имя": "Сергей", "Номер": "035-556-47-23"}, {"Имя": "Констан", "Номер": "034-555-23-95"}, ] FORMAT_STR = '{:<15} {:>12}' def list(contacts): print(FORMAT_STR.format('Имя', 'Номер')) for contact in contacts: print(FORMAT_STR.forma...
dffb80f81d78418c00eabb5f122519a0fe4a4fd7
voodoopeople42/Vproject
/Janus/python-base-unit_05/board.py
244
3.71875
4
# board = [['_', '_', '_'], ['_', '_', '_'], ['_', '_', '_']] tmp = " _____" for i in range(len(board[0])): tmp += "\n|" for j in range(len(board[0])): tmp += board[i][j] + "|" tmp += "\n -----" print(tmp)
e8ce4c9b667118b96173af7ec505ffaaf33b3477
voodoopeople42/Vproject
/1/time.py
102
3.59375
4
n = int(input("Input number:" )) hours = n % (60 * 24) // 60 minutes = n % 60 print(hours, minutes)
d9b66b67f03320c1ffa789b59c7b5994298319d0
voodoopeople42/Vproject
/Janus/python-base-unit_09/gui/calc03.py
4,913
3.734375
4
from tkinter import * # минимальное приложение на Tkinter: root = Tk() # За создание окна отвечает класс Tk(), и первым делом нужно создать экземпляр этого класса. Этот экземпляр принято называть root, хотя вы можете назвать его как угодно. # title - заголовок окна root.title("Simple calculator") # geometry - устана...
b50ba165cf49400e8cf6f37db8e7e909147810ac
voodoopeople42/Vproject
/Janus/python-base-unit_02/type01.py
5,083
4.3125
4
#! /usr/bin/env python # coding: utf var = "string1" print(var) # Выведет "string1" var = 1 print(var) # Выведет "1" var += 2 print(var) # Выведет "3" # число π PI = 3.14 print(PI) # => 3.14 # случайное изменение значения PI='MAIN' print(PI) type(object) # <class 'type'> type(type) # <class 'type'> type(int) # ...
568bbf77c5d685e8b0dba1267bb296ecaabd694d
almabeganovic/WS2016
/AnnaMajewski/aufgabe3a.py
525
3.984375
4
from random import randint ergebnis = randint(1,10) print ("Sie haben 3 Versuche eine Zahl zu erraten!") for i in range(3): raten = input("Geben Sie eine Zahl zwischen 1 und 10 ein") raten = int(raten) if raten == ergebnis: print ("Richtig! Die Zahl war", raten) break elif raten < erge...
eb0545f8c75bb8a048fc52a6f5b3a89bc8159f12
almabeganovic/WS2016
/23reever/Aufgabe_3b.py
297
3.859375
4
# User nach Input fragen string = input("Geben Sie einen Text ein: ") # Länge Substring ss = 3 # Mögliche Anzahl von Sequenzen: Stringlänge - Substring + 1 for i in range(0, len(string) - ss + 1): # " " * i - create a nice indent for each line print(" " * i, string[i:i + ss], sep="")
45c036e33d642d8ada09272dec7152a87dea512b
Sridhar-S-G/Python_programs
/Extract_numbers_from_String.py
370
4.125
4
''' Problem Statement A string will be given as input, the program must extract the numbers from the string and display as output Example 1: Input: Tony Stark's daughter says 143 3000 Output: 143 3000 Example 2: Input: There4 I think you will be satis5ed with this tutorial Output: 4 5 ''' #Solution Code import re s=...
f66af7aa3525661a8b531cef7d30fd5d9d1f951f
Sridhar-S-G/Python_programs
/CountOfSpecialCharacters.py
640
4.09375
4
''' Count of Special Characters The program must accept a string S as the input. The program must print the count of special characters in the string S as the output. Note: Special character is a character which is not an alphabet or not a digit. Boundary Condition(s): 1 <= Length of S <= 100 Input Format: The first l...
f4744c21a57354c5563664cd5a29bff27f616df2
Sridhar-S-G/Python_programs
/Print Consonants Circularly.py
1,324
3.75
4
''' The program must accept an alphabet CH as the input. The program must print all the consonants from CH circularly as the output. Note: CH is always in lowercase. Boundary Condition(s): 'a' <= CH <= 'z' Input Format: The first line contains CH. Output Format: The first line contains all the consonants in lowercase f...
3c4f4279850d8e2f0bb240fa3c2703b54f2796bc
simiss98/PythonCourse
/UNIT_1/Module1.2/MOD01_1-2.2_Intro_Python.py
1,583
4.21875
4
#creating name variable name = "Petras" # string addition print("Hello " + name + "!") # comma separation formatting print("Hello to",name,"who is from Vilnius.") print("Hello to","Petras","who is from Vilnius.") # [ ] use a print() function with comma separation to combine 2 numbers and 2 strings print("I was born at...
859f67c8cfa6ecaf311a0f7215ddc8542c449d2e
simiss98/PythonCourse
/UNIT_1/Module2/Required_Code_MOD2_IntroPy.py
270
3.734375
4
# [ ] create, call and test fishstore() function def fishstore(fish=input("Entery Fish type on a keyboard ").capitalize(),price=input("Enter fish price on a keyboard ")): fish_and_price="Fish Type: "+fish+" costs $"+price return fish_and_price print(fishstore())
9e4156f225546d0808d225b5078af06a872acff6
simiss98/PythonCourse
/UNIT_1/Module4.1/MOD04_1-6.1_Intro_Python.py
1,981
4.15625
4
#Task1 # [ ] Say "Hello" with nested if # [ ] Challenge: handle input other than y/n print("Please Say Hello") hello_decision=input('"y" for yes or "n" for no: ' ) print() #1st nested if if hello_decision.lower()=="y": #select hello type print("Please select hello type.") hello_type = input('"hello" for full ...
6c19170153ee9669fbafe02192606989d031e7a5
simiss98/PythonCourse
/UNIT_1/Module1.1/MOD01_1-1.4.py
2,115
4.375
4
Task1 #creating x,y and z integer variables and then adding then calculating sum of 3 integers. x=1 y=2 z=3 x+y+z # displaying sum of float and integer. 65.7+4 #creating string name variable and then using print just for fun to display both strings. name="Evaldas" print("This notebook belongs to "+name) #creating sm_nu...
4463b4b6db183a66f823f48e8e1398194af00980
avinashingit/epi
/arrays/advancingarray5.4.py
711
3.859375
4
# @Author: Avinash Kadimisetty <avinashingit> # @Date: 2019-01-06T14:08:24-06:00 # @Email: kavinash366@gmail.com # @Project: Elements of Programming Interviews # @Filename: advancingarray5.4.py # @Last modified by: avinashingit # @Last modified time: 2019-01-07T13:48:35-06:00 # @License: MIT License ''' Q: Write ...
dc65d35c0037b19ec920fff8e65eb8a472da762a
avinashingit/epi
/arrays/incrementarray5.2.py
851
3.859375
4
# @Author: Avinash Kadimisetty <avinashingit> # @Date: 2019-01-05T16:09:25-06:00 # @Email: kavinash366@gmail.com # @Project: Elements of Programming Interviews # @Filename: incrementarray5.2.py # @Last modified by: avinashingit # @Last modified time: 2019-01-05T16:20:52-06:00 # @License: MIT License ''' Write a p...
21c3319054dbf33498ba9504e15f779fecea7df2
ibrahim85/Neural-network-code-for-solving-ordinary-differential-equations
/eq/lagaris_01.py
1,409
3.984375
4
""" Problem 1 in Lagaris et al (1st order ODE IVP) The equation is defined on the domain [0,1], with initial conditions defined at x=0. The analytical form of the equation is: G(x,y,dy/dx) = dy/dx + (x + (1 + 3*x**2)/(1 + x + x**3))*y - x**3 - 2*x - x**2*(1 + 3*x**2)/(1 + x + x**3) = 0 """ fr...
a2b1d4fb602cd8f2c28271ed4980e3981414ebde
siva600/DATA-STRUCTURES--V.2
/Alpha/test.py
65
3.84375
4
d = {'a':2, 'b':3} for item in list(d.keys()): print(item)
a1618dec195ef6a8de2955ade2c28bbb94dae461
AmrKhalifa/Modeling-rainfall-data-in-Bangladesh
/feature_extractor.py
2,730
3.78125
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans def read_data(): """ this funcitons reads the dataset file and returns a Pandas data frame the contains the data Args: NONE Returns: Pandas dataframe: dataframe the contains the d...
43be696e8ef1b86c1bc3d3bbfca00dfc07893589
ErickSaulQuezadaAlmazan/Computational-Geometry-Practica_2
/Práctica 02.py
2,997
3.953125
4
''' INTSITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO ESCOM COMPUTATIONAL GEOMETRY ALUMNO: QUEZADA ALMAZÁN ERICK SAÚL PRÁCTICA 02: 19-03-21 FECHA DE ENTREGA: 26-03-21 ''' print("B I E N V E N I D O\n") # Inciso A) Describe el conjunto de puntos. print("Considerando S en E^2 un conjunto finito...
122c613fd12ec41351a9899cb35c20ec5926c9a6
satrijotomo/Python_codes
/checkBookPrice.py
578
3.6875
4
#! /usr/bin/env python3 ### this file was created on Mac system import bs4,requests def getBNBookPrice(ProductUrl): res = requests.get(ProductUrl) mySoup = bs4.BeautifulSoup(res.text, "html.parser") title = mySoup.select('#prodSummary > h1') elems = mySoup.select('#prodInfoContainer > form.pdp-form > ...
3d7fc81384219e71c1580dec167e0da9805d1daf
ariabee/pygame-tutorial
/pygame-tutorial-part1.py
4,584
3.984375
4
# Pygame Tutorial Assignment # Tutorial url: https://coderslegacy.com/python/python-pygame-tutorial/ # LAP WS 2020-2021, Week 3 # Group: AriaRay Brown, Ben Posner, Susann Boy import pygame, sys from pygame.locals import * import random # Initialize program pygame.init() """ # Create color objects BLACK = pygame.Colo...
a242041cc80b354c9d73e3018c8236fb9ecc8e95
tanvi1706/practiceLeetCode
/306.py
694
3.59375
4
class Solution: def AdditiveNumber(self,num: str) -> bool: def backtrack(self, num1: str, num2: str, rem: str) -> bool: if not rem: return True target = str(int(num1) + int(num2)) if rem.startswith(target) and all(str(int(x)) == x for x in (num1, num2)): ...
5d22d099a117896b83c84babf34a3916a06504fc
Futi7/AnagramChecker
/main.py
1,949
4.1875
4
class AnagramChecker: list_of_strings = [] first_string_keys = {} second_string_keys = {} list_of_keys = [first_string_keys, second_string_keys] def __init__(self, first_string, second_string): self.list_of_strings.append(first_string) self.list_of_strings.append(second_string) ...
fd0702b65d53a7f76aa5b36e1ff09a34df15984f
marcus-deans/duke-computationalmethods
/Lab5-Root-Finding-Word-Scambling/debug_comps.py
710
3.953125
4
""" @author: DukeEgr93 """ import math as m import numpy as np def power_list(list_in): return [k**2 for k in list_in] def cos_list(list_in): return [m.cos(k) for k in list_in] def evens_only(list_in): return [k for k in list_in if k % 2 == 0] def first_three_squares_only(list_in): return [k fo...
5210a1e70043e493410822caa4ed2d566419f527
marcus-deans/duke-computationalmethods
/Lab5-Root-Finding-Word-Scambling/lab5notes.py
302
4.09375
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 24 11:52:06 2019 @author: marcu """ def upshift(word): new_list = [] for letter in word: new_list += [chr(ord(letter)+1)] new_word = ' '.join(new_list) return new_word print(upshift('Hello'))
7dd562bcf2f3a946f91f72b4ed98e9b94699e32e
marcus-deans/duke-computationalmethods
/Lab3-Random-Number-Functions/tri_calc.py
1,029
3.5625
4
# -*- coding: utf-8 -*- """ [Triangle Calculator] [Marcus Deans] [12 September 2019] I understand and have adhered to all the tenets of the Duke Community Standard in creating this code. Signed: [md374] """ # %% Import modules import math as m import matplotlib.pyplot as plt # %% Define function def triangles(a, b...
e78f160183d2f50dbb0152d808dba8e17c0f47ab
bbjunaid/ProgrammingChallenges
/Project Euler/Problem 17/euler.py
1,092
3.875
4
import sys numbers = { 0 : '', 1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five', 6 : 'six', 7 : 'seven', 8 : 'eight', 9 : 'nine', 10 : 'ten', 11 : 'eleven', 12 : 'twelve', 13 : 'thirteen', 14 : 'fourteen', 15 : 'fifteen', 16 : 'sixteen', 17 : 'seventeen', 18 : 'eighteen', ...
2bff03f27aa9dc9805d6af86c6ca315437c86138
thuandt/project_euler_solutions
/022/project_euler_022.py
2,090
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Filename: project_euler_022.py # # Description: Project Euler, Problem 022 # # Created: Sun 12 Jun 2011 04:17:53 AM ICT # Last Modified: Sun 12 Jun 2011 05:20:15 AM ICT # # Author: Thuan.D.T (MrTux) # Company: Water Resources University (...
6b69f5c58e234e03dfe1cb093761a1115ee4e47c
chihsuanbjjh/binder
/師大計算機課程/Python Turtle/心臟線-順向(一個圖)-1.py
2,520
3.546875
4
from turtle import * import math hideturtle() speed(0) # tracer(50,2) screen = Screen() screen.colormode(255) screen.setup(1200,800) #產生圓的點,畫點 def gen_circle_point(step, radius, x_start=0): theta = 0 circle_list = [] step_angle = 2*math.pi/step for i in range(step): circle_list.append( ...
5b126831e4954a486a012e5b58413b33ad8a2ecf
xValentim/Revisao_Inflames_12_06
/real.py
286
3.53125
4
# Problema da OBI primeira fase N, M = [int(i) for i in input("").split()] pais = [int(j) for j in input("").split()] compareceram = [int(k) for k in input("").split()] geracoes = [[0]] geracao_atual = geracoes[0] for i in range(len(pais)): descendente = i + 1 pai = pais[i]
5554e8f5e697927a2187061b4071611a73d84346
xValentim/Revisao_Inflames_12_06
/gabarito/q8_loops.py
410
3.78125
4
''' Quantos uns? Escreva uma função que recebe um número e devolve a quantidade de vezes que o algarismo 1 ocorre nesse número. Ex: 1030110641 tem 4 ocorrências do algarismo 1. O nome da sua função deve ser quantos_uns ''' def quantos_uns(n): qtde = 0 while n != 0: ultimo_algarismo = n % 10 i...
86cc05429f561bace257eb77b76b34c0edcd6e50
KevinNgWK/Snake-Game
/Snakes.py
8,833
4.25
4
""" Snake Game Size of each square is 15x15 Keep array representation of snake """ #Import necessary packages import pygame import random def draw_square(win, sq_size, coord, color="black"): """ Function to draw squares parameters: win: display window sq_size: size of square to be drawn (i...
3bc0b246e4e1e6326d9d9affd18eebb7f975252b
kjanagiram/PythonBootCamp
/Methods/Methods.py
6,741
4.6875
5
print("Methods and Functions") ''' By using def keyword, we can declare a function in python. Below are the syntax of different functions syntax #1 Basic function def function_name(): statement #2 Function with return value def function_name(): return value #3 Function with arguments and return value ...
23921c4db3efb82c22a615633f850bebfb32a8ba
Papenkov/codes
/Алгоритмы/Сортировка слиянием (задача на число инверсий).py
1,507
3.671875
4
''' Задача на число инверсий. Первая строка содержит число 1 ≤ n ≤ 10^5, вторая — массив A[1…n], содержащий натуральные числа, не превосходящие 10^9. Необходимо посчитать число пар индексов 1 ≤ i < j ≤ n, для которых A[i] > A[j]. (Такая пара элементов называется инверсией массива. Количество инверсий в массиве являетс...
3bb5d044aca49c612d2c6ad007170cffa798f7f4
ZhouQiRong/jira-spider
/DateUtil.py
1,193
3.9375
4
import calendar import datetime class DateUtil : def __init__(self): print("DateUtil init...") def getMonthFirstDayAndLastDay(self,year=None, month=None): """ :param year: 年份,默认是本年,可传int或str类型 :param month: 月份,默认是本月,可传int或str类型 :return: firstDay: 当月的第一天,datetime.date类...
834c5cd8f1807af2aca3a364e9c65134886b394e
rkzhang/python-learing
/pyton_learning/base/thread_sample.py
860
3.859375
4
#-*-coding:UTF-8-*- ''' Created on 2014年12月9日 @author: rkzhang ''' import threading import time from threading import Timer, Lock t = 0 lock = Lock() def printCount() : lock.acquire() global t print t t = t + 1 lock.release() class ClockThread(threading.Thread) : def __init__(self, interval)...
e850100adf43b44f77622fac656663f613393707
Maaxxs/gtk3_examples
/with_glade/2add2Numbers.py
939
3.984375
4
""" Simple program to add two numbers. Enter two numbers and press the '=' Button. If you entered numbers, then the text of the result label will be changed to the result. Otherwise you are asked to enter something valid. """ import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk class Handler: ...
aa4ecbf36466d4cd0cc3d575b4c9bc2931a73a38
mselig/game-of-life-python
/gol/test/test_cell.py
2,066
3.71875
4
# -*- coding: utf-8 -*- from gol.base import Cell class TestCell(object): def test_initialisation(self): cell = Cell() assert type(cell.is_alive) == bool assert type(cell.neighbours) == int assert cell.neighbours == 0 cell = Cell(1) assert cell.is_alive ...
56b31f6ab5ce4b1c2a34f99b3114528d5ba31cae
jpl126/dynamic-programing
/dynamic_programming/examples/frozen_lake_iterative_policy_evaluation.py
1,545
3.71875
4
""" Simple script showing iterative policy evaluation based on policy going always right. """ from typing import Callable from environments.frozen_lake.custom_frozen_lake import FrozenLakeEnv, RIGHT from utils.DP_agents import DiscreteAgent from utils.environment import Environment def right_policy(state: int) -> in...
bfa5019a28ca14b2d0cfa0defa98d25b59b491a1
akschenker/python-challenge
/PyBank/main.py
1,691
3.78125
4
import os import csv """ The total number of months included in the dataset The total net amount of "Profit/Losses" over the entire period The average change in "Profit/Losses" between months over the entire period The greatest increase in profits (date and amount) over the entire period The greatest decrease in losse...
06849de30d0760119ce5ec296b20435b4e745233
SoumendraM/DataStructureInPython
/CHAP3-LINKLIST/CircleLinkList.py
8,199
4
4
## Circular Link List implementation ## Circular List Node implementation class Node: def __init__(self): self.data = None self.next = None def getData(self): return self.data def setData(self, data): self.data = data def getNext(self): return self.next ...
6158f105bf37c0c2b1ceb4729307c23cef48abb7
2470370075/suanfa
/算法/插入排序.py
1,521
3.859375
4
# 插入:后面部分里的第一个,插入到前面部分合适的位置 # 插入排序: 把后面部分里的第一个,插入到前面部分合适的位置, # 首次的前面部分只包含列表里的第一个,剩余的为后面部分,把后面部分的第一个与前面部分的第一个比较,插入到指定位置 # 第二次前面部分为列表的前两个,剩余为后面部分,把后面部分的第一个和前两个比较,插入到指定位置 # 具体是怎么比较的呢:用后面部分的第一个与前面部分的最后一个比大小,如果小,交换位置,继续往前比,如果大,结束。 # 依次类推, # 实现排序 """ - * * * * * - ...
f5252a1380ed86f65900882301debeab234daa94
praveenv253/monte-carlo
/integration/integrate.py
1,662
3.90625
4
#!/usr/bin/env python from scipy import * from function import function, domain # We do a monte-carlo integration with 1,000,000 points numpoints = 1000000 # Create 'numpoints' number of random points in [0, 1)x[0, 1) x = random.random(numpoints) y = random.random(numpoints) # Scale x to fit the domain x = x * (dom...
7eda09ec03db88f72b992e21616b9f90c5ce3772
ed-villani/EngSoftEx9
/ex3.py
1,172
3.65625
4
class Book: def __init__(self, titulo, isbn, preco): self.__titulo = titulo self.__isbn = isbn self.__preco = preco # get def getTitulo(self): return self.__titulo def getISBN(self): return self.__isbn def getPreco(self): return self.__preco # ...
5b4ce618a9260ca6378d2443ca40f4fbc5fd3fa9
charanchakravarthula/python_practice
/slicing.py
255
4.0625
4
# list slicing list_var=[1,2,3,4,5] # index slicing without step print(list_var[0:4]) #index slicing with step print(list_var[0:4:2]) #string slicing str_var="abcdefgh" print(str_var[2:6:2]) # tuple slicing tup_var=(1,2,3,4,5) print(tup_var[0:3])
9498fe8866498ef6be30b8d8967dad971f09d801
charanchakravarthula/python_practice
/Baics.py
499
4.3125
4
# variable assignment var = 1 print(var) # multiple values assignment to a variable var1,var2 =(1,2) print(var1,var2) #ignoring unwanted values var1,__,__=[1,2,3] print(var1) var1=var2=var3=1 print(var1,var2,var3) # knowing the type of the varible i.e data type of variable var1=[1,2,3] var2=('a',"b","c") var3=1...
17ff01f04c24cdfda0ad6acc1d5b51345b1567ae
ahasan09/python_fundamental
/string.py
413
4.0625
4
# Formatted String first = "Raju" last = "Hasan" full = first+" "+last print(full) full = f"{first} {last}" print(full) # String Method course = " Python Programming " print(course.upper()) print(course.lower()) print(course.title()) print(course.strip()) print(course.rstrip()) print(course.lstrip()) print(course.find(...
2d3d23c1db15da1c4bb2102066566cd9b61d9ed5
param-132/Zoom-ClassWork
/CreditCard.py
1,238
3.875
4
#Assignment: class CreditCard: def __init__(self,customer,bank, card_number,balance): self.customer_name = customer self.bank_name = bank self.balance = balance self.credit_card_number = card_number def get_customer(self): return self.customer_name def get_ba...
347ce2e7e04c6641b4cf4c9fbe6473748d14ffcc
batistazc/PythonNote
/5th.py
2,941
3.734375
4
#-*-coding:utf8-*- #第五章 条件、循环和其他语句 # # 使用逗号输出,逗号当连接符用 # print("age:", 42) # # 文本和变量同时输出,又不希望格式化字符串时可以使用此方法 # name = "zhangchi" # salutation = "Mr." # greeting = "Hello" # print(greeting, salutation, name) # # 在结尾加上逗号,会和下一个print输出到同一行(只在脚本中起作用) # print("Hello,"), # print("World!") # # 把某件事作为另一件事导入,方法 # import somemo...
9b0a8baea9d1033e94f50d5ca64a217c202219bd
bang103/MY-PYTHON-PROGRAMS
/WWW.CSE.MSU.EDU/CONTROL/AncientEgypt.py
2,169
4
4
#http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/ #Ancient Egyptian Multiplication ##Crazy computer says -3//2 is -2, big problem if second operand is negative, because oper2 is being checked all the time #also if second operand has minus sign,then difficult to compute sign of product #so did whole E...
2d980fc7d8412720a20194b5de8fd43f3057323e
bang103/MY-PYTHON-PROGRAMS
/BIBLIO/Hangman.py
5,937
4.0625
4
#Hangman #July 30, 2015 #Description of rules after the program #TheWord-Word to Guess #Hangman-List containing hangman parts #InputWord - Word being formed #InputChar- character being input everytime #HMan.txt - file containing words for the hangman game ####the following import disables print statement and ...
50bd2eb187d1affea1bb607b0de9aff1e6e37646
bang103/MY-PYTHON-PROGRAMS
/WWW.CSE.MSU.EDU/STRINGS/PalindromeNum.py
2,271
3.90625
4
#http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/ #September 9, 2015 # from __future__ import print_function #take in lower limit #take in upper limit #internally keep 3 counters; palindrome, non-lycheral, lycheral #from lowerlimit to upper limit #1.check if number is palindrome, if yes, inc...
3dc3eb11e65a0740585d62155e5b4dec9682604d
bang103/MY-PYTHON-PROGRAMS
/WWW.CSE.MSU.EDU/SIMPLE PROGRAMS/slayer.py
783
3.890625
4
#August 18 2015 #inputs A number of the form SLAYER #Checks whether SLAYER+SLAYER+SLAYER=layers #Only integer operations can be used from __future__ import print_function def make_layers(inp): s=inp/100000 layer=inp%100000 layers=layer*10 + s return(layers) print("Guess a...
e3e76c37ff817bae9836c142f0a7113ede554505
bang103/MY-PYTHON-PROGRAMS
/PYTHONINFORMATICS/DictDayOfWeek.py
871
4.25
4
#Exercise 9.2 in Python for INformatics #Exercise 9.2 Write a program that categorizes each mail message by which day of #the week the commit was done. To do this look for lines which start with *From*, #then look for the third word and then keep a running count of each of the days #of the week. At the end of the p...
adc3327fe24e67694446fd98f023306cafd012d2
bang103/MY-PYTHON-PROGRAMS
/WWW.CSE.MSU.EDU/STRINGS/Cipher.py
2,729
4.25
4
#http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/ #implements encoding as well as decoding using a rotation cipher #prompts user for e: encoding d: decoding or q: Qui import sys alphabet="abcdefghijklmnopqrstuvwxyz" print "Encoding and Decoding strings using Rotation Cipher" while True: o...
b92f31c4ec5ac049b5195d1c3322f9726f77441f
berg2043/Acronym-Spike
/populate db/populate.py
509
3.609375
4
def load_words(): with open('./../../words_alpha.txt') as word_file: valid_words = set(word_file.read().split()) return valid_words if __name__ == '__main__': english_words = load_words() # demo print string = 'INSERT INTO "words"(word)\nVALUES' str_end = ';' count = 0 for wor...
c6fd62a3919dfa4893310e5ff825850fd77fedb4
Ankit-Kumar08/Soduku_Solver-
/Eliminate.py
744
3.734375
4
from Grid_Value import * def eliminate(values): """Eliminate values from peers of each box with a single value. Go through all the boxes, and whenever there is a box with a single value, eliminate this value from the set of values of all its peers. Args: values: Sudoku in dictionar...