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 |
|---|---|---|---|---|---|---|
2de9437f4bb2df0f0928ac1928e62efb8e1eaafa | Nihilnia/reset | /Day 16 - Simple Game_Number Guessing.py | 1,782 | 4.21875 | 4 | # Simple Game - Number Guessing
from time import sleep
from random import randint
rights = 5
number = randint(1, 20)
hintForUser = list()
userChoices = list()
for f in range(number - 3, number + 3):
hintForUser.append(f)
print("Welcome to BASIC Number Guessing Game!")
while rights != 0:
pr... |
622934e84d6a56e6a1b627272ff1b4eaf1b62e12 | Nihilnia/reset | /Day 14 - Parameters at Functions.py | 685 | 4.21875 | 4 | # Parameters at Functions
# if we wanna give any parameters to a Function
#we should insert a value while using.
def EvilBoy(a, b):
print("Function 'EvilBoy' Worked!")
return a + b
print(EvilBoy(2, 3))
# that was a classic function as we know.
# But we can make it some default parameters.
def... |
a3fb7c57a210cd5965871f0812e8de56749fb21c | Nihilnia/reset | /Day 19 - vars function.py | 462 | 3.75 | 4 | class planets():
def __init__(self, name = "unknown", diameter = 0, day = 0):
self.name = name
self.diameter = diameter
self.day = day
mercury = planets(name = "Mercury", diameter = 3.31, day = 58.6)
venus = planets(name = "Venus", diameter = 7.521, day = 241)
jupiter = planets(na... |
2284165470e9352f1b5f4ee6082020b808ae9b73 | fxw97/NCRE2python | /第10套/综合应用题/10-46.demo.py | 787 | 3.5625 | 4 | import random
var='a'
lst=[chr(ord(var)+i) for i in range(26)]
letter = lst[random.randint(0,25)]
count = 0
while True:
letter_input = input('请输入26个字母中的任一个:')
count += 1
if letter_input not in lst:
print('请重新输入字母')
else:
if count > 100:
print('猜测超过5次,答题失败')
break
... |
b93cc2ab46c823daff8112aafa5925dda1c6cc90 | fxw97/NCRE2python | /第8套/简单应用题/8-45.demo.py | 474 | 3.625 | 4 | import math
try:
a = eval(input('请输入底数:'))
b = eval(input('请输入真数:'))
c = math.log(b,a)
except ValueError:
if a<=0 and b>0:
print('底数不能小于等于0')
if a>=0 and b<0:
print('真数不能小于等于0')
elif a <= 0 and b<=0:
print('真数和底数都不能小于等于0')
except ZeroDivisionError:
print('底数不能为1')
exc... |
4efe412f71763ad506ab65585674d97b92d1ea2a | fxw97/NCRE2python | /第5套/基本操作题/5-42.demo.py | 146 | 3.5 | 4 | # 将输入的10进制数转换为2进制
s = input('请输入一个10进制的数:')
num = eval(s)
print('转换为二进制是{:b}'.format(num)) |
6ddc3823c97d567c8f2d009013a0409404a92fb6 | manuferro/pylib | /class_test.py | 371 | 3.75 | 4 | #!/usr/bin/python
class TestClass:
v = 10
def __init__(self):
self.v = 11
def mt(self):
print "metodo"
self.v=12
def retval(self, value):
return value + 1
if __name__ == '__main__':
print "class test"
obj = TestClass()
print obj.v
obj.mt()
p... |
73de5e19d4e7ca7719e1a6caab1daf94969a3795 | ashleynkomo/revision | /linear search.py | 463 | 3.984375 | 4 | #Linear Search
def Linear_search(List, search):
found = False
counter = 0
while not found and counter <len(List):
if List[counter] == search:
found = True
else:
counter += 1
return found
#main program
List = ["john", "James", "billy", "Ashley"]
... |
b022fd670ee06d5bb7259bc072389f83da5a4807 | ashleynkomo/revision | /stretch.py | 170 | 3.890625 | 4 | #Ashley Nkomo
#09/12/14
#Strect and Challenge
def conversion_choice():
choice = input(" Would you like to convert metres to centimetres(1) or feet to inches(2): ")
|
b2c47a7fbce132076fccb7ce47172444b9ffef63 | thiago-franco/uri | /1153.py | 122 | 3.609375 | 4 | def fatorial(x):
if x == 0:
return 1
return x * fatorial(x-1)
n = int(input())
print(fatorial(n))
|
24877e1c1210402daa68fab852c4b43be83f0e48 | thiago-franco/uri | /1065.py | 124 | 3.65625 | 4 | pares = 0
for i in range(5):
n = int(input())
if n % 2 == 0:
pares += 1
print(pares, 'valores pares')
|
1ef4ae4da767c2add71e4e2444f15a98bbf2f133 | thiago-franco/uri | /1048.py | 361 | 3.609375 | 4 | x = float(input())
p = 0
if x > 0 and x <= 400:
p = 0.15
elif x >= 400.01 and x <= 800:
p = 0.12
elif x >= 800.01 and x <= 1200:
p = 0.10
elif x >= 1200.01 and x <= 2000:
p = 0.07
elif x > 2000:
p = 0.04
print("Novo salario: %.2f" % (x+x*p))
print("Reajuste ganho: %.2f" % (x*p))
... |
ba2dbb8ee9db77a12b6cb61f27f857fcdbcdb9eb | thiago-franco/uri | /1151.py | 187 | 3.765625 | 4 | n = int(input())
f = [0,1]
s = "0 1"
for i in range(2, n): # Os 2 primeiros termos já estão calculados
nf = f[i-1] + f[i-2]
f.append(nf)
s += ' ' + str(nf)
print(s)
|
ebe584c7bed7f25811f0d29d2ff2843b8e21ae91 | evertheylen/logicpy | /logicpy/debug.py | 1,269 | 3.609375 | 4 |
class NoDebugger:
def prove(self, w, r):
pass
def output(self, text):
pass
def proven(self, w, r):
pass
def next(self):
return self
def from_next(self):
return self
def __bool__(self):
return False
def truncate(s, length... |
93de2cc7daa588084de95a3a09449244bdffff1a | xyuan/HybMesh | /doc/code_preproc.py | 790 | 3.53125 | 4 | """
Script is used to process the source file
before pasting it into documentation.
Usage:
python code_preproc.py path/to/filename
Creates a resulting file in a current directory called
code_preproc_out-filename
Functionality.
1. Removes lines in block
<code_preproc remove vvv>
....
<code_preproc remove ^^^>
"... |
61e74c1c979914aa10e586ffd0fc0817ecf47c10 | jmcontreras10/science-algorithms | /Statistic/LinearRegression.py | 1,312 | 3.546875 | 4 | # Author: jmcontreras10
# Using concepts learned in IBIO2240: scientific programming
import numpy as np
import matplotlib.pyplot as plt
import sys
from GaussJordan import gaussJordanSolve
##
# Gives the values to build the linear regression ecuation
# Inputs:
# xVals: Values of X Axis
# yVals: v... |
f6c2553cd81ea3b403b7a131024bdf2555037bc7 | ipikuza/new_project | /hw2/hw2_tasks.py | 2,657 | 3.6875 | 4 | from collections import Counter
import random
class homeWorkTwo():
def first_task_str(self):
new_str = 'spam and eggs or eggs with spam'
#total symbols
print('Total amount = ', len(set(new_str)))
print(' '.join(new_str))
#each symbols separately
counter = Counter(... |
39d6f88e3eb95a61f1f3696fa4d075b163578050 | jeremythibeau/AI_Project | /Card.py | 716 | 3.796875 | 4 | class Card:
def __init__(self, suit, number):
self.suit = suit
self.number = number
#prints the value of the top card of the deck
def printCard(self):
s = ""
if self.number == 11:
s = s+ "Jack"
elif self.number == 12:
s = s + "Queen"
... |
fc4392fc32b47c9488e55a8b04b7129e136d4d0f | zhangyiwen5512/myleetcode | /pyleetcode/solutions/reverse.py | 762 | 3.796875 | 4 | import os
"""
* 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。
*
* 输入: 123
* 输出: 321
*
* 输入: -123
* 输出: -321
*
* 输入: 120
* 输出: 21
*
*
* x对10取余数求得每一位,加到result上
* x/10下一位求余数
*
*
*
"""
class Solution:
def reverse(self, x: int) -> int:
result = 0
if x < 0:
sign = -1
x ... |
4d781f2bec62eccddb33a03135773b21d444c33c | zhangyiwen5512/myleetcode | /pyleetcode/solutions/divide.py | 1,829 | 3.90625 | 4 | from typing import List
"""
* 给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。
* 返回被除数 dividend 除以除数 divisor 得到的商。
* 整数除法的结果应当截去(truncate)其小数部分,例如:truncate(8.345) = 8 以及 truncate(-2.7335) = -2
*
* 输入: dividend = 10, divisor = 3
* 输出: 3
* 解释: 10/3 = truncate(3.33333..) = truncate(3) = 3
*
* 输入: divid... |
01dc461ae375845d07aba5caa78d5f7825d50257 | zhangyiwen5512/myleetcode | /pyleetcode/solutions/convert.py | 1,522 | 3.578125 | 4 | import os
"""
* 将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。
* 比如输入字符串为 "LEETCODEISHIRING" 行数为 3 时,排列如下:
* L C I R
* E T O E S I I G
* E D H N
* 之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"LCIRETOESIIGEDHN"。
* 请你实现这个将字符串进行指定行数变换的函数:
*
* 输入: s = "LEETCODEISHIRING", numRows = 3
* 输出: "LCIRETOESIIGEDHN"
*
* 输入: s =... |
c67f48095438ea0763744ce52cd3e0f9e9dd1eb2 | VitalShimanski/Study_Python | /STUDY_Python/DZ/Lists_range_DZ2.py | 531 | 3.90625 | 4 | for value in range(1,21):
print(value)
million = []
for value in range (1,1000001):
million.append(value)
print(million)
print(min(million))
print(max(million))
print(sum(million))
for value in range(1,21,2):
print(value)
multiples_of_three = []
for value in range(3,31):
if value%3 == 0:
mu... |
a45d2ea4c58b4593ad2afd24cd602b7e728f91e7 | VitalShimanski/Study_Python | /SQLite2.py | 2,053 | 3.671875 | 4 | #!/usr/bin/env python3
import sqlite3
from random import randint
global db
global sql
global user_login
db = sqlite3.connect('server db')
sql = db.cursor()
sql.execute("""CREATE TABLE IF NOT EXISTS users (
login TEXT,
password TEXT,
cash BIGINT
)""")
db.commit()
def reg():
# n... |
7cd318ccc78e1cf79b698818518639ea10ab78b5 | VitalShimanski/Study_Python | /Dictionaries_DZ9.py | 748 | 4.21875 | 4 | favorite_languages = {
'jen': 'python',
'sarah': 'c',
'edward': 'ruby',
'phil': 'python',
}
peoples = ['adam', 'sergey', 'jen', 'sarah', 'edward', 'lesly', 'amanda', 'phil', 'ivan']
for name in peoples:
if name in peoples and name not in favorite_languages:
print(f"{name.title()} please tak... |
134e609ec9efa3a9d8b85165a698d9376b190be3 | kumarjitpathakbangalore/backup | /Image Analysis/Automated Driver Fatigue detection/utils/propertiesUtils.py | 1,761 | 3.59375 | 4 | """
These are miscellaneous functions used in code
"""
import os
from utils.properties import Properties
def getPath(filename):
mode = ["data","evaluation","model","parameters","utils"]
path = ""
for any in mode:
if str(os.getcwd()).__contains__(any):
path = str(os.getcwd()).replace(... |
ef741ad62a8e5d1df4e6b9c23998e539a10bb322 | favour-22/holbertonschool-higher_level_programming | /0x06-python-classes/1-square.py | 283 | 3.828125 | 4 | #!/usr/bin/python3
"""Module containing the Square class"""
class Square:
"""The Square class"""
def __init__(self, size):
"""Initializing an instance of Square
Args:
size: The size of the Square instance
"""
self.__size = size
|
4e9f13a8c7ecab8c17168286a77e91f07b0c9d73 | favour-22/holbertonschool-higher_level_programming | /0x06-python-classes/5-square.py | 1,124 | 4.34375 | 4 | #!/usr/bin/python3
"""Module containing the Square class"""
class Square:
"""The Square class"""
def __init__(self, size=0):
"""Initializing an instance of Square
Args:
size (int): The size of the Square instance. Default value is 0.
"""
self.size = size
@prop... |
cd096cd1bb2f4ef28e00de18fc163cd8286f1e3f | favour-22/holbertonschool-higher_level_programming | /0x08-python-more_classes/101-nqueens.py | 5,639 | 4.15625 | 4 | #!/usr/bin/python3
"""
Module containing functions to search for solutions to N-queens problem.
"""
def all_possible(n=4):
""" Function to find all possible solutions by placing the first queen on
the first row, with different column positions starting from 2nd
column to 2nd to last column.
... |
38070e89a40aaec64428ba530d7570040165281f | durgeshsri/WaferFaultPrediction | /PredictionDataPreprosessing/Preprocessing.py | 8,646 | 3.71875 | 4 | import pandas as pd
import numpy as np
from sklearn.impute import KNNImputer
class Preprocessor:
"""
This class shall be used to clean and transform the data before training.
Written By: Durgesh Kumar
Version: 1.0
Revisions: None
"""
... |
5ad7ad4c61190bb23ee7693b99df8dc4c14ffb18 | skm2000/OOPS- | /Python/Assignment 1/Prog1_14A.py | 602 | 3.578125 | 4 | if __name__ == "__main__":
L = ["Dummy lines\n", "oo asas jef lasslakas\n", "paosask jn aslas\n"]
# writing to file
file1 = open('myfile.txt', 'w')
file1.writelines(L)
file1.close()
# Using readlines()
file1 = open('myfile.txt', 'r')
lines = fil... |
867215b59920586cda5067058b049d1373502c6a | skm2000/OOPS- | /Python/Assignment 2/Exercise20/controller.py | 1,907 | 4.25 | 4 | '''
@author: < add your name here >
'''
from tkinter import *
from quiz import Quiz
class Controller:
''' Drive an interactive quiz GUI '''
def __init__(self, window):
''' Create a quiz and GUI frontend for that quiz '''
self.quiz = Quiz()
self.question_text = Te... |
5b84ab152667ea66d91a03755afc7b2b0f22f302 | skm2000/OOPS- | /Python/Assignment 1/Prog1_3.py | 340 | 4 | 4 |
if __name__ == "__main__":
odd = []
even = []
for num in range(21):
if num%2 == 0:
even.append(num)
else:
odd.append(num)
print("first 10 odd numbers: " + str(odd))
print("first 10 even numbers: " + str(even))
# couldn't figure out what maam meant by ... |
81ffce60a78b6812d1c24a71d893500b76954bfb | thaithai1/ML_from_scratch | /Model.py | 14,165 | 3.515625 | 4 | import numpy as np
from utils import *
import matplotlib.pyplot as plt
class Model:
def __init__(self, X_train, Y_train, X_test, Y_test):
self.X_train = X_train
self.Y_train = Y_train
self.X_test = X_test
self.Y_test = Y_test
def init_param(self):
pass
def... |
e0eed7d38b062dfbc56f747dc415e2f0983cf9ad | Zong-Xi/IT-Management-with-Python | /Business-Python-1/hw3/exchange.py | 1,341 | 3.5625 | 4 | def change(a):
'''
消費金額: a (0 <= a <= 1000)
找錢規則: 與其給5張100,不如給1張500;與其給2個50,不如給1張100...
錢幣: 500 -> 100 -> 50 -> 10 -> 5 -> 1
'''
total = 1000 - a
p = q = r = x = y = z = 0
if total >= 500:
p = int(total / 500)
total = total - p*500
if total >= 100:
q = int(tot... |
02ce308d419002f025b27b4cb590fcff7d07dd7e | volleyballfantic2/projects | /python/PycharmProjects/data_visualization/sitka_highs.py | 1,331 | 3.59375 | 4 | import csv
import matplotlib.pyplot as plt
from datetime import datetime
# "sitka_weather_07-2014.csv", "sitka_weather_2014.csv", "death_valley_2014.csv"
filename = "data/buffalo_weather_2020.csv"
with open(filename) as f:
reader = csv.reader(f)
header_row = next(reader)
for index, column_header in enumer... |
b6d1750646f75d58e5f3c8073e3f7c009e0bf5c3 | ntrainor1/Challenges | /common/fibonacci.py | 502 | 4.03125 | 4 | from common.number_reader import number_reader
def fib(number):
if number < 1:
return "Please enter a positive number"
elif number == 1:
return str(0) + " - " + number_reader(0)
elif number == 2:
return str(1) + " - " + number_reader(1)
counter = 2
x = 0
y = 1
resul... |
4d721b782442d9f44367d2e314c669074032e57f | cosimino81/Udemy | /Python_Research/language_processing/counting_words.py | 6,009 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 05 09:44:16 2018
@author: Cosimo
Questa esercitazione fa riferimanto al CASE STUDY 2: Natural Language Processing
L'esercitazione parte con la definizione di semplici funzioni per la conta delle
frequenze delle parole in un testo e della lunghezza del testo, si p... |
85ccd72cb67a0988f99cfa816f2908fb9dccaa3c | cosimino81/Udemy | /OOP/8_multilevel_inheritance.py | 552 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 1 17:51:48 2019
@author: Cosimo
"""
class MusicalInstrument:
maxNumberOfKeys =12
class StringInstrument(MusicalInstrument):
typeOfWood = "Cedro"
class Guitar(MusicalInstrument, StringInstrument):
def __init__(self):
self.numb... |
93fee1f8d99829451cf39fde175f97e27ef15578 | rawg/bitsandfytes | /challenge/unionfind.py | 6,719 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
"""
import unittest
from collections import OrderedDict
class UnionFind(object):
"""A Union-Find data structure, aka a Disjoint-Set."""
def __init__(self, items):
# items[k] = position in sketch
self.items = OrderedDict()
i = 0
... |
3a969e69d8a704c7cfc2a3437f50a135e31ccd99 | epaqu/Leetcode-Interview-Questions-Easy | /strings/string2int.py | 856 | 3.734375 | 4 | class Solution(object):
def myAtoi(self, str):
"""
:type str: str
:rtype: int
"""
sign=1
expected=False
result=0
for x in str:
if expected and not x.isdigit():
break
if x == "-" and not expected:
... |
66d38a03e9b1bbd45d5cdcfe65d89b48933114f5 | ctuning/ck-ml | /program/shared-matmul-python/matmul.py | 1,243 | 3.515625 | 4 | #
# Copyright (C) 2016 by Grigori G.Fursin
# http://fursin.net
#
def prep(A,B,C):
import math
for j in range(0,N):
for i in range(0, N):
D=float(i+j+2);
A[i][j]=math.sin(D+1);
B[i][j]=math.sin(D+2);
C[i][j]=math.sin(D+3);
return
def matmulsub(A,B,... |
458aa7b7e8015db201c1c8563d93c48d849cd634 | moodycam/MARS-5470-4470 | /Hopkins/Homeworks/Week 3/Hopkins_Exercises_WK3.py | 4,235 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 4 14:52:51 2019
@author: srv_veralab
"""
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
person = input('Enter your name:')
#%%
"""
Exercise 1
"""
def scary():
person = input('Enter your name: ')
# Creates ... |
4e209b10871f8c9c64a2e55e93e8a3bcd61c0ce0 | moodycam/MARS-5470-4470 | /Ramsden/Ramsden_4_Feb_2019_.py | 5,379 | 3.578125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
# In[2]:
import matplotlib.pyplot as plt
# In[3]:
a = np.arange(10)
# In[4]:
a
# In[11]:
plt.plot(a,3*a + 5)
plt.xlabel('a')
plt.title('Plot')
plt.xlabel('a + 5')
plt.show()
# In[10]:
#We are revieweing the Numpy array plus plots
... |
e5604624eb414511597d0ada0690b9d85b6f1ac7 | moodycam/MARS-5470-4470 | /Hopkins/Notes/Week 2/Hopkins_Class_Notes.py | 2,314 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 23 18:10:11 2019
@author: srv_veralab
"""
#%% Board Notes
Variable Assignments
myvar = 2
"myvar" is the variable name
"=" is the assignment operator
"2" is what it can be
Types of assignments (aka "2")
Integer: 1, 2, 3,... |
6dcef2d50687fef1eceafb9a725c64c29680d921 | moodycam/MARS-5470-4470 | /Ramsden/Ramsden_6_Feb_2019_Class_notes.py | 3,092 | 4.0625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import matplotlib
# In[2]:
import numpy as np
# In[3]:
import matplotlib.pyplot as plt
# In[4]:
get_ipython().run_line_magic('matplotlib', 'inline')
# In[5]:
#Setting up the plot
# In[7]:
plt.subplots(figsize = (2,2))
# In[8]:
#1.3.2
# In[9]:
... |
0763e2dd334b978351b5eccc1a1d054aefcfa61b | 4lma/SMX | /M_03/UF1/PYTHON/ejercicio-edad-3.py | 195 | 3.84375 | 4 | edad = int(input("Indique su edad"))
if (((edad >= 18)and(edad<=23))or(edad==17)):
print ("puede entrar en la sesión de jovenes")
else:
print("no tiene permitido el acceso a esta sesion")
|
78a08c0d10259930252eddf76d371485dec22c36 | 4lma/SMX | /M_03/UF1/PYTHON/mayor_2.py | 375 | 3.828125 | 4 | entrada sortrida
-10-1-200 -1
3 6 9 9
3 9 6 9
6 3 9 9
6 9 3 9
9 3 6 9
9 6 3 9
9 9 9 9
9 9 6 9
9 6 9 9
6 9 9 9
n1=int(input("introduce un número cualquiera"))
n2=int(input("introduce un número cualquiera"))
n3=int(input("introduce un número cualquiera"))... |
b7d1653752dc00d49120d73ebd1042d3db955969 | rakhi2207/Learning-python | /dictionaryAndSet.py | 859 | 3.6875 | 4 | d1={"Rakhi":"Pizza","Vandana":"Burger","Aditi":"Punjabi tadka","Sugiya":"pasta",
"Shivango":{"Pizza","Burger","Punjabi tadka","Pasta"}}
print(d1["Shivango"])
print(d1["Aditi"])
d1["Mummy"]="Roti Sabzi"
print(d1)
del d1["Vandana"]
print(d1)
d1.update({"Rahul":"Icecream"})
print(d1)
d2=d1
del... |
6a658a044bee82ceaf20b137cd32ffdc110d1a6b | Aabha-Shukla/Programs | /Aabha_programs/9.py | 300 | 4.34375 | 4 | #Write a program that accepts sequence of lines as input and prints the
#lines after making all characters in the sentence capitalized.
#Suppose the following input is supplied to the program:
str=input('Enter a string:')
if str.lower():
print(str.upper())
else:
print(str.upper())
|
ac220d43f32c8f584a702565ed93d0578bc74634 | bulbulpaul/nlp100 | /chapter02/question_11.py | 1,523 | 3.625 | 4 | # coding:utf-8
import argparse
def _readfile_with(file_name, fn) :
"""
read file with execute function
:param str fil_name: open file name
:param function fn: execute function
:rtype: str
:return: string after function adaptation
"""
with open(file_name) as f:
for line in f:
... |
6aa20d19a5cf70877b26a0360034f74fedc72c45 | maxlaimon/rep | /w3/2.py | 240 | 3.546875 | 4 | def write_array(arr, file):
arr = map(lambda x : x+'\n',arr)
file.writelines(arr)
arr = ["some", "body", "once", "told me"]
with open("2.txt", "w") as F:
write_array(arr, F)
with open("2.txt", "r") as F:
for line in F:
print(line)
|
a1852a7e3e69fbe8b9e542a3b2b038f2d42528f9 | maxlaimon/rep | /w3/3.py | 460 | 3.5625 | 4 | import zipfile
import os
from pathlib import Path
def write_array(arr, file):
arr = map(lambda x : x+'\n', arr)
file.writelines(arr)
with zipfile.ZipFile("main.zip", "r") as zip1:
zip1.extractall("main")
p = Path("main")
files = list(p.glob('**/*.py'))
X = set()
for path in files:
X.add(path.parts[-2])
Xlist =... |
6e3afed12edd89d62566861277c27203d2efd298 | kishoreyekkanti/mangrove | /src/mangrove/utils/types.py | 2,406 | 4.03125 | 4 | # vim: ai ts=4 sts=4 et sw=4 encoding=utf-8
from numbers import Number
from datetime import datetime
def is_empty(arg):
"""
Generalizes 'empty' checks on Strings, sequences, and dicts.
Returns 'True' for None, empty strings, strings with just white-space,
and sequences with len == 0
"""
if ... |
1dcf0b7be1e8b0ec5d033145c42855f47a684d21 | kknd113/code | /medium/detect_cycle.py | 783 | 3.9375 | 4 | # Given a linked list, determine if it has a cycle in it.
#
# Follow up:
# Can you solve it without using extra space?
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def hasCycle(self, head):
... |
bd614402c1b6300dcdbc81e6c8ad29bdd3e2b425 | 924070845/TanzhouPythonVipSecondClass | /进程与线程池/进程池+线程池实现并发服务器.py | 1,219 | 3.546875 | 4 | from multiprocessing import Pool, cpu_count
from multiprocessing.pool import ThreadPool
import socket
server = socket.socket()
server.bind(('0.0.0.0', 9988))
server.listen()
def worker_thread(conn):
while True:
data = conn.recv(1024)
if data :
conn.send(data)
... |
e6464b910033a0d644dcf166d7e1e893c1328dc9 | 924070845/TanzhouPythonVipSecondClass | /网络编程/socket_server01.py | 1,343 | 3.578125 | 4 | '''
我们要实现的功能是,客户端向服务端发送一个消息,
服务端可以收到,并且原封不动的返回给客户端
'''
import socket
server = socket.socket() # 创建socket
server.bind(('0.0.0.0', 20000)) # 绑定IP地址
server.listen() # 创建监听
# 这里的监听还可以有参数,那是解释器版本的差异,有餐数是指最多有几个用户可以连接我。
# 不加人最大,任意数连接
# 不用写的时候,你写多少都没用
print('开始监听~~~')
# 开始接受客户端的请求
# accept返回的是... |
b7003bf6d2b49d71f3a10fef7ab46614f3ee9e81 | CaduFelix/http-localhost-8888-notebooks-Untitled1.ipynb | /Untitled1.py | 2,468 | 3.828125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
print(Boa noite)
# In[2]:
print ("boa noite")
# In[3]:
x = 5
# In[4]:
print ("x")
# In[ ]:
# In[5]:
print (x)
# In[6]:
print (type(x))
# In[7]:
preco = 19.99
print(preco, type(preco))
# In[8]:
cidade = "São Paulo"
print (cidade, type(cid... |
a6f2085c6b54a8422b8dd1cfa8997da4031ea06e | Ch-Illia/Intro_Python_Homework | /Homework 3 Chornoknyzhnyi.py | 3,010 | 4.21875 | 4 | # Задача 1
# У вас есть переменная value, тип - int.
# Написать тернарный оператор для переменной new_value по такому правилу:
# если value меньше 100, то new_value равно половине значения value,
# в противном случае - противоположне value число.
value = int(input("Enter here:"))
new_value = value / 2 if value < 100 el... |
159eaa2e0a1bd0ae18d12c34ec5511adbcdb22b1 | wanghao07456/ChinaHadoop_AI_Offer | /字符串/day1/亲密字符串/buddy_string_taiyang.py | 755 | 3.640625 | 4 | class Solution:
"""
@param A: string A
@param B: string B
@return: bool
"""
def buddyStrings(self, A, B):
# Write your code here
if A is None or B is None or len(A) != len(B):
return False
if A == B and len(set(A)) < len(A):
return True
l, ... |
3dc89baf77ab2e6419ec3e7a7c8f57ceff7114ce | RKiddle/Google-Python | /course-1/Dictionaries_Practice_Quiz.py | 1,135 | 3.578125 | 4 | #1
def email_list(domains):
emails = []
for keys in domains:
for values in domains[keys]:
emails.append(values+'@'+keys)
return(emails)
print(email_list({"gmail.com": ["clark.kent", "diana.prince", "peter.parker"], "yahoo.com": ["barbara.gordon", "jean.grey"], "hotmail.com": ["bruce.wayne"]}))
#2
def group... |
d3522472d723e178dc264817c90276ba968b792d | Khokavim/Python-Advanced | /PythonNumpy/numpy_dimensions.py | 625 | 4.03125 | 4 | import numpy as np
three_d_arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
#print (three_d_arr[0])
#if you omit later indices, the returned object will be a lowerdimensional
#
# # ndarray consisting of all the data along the higher dimensions
copied_values = (three_d_arr[0].copy()) # copy arr[0] v... |
691ce469febbe5b4404a3e0fb6e0d65681ab0e2c | Khokavim/Python-Advanced | /PythonNumpy/numpy_matrix_format.py | 497 | 4.53125 | 5 | import numpy as np
matrix_arr =np.array([[3,4,5],[6,7,8],[9,5,1]])
print("The original matrix {}:".format(matrix_arr))
print("slices the first two rows:{}".format(matrix_arr[:2])) # similar to list slicing. returns first two rows of the array
print("Slices the first two rows and two columns:{}".format(matrix_arr[:2, 1... |
8801ca4c2ab7197cb3982477f37ed8f743ccac3c | MaineKuehn/workshop-advanced-python-hpc | /solutions/021_argparse.py | 715 | 4.25 | 4 | # /usr/bin/env python3
import argparse
import itertools
import random
CLI = argparse.ArgumentParser(description="Generate Fibonacci Numbers")
CLI.add_argument('--count', type=int, default=random.randint(20, 50), help="Count of generated Numbers")
CLI.add_argument('--start', type=int, default=0, help="Index of first ge... |
d86f97ebd2082f1c97466d99b086e050270c17eb | stanslauz/djangod | /stans.py | 242 | 4 | 4 | guess_word = 12
count = 0
count_limit = 3
while count < count_limit:
gswd = int(input("enter the word please"))
count = count + 1
if gswd == guess_word:
print("correct word")
break
else:
print("nope") |
57a2d06aef3022901d575af35268be32a6cb2c25 | diligejy/nam | /04_calculate/cal.py | 163 | 3.859375 | 4 |
operator = ["+", "-", "*", "/", "="]
user_input = "5 + 5 * 10"
string_list = []
for i, s in enumerate(user_input):
print(i,s)
if s in operator:
|
6d4472bea179f8bc119c29f82a682a99682eade1 | benjaminestes/bq-stat | /nld_from_csv.py | 3,061 | 3.640625 | 4 | #!/usr/bin/env python
# coding=utf-8
"""Given a CSV file from Stat's ranking ranking export, create a
newline-delimited JSON file corresponding with BQ schema."""
from sys import stdin
import csv
import json
def map_row_to_schema(row):
"""Associate a value from a Stat CSV export with the correct
identifier ... |
bdf7f5076c576270b3f8fd3f4003314fffaad3e9 | Nooralwachi/compare_files.py | /compare_file.py | 292 | 3.609375 | 4 | def compare_files(filename1,filename2):
file1_gen=(line.strip() for line in open(filename1))
file2_gen=(line.strip() for line in open(filename2))
for line1, line2 in zip(file1_gen,file2_gen):
if line1 != line2:
return False
return True
print(compare_files('file1.txt', 'file2.txt')) |
554ce8a34f7fccb0c70834c13d94bb40bd51d02d | Marshall-mk/OpenCV | /openCV/drawing geometric shapes on images.py | 769 | 3.515625 | 4 | import cv2
import numpy as np
# draw geometric shapes
path = r'data/'
#img = cv2.imread(path+'lena.jpg',-1)
img = np.zeros([512,512,3],np.uint8)
#img = cv2.line(img,(0,0),(255,255),(255,255,0),5)# draws a line with the given parameters
#the image itself,the start point,end point,color,thickness (-1 fills it wi... |
b8814fe4b71ea51be71369d8086b1f1e6429ed1a | ajboxjr/Gradebook | /teacher.py | 3,308 | 3.859375 | 4 | #
from assignment import *
from student import *
class Teacher:
def __init__(self,name):
self.name = name
self.class_roster = []
self.assignment_list = []
# Add student to the class roster
def add_student_to_roster(self,student):
self.class_roster.append(student)
... |
fa17a26019490a7cedfb66cf3e29fd2afaea96eb | LuizGGeas/MatrizInversa | /mian.py | 3,047 | 3.546875 | 4 | class matriz:
matriz:float = []
inversa:float = []
def __init__(self, matriz):
self.matriz = matriz
tam = len(matriz)
for i in range(tam):
linha = []
for j in range(tam):
linha.append(0 if i != j else 1)
self.inversa.append(linha... |
98f6520c939360eb1b034ea4a75c42b0ae701ac0 | sadath-ms/ip_questions | /sequential_search.py | 811 | 3.875 | 4 | def seq_search_v1(arr, elem):
for ele in arr:
if ele == elem:
return 'Found'
return "Not Found"
def seq_search_v2(arr, elem):
# searching for un order list
pos = 0
while pos < len(arr):
if arr(pos) == elem:
return 'Found'
pos += 1
... |
08f5b82ba5051d45de9dee198e9e50cdd2b47e0a | sadath-ms/ip_questions | /unique_char.py | 523 | 4.15625 | 4 | """
UNIQUE CHARCTER IN A STRING
Given a string determines, if it is compresied of all unique characters,for example
the string 'abcde' has all unique characters it retrun True else False
"""
def unique_char(st):
return len(set(st)) == len(st)
def unique_char_v2(st):
chars = set()
for u in st:
... |
7b8e722198f0efde825faab33e60920ae943b119 | sadath-ms/ip_questions | /linked_list/s_ll.py | 2,851 | 3.6875 | 4 | """
Singly linked list:-
is a collection if nodes that collectevely form a linear sequence
each node stores a reference to an object that is an element of the sequence, as well as a
reference to the next node of the list
the first node and last node of the linked list are also known as the head and tail of the list
... |
4e9fba79b39377109816124964abc128742daddb | PratyPratyush/Socket_Programing | /roshan_python_code/r_final.py | 648 | 3.53125 | 4 | import os
from os.path import isfile
def fun(path):
print "This is Folder path : "+path
dirlist=os.listdir(path)
dirlen = len(dirlist)
dirlen=dirlen-1
arr = []
while(dirlen > -1):
if not os.path.isfile(path+"/"+dirlist[dirlen]):
arr.append(path+"/"+dirlist[dirlen]);
else:
print "File name : "+dirlist[d... |
97f80fb49430024d4d1e7d5742ad5f2ba5e73e59 | rishabhworking/python | /takingInputs.py | 293 | 4.34375 | 4 | # Python Inputs
print('Enter the number: ')
num1 = int(input()) # This is how to take an input
print('Enter the power: ')
num2 = int(input())
power=num1**num2
print(num2,'th power of',num1,'is:',power) # This is how you print vars with strs
# int(input())
# float(input())
# str(input())
|
20f47acbc3676f04a17898c859382514efc1e2cc | fabiochiusano/ttt3d | /simulation.py | 1,659 | 3.6875 | 4 | import matplotlib.pyplot as plt
from utils import *
from players import *
from board import *
from game import *
class Simulation:
pass
class Simulation1vs1:
def __init__(self, p1, p2, levels, rows, cols):
self.p1 = p1
self.p2 = p2
self.board = Board(levels,rows,cols)
self.results = [0,0,0]
self.tot_turns... |
dab9df4b39ba0b10328ea214191edd108e8a3aa1 | ja-vu/SeleniumPythonClass | /Class1/venv/sec4.py | 705 | 4.1875 | 4 | """
Sec 4 - 22
"""
cars = ["bmw", "audi", "lexus"]
empty_list = []
print(cars)
print(empty_list)
print("*#" * 20)
print(cars[0])
num_list = [1, 2, 3]
sum_num = num_list[0] + num_list[1]
print(sum_num)
more_cars = ["honda", "toyota", "KIA"]
print(more_cars[1])
more_cars[1] = "Benz"
print(more_cars[1])
print(mo... |
5273a16984fb7298dc231b4cdff161d4529ab76b | ja-vu/SeleniumPythonClass | /Class1/onlineExercises/Q6/StringList.py | 537 | 4.40625 | 4 | """
Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.)
https://www.practicepython.org/exercise/2014/03/12/06-string-lists.html
"""
word = input("Give me a word and I will check if this is a palindrome or not: ")
#... |
059baac8ac76bba912eafcf90a25b6cbf9df1baa | zhych125/Leetcode | /python/Reverse_Integer.py | 322 | 3.703125 | 4 | class Solution:
# @return an integer
def reverse(self, x):
result=0;
flag=False
if x<0:
flag=True
x=-x
while x>0:
result=result*10
result=result+x%10
x=x/10
if flag:
result=-result
return resu... |
2ef53322e5eea389a141c08d92f21c630221848b | mattwrobel/kparts | /kpart.py | 8,670 | 3.546875 | 4 | #!/usr/bin/python
class KMod(object):
def __init__(self, name):
self.name = name
self.parts = []
def __str__(self):
return self.name
class KTag(object):
def __init__(self, name):
self.name = name
self.parts = []
def __str__(self):
return self.name
class... |
e0d350abd7dc0c984321314ecc148c6b48b4becd | jbhowsthisstuffwork/python_automateeverything | /Practice Projects/theCollatzSequence.py | 968 | 4.375 | 4 | # Create a program that allows a user to input an integer that calls a collatz()
# function on that number until the function returns the value 1.
import time,
userInput = ''
stepsToComplete = 0
def collatz(number):
global userInput
evaluateNumber = number % 2
if evaluateNumber == 0:
userInput = n... |
3488ee4d0704d912fc00ae30bad1ce1b45bf0532 | derrix060/MutationTestingPresentation | /bank.py | 1,068 | 4.09375 | 4 |
class BankAccount():
"""
Class that represents a bank account.
"""
def __init__ (self, name, balance):
self.name = name
self._balance = balance
self._history = []
def deposit (self, amount):
"""
Deposit some money in this account.
"""
... |
0a1e41d87846b8bb1ac2f347ac49cb73aebf29d2 | prasoonsoni/Python-Questions-1st-Semester | /Lists/Take 10 integer inputs from user and store them in a list. Now, copy all the elements in another list but in reverse order.py | 273 | 4.0625 | 4 | """Take 10 integer inputs from user and store them in a list.
Now, copy all the elements in another list but in reverse order."""
l1 = []
for i in range(0,10):
i = int(input("enter number : "))
l1.append(i)
l2 = l1.copy()
l2.reverse()
print(l1)
print(l2) |
669eae0536f094468c0bb4aa409d40ab7542da68 | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/hello wrold.py | 724 | 3.78125 | 4 | def bubbleSort(arr):
n = len(arr)
for i in range(n-1):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
n = int(input())
name = []
price = []
for i in range(n):
x = input().split()
na = [x[-1],x[0]]
pa = [x[-1],int(x[1])]
... |
fe70b91cd95dd06b2831ef9931839caefc3a02c7 | prasoonsoni/Python-Questions-1st-Semester | /Strings/python program to count the number of lowercase character in the string.py | 172 | 4.0625 | 4 | """11. python program to count the number of lowercase character in the string"""
a = str(input())
count=0
for i in a:
if i.islower():
count+=1
print(count)
|
e071afae182433c4577b26135a837053f05fcece | prasoonsoni/Python-Questions-1st-Semester | /Python Collections/how to delete elements in list.py | 74 | 3.671875 | 4 | # how to delete elements in list
l =[1,2,3,4,5,6,7,8,9]
del(l[1])
print(l) |
330cd6f2d5ce9090ca9d481016e13a9529abe9e0 | prasoonsoni/Python-Questions-1st-Semester | /Strings/pythom programme to check if the string is a palindrome or not.py | 167 | 4.15625 | 4 | """12. python program to check if a string is a palindrome or not"""
a = str(input())
b = a[::-1]
if a==b:
print("palindrome")
else:
print("not a palindrome") |
4ae8f3a983da434c15c25f8da5df8cfb000789f1 | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/find no of small spheres.py | 533 | 4.25 | 4 | # OPERATORS
""" Q.1 --- TO FIND NO OF SMALL SPHERES OF RADIUS 'r' THAT CAN BE STORED IN
THE LARGE SPHERE OF RADIUS 'R' """
R = float(input("ENTER RADIUS OF LARGE SPHERE(in cm) : "))
r = float(input("ENTER RADIUS OF SMALL SPHERE(in cm) : "))
V = (4/3)*3.14*R*R*R # V = VOLUME OF L... |
08d57426aedacecd968d82102df17af5caa5be4b | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/Given a string and an integer number n, remove characters .py | 217 | 3.828125 | 4 | """Given a string and an integer number n, remove characters
from a string starting from zero up to n and return a new string"""
a = input("Enter String: ")
n = int(input("Enter 'n': "))
b = a[n:-1] + a[-1]
print(b) |
1a7af178aa5246edef6825bb77c4bc196088a4e4 | prasoonsoni/Python-Questions-1st-Semester | /Lists/Write a program to find the sum of all elements of a list using while loop.py | 235 | 3.9375 | 4 | """Write a program to find the sum of all elements of a list."""
n = int(input("no of inputs : "))
l =[]
i = 0
sum1 = 0
while i<n:
num = int(input("Enter a number : "))
l.append(num)
sum1 = sum1 + l[i]
i=i+1
print(sum1) |
cf627e4efe01fe4127f1bcc2f69b05edcf3cc04c | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/assignment operators.py | 69 | 3.796875 | 4 | a=int(input())
a+= 5 # can be both addition and substraction
print(a) |
1fef090297cdb3599ba5583d40331c743d593abb | prasoonsoni/Python-Questions-1st-Semester | /Lists/given an english word design algorithm and write the python code to check .py | 636 | 3.859375 | 4 | """given an english word design algorithm and write the python code to check
is it can be typed using just a single row of keyboard. for eg- potter, equity
pribt yes if letters of the word are from single row and print no otherwise"""
a = str(input("Enter a Word ? "))
f = "qwertyuiop"
s = "asdfghjkl"
t = "zxcvbnm"
a ... |
df10766124014991384ef77523a2ee29d9241517 | prasoonsoni/Python-Questions-1st-Semester | /Python Collections/general syntax of list.py | 128 | 3.8125 | 4 | ## general syntax of list##
"""varname = [item1, item2, item3]"""
L1 = [1,2,3]
print(L1)
#to access particular item
print(L1[0]) |
c759b9239673a8bab92a03451492a84931492cfc | prasoonsoni/Python-Questions-1st-Semester | /Lists/Write a program to print sum, average of all numbers, smallest and largest element of a list.py | 497 | 4.09375 | 4 | """Write a program to print sum, average of all numbers,
smallest and largest element of a list."""
n = int(input("How many numbers you want to enter ? "))
l = []
sum = 0
for i in range(0,n):
i = int(input("enter numbers = "))
l.append(i)
lenght = len(l)
for j in range(0,lenght):
sum = sum + l[j]
aver... |
e7c927f7a0dc6d4b8fedc95b86665744f50c2d2e | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/how to use elif.py | 295 | 4.21875 | 4 | """ how to use elif
if condition:
statements
elif condition:
statements """
# largest of three numbers #
a = int(input())
b = int(input())
c = int(input())
if a>b and a>c:
print (a, "is greatest")
elif b>c:
print (b, "is greatest")
else:
print (c, "is greatest") |
90cd2cd81f067aab6d5bce07cc69faee77301bd1 | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/printing even numbers using for.py | 70 | 3.546875 | 4 | ## print even numbers using range
for i in range(2,11,2):
print(i) |
eaeecab47effe7038b25ef3c7bbe6662937966dc | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/if eligible for exam or not.py | 534 | 3.96875 | 4 | """A student will not be allowed to sit in exam if his/her attendence is less
than 75%.
Take following input from user
1.Number of classes held
2.Number of classes attended.
3.And print
(i)percentage of class attended
(ii)Is student is allowed to sit in exam or not."""
held = int(input("NO OF CLASSES HEL... |
e51958edaeb4a968e4cfc62f23438a3e14ea5d23 | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/Given a list of numbers, return True if first and last number of a list is same.py | 279 | 3.875 | 4 | """Given a list of numbers, return True if first and
last number of a list is same"""
n = int(input("number of elements in a list= "))
l = []
for i in range(0,n):
x = int(input("Enter elements : "))
l.append(x)
if l[0]==l[-1]:
print("True")
else:
print("False") |
17d155696d9ffff04ef69db068378180a66f3aca | prasoonsoni/Python-Questions-1st-Semester | /EXERCISES/pat1.py | 442 | 4 | 4 | salary = int(input("salary - "))
experience = int(input("experience - "))
if salary<0 or experience<0:
print("invalid input")
else:
salary_10yrs = 0.1*salary + salary
salary_5yrs = 0.05*salary + salary
otherwise = 0.03*salary + salary
if experience>10:
print (int(salary_10yrs))
else :
... |
8d84090053e758628e030d08beca7f9e8ce7d207 | nakshatar/Python-assignment | /8.py | 204 | 3.9375 | 4 | tuple_a = ('Apple', 'Banana', 'Sapota', 'DalimbeHannu')
tuple_b = ('Potato', 'Brinjal', 'Eeerekai', 'Aagalkai')
my_list = list(zip(tuple_a,tuple_b))
for val in range(len(my_list)):
print (my_list[val])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.