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 |
|---|---|---|---|---|---|---|
afcee62a9cdf798e744eebbf4c20d10e0b1453c2 | amen619/python-core-tutorials | /lesson.06/while.py | 140 | 3.734375 | 4 | # Распечатать числа от 1 до 100
index = 1
while index <= 100:
print(index)
index += 1
# index = index + 1
|
9d6eaa66b5e3e24818e50cadbbbba75e76a5ca73 | ramlingamahesh/python_programs | /conditionsandloops/Sumof_NaturalNumbers.py | 615 | 4.21875 | 4 | num = int(input("Enter a number: "))
if num < 0:
print("Enter a positive number")
else:
sum = 0
# use while loop to iterate un till zero
while (num > 0):
sum += num
num -= 1
print("The sum is", sum)
# 2 Python Program - Find Sum of Natural Numbers
print("Enter '0' for exi... |
24a599fb4fa7dcf2a5fe305b6a0905429dc2d195 | ramlingamahesh/python_programs | /conditionsandloops/GCDorHCF.py | 779 | 4.125 | 4 | '''n1 = 48
n2 = 36
# find smaller
if (n1 > n2):
smaller = n2
else:
smaller = n1
# getting hcf
i = 1
while (i <= smaller):
if (n1 % i == 0 and n2 % i == 0):
hcf = i
i = i + 1
print("hcf = ", hcf)'''
# Method 2: Using Recursion
'''
def find_hcf(n1, n2):
if (n2 == 0):
return n1
... |
ec5b56efd27c6d6c232e3c21f80bdccba626b68b | ramlingamahesh/python_programs | /conditionsandloops/FindNumbers_Divisible by Number.py | 646 | 4.15625 | 4 | # Python Program - Find Numbers divisible by another number
print("Enter 'x' for exit.");
print("Enter any five numbers: ");
num1 = input();
if num1 == 'x':
exit();
else:
num2 = input();
num3 = input();
num4 = input();
num5 = input();
number1 = int(num1);
number2 = int(num2);
number3 = ... |
36227f5beb047cbeb7dc6528774d971c006344da | ramlingamahesh/python_programs | /Pyramid Patterns/ProgramNo_5.py | 207 | 3.734375 | 4 | # Python Program - Pattern Program 5
n = 1
for i in range(0, 5):
for j in range(0, i + 1):
print(n, end=" ")
n = n + 1
print()
'''
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
''' |
718141c59ac719131f6076dae72f09618093af0a | elnadar/My-Udacity-porjects | /Udacity US bike share/bikeshare.py | 8,251 | 4.15625 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york': 'new_york_city.csv',
'washington': 'washington.csv' }
# list of valid months name
months = ['january', 'february', 'march', 'april', 'may', 'june']
# list of valid boolean inputs
boolean ... |
4558ee9719d5cc3ed9f3527fea983dff4ff2f2e9 | shohanurhossainsourav/python-learn | /program21.py | 463 | 3.8125 | 4 | subjects = ["C", "C++", "Java", "python", "BASIC"]
print(len(subjects))
subjects1 = [22, 11, 44, 33, 55, 77, 44, 44]
subjects.append("TOC")
print(subjects)
subjects.insert(2, "OS")
print(subjects)
subjects.remove("BASIC")
print(subjects)
subjects.sort()
print(subjects)
subjects.reverse()
print(subjects)
subjects.... |
7d2c9e8a5deaf3638bd82e7c1c846f3ce5fd0f5d | shohanurhossainsourav/python-learn | /program52.py | 599 | 3.984375 | 4 | class Shape:
def __init__(self, dim1, dim2):
self.dim1 = dim1
self.dim2 = dim2
def area(self):
print("I am area method of shape class")
# triangle class inherits Shape class' property
class Triangle(Shape):
def area(self):
area = 0.5 * self.dim1 * self.dim2
... |
5209c52949500091bda483d0b6b7fba199098637 | shohanurhossainsourav/python-learn | /program28.py | 341 | 4.375 | 4 | matrix = [
[1, 2, 3],
[4, 5, 6],
]
print(matrix[0][2])
# print matrix value using nested loop
matrix = [
[1, 2, 3],
[4, 5, 6],
]
for row in matrix:
for col in row:
print(col)
matrix1 = [
[1, 2, 3],
[4, 5, 6],
]
# 0 row 2nd coloumn/3rd index value changed to 10
matrix1[0][2] = 10
... |
051560570af67ed470d7713cba3533ef063228a2 | shohanurhossainsourav/python-learn | /program41.py | 279 | 3.9375 | 4 | '''
reading a file
'''
file = open("student.txt", "r+")
# print(file.writable())
# text = file.readlines()
# print(text)
text = file.read()
print(text)
# text = file.readlines()[1]
# print(text)
size = len(text)
print(size)
# for line in file:
# print(line)
file.close()
|
19264495dfaeaa903ae6f58ab0219d2e1316ebf7 | shohanurhossainsourav/python-learn | /program45.py | 72 | 3.546875 | 4 | # swapping
a = 10
b = 20
a, b = b, a
print("a = ", a)
print("b = ", b)
|
da45c09ec80fff7517b34d291544b8e7048d2892 | shohanurhossainsourav/python-learn | /program47.py | 375 | 3.5625 | 4 | # class and object with method
class Student:
roll = ""
gpa = ""
def set_value(self, roll, gpa):
self.roll = roll
self.gpa = gpa
def display(self):
print(f" Roll : {self.roll}, GPA : {self.gpa}")
Sourav = Student()
Sourav.set_value(1965, 3.81)
Sourav.display()
Sumaiya = Stu... |
b4d942266d626f9864334cebee50dbc78808ac87 | Hanlen520/XKAppium | /case/try_thread.py | 336 | 3.734375 | 4 | # -*- coding: utf-8 -*-
# @Author : xiaoke
# @Email : 976249817@qq.com
import threading
threads = []
def sum(a):
print(a + 1)
for i in range(3):
thread = threading.Thread(target=sum, args=(i,))
threads.append(thread)
print(thread)
if __name__ == '__main__':
for y in thre... |
e8e3c5198815a39621631504bf3eb15588b98242 | impramodp/FSDP2019 | /day12/titanic.py | 722 | 3.53125 | 4 | # -*- coding: utf-8 -*-
import pandas as pd
df = pd.read_csv("training_titanic.csv")
df['Survived']
df['Survived'].value_counts()[1]
print("survived : ",df['Survived'].value_counts()[1])
print("died : ",df['Survived'].value_counts()[0])
print("survival rate :",df['Survived'].value_counts(normalize = True)[1]*100)
df_ma... |
4a3572eb56f3287a934c34dc39844ee8c33e8be2 | impramodp/FSDP2019 | /day2/day2/pangram.py | 371 | 3.875 | 4 | # -*- coding: utf-8 -*-=
str=input("Enter the string :")
l1=[]
count=0
for i in str:
l1.append(i)
final_list=[]
for y in l1:
if y not in final_list:
final_list.append(y)
for elements in final_list:
if elements in 'abcdefghijklmnopqrstuvwxyz':
count += 1
if count == 26:
print ("Pangr... |
7fb0a50ad7eef5019dd88b11c7d868f595c10c4b | impramodp/FSDP2019 | /day1/restart.py | 361 | 4.03125 | 4 | # -*- coding: utf-8 -*-
str1=input("enter a string")
replaced_char=input("enter the character you want to replace")
replacement_char=input("enter char eith younwant to replace")
#first appearence of replaced char
f_occur=str1.find(replaced_char)
str2=str1[:f_occur+1]
str3=str1[f_occur+1:].replace(replaced_char, repla... |
d355cdcb98615fbb916b8388c13cb90d97ab8120 | impramodp/FSDP2019 | /day2/day2/translate.py | 292 | 3.671875 | 4 | # -*- coding: utf-8 -*-
str=input("enter a string")
def translate(s1):
l1=[]
constant='bcdfghjklmnpqrstvwxyz'
for i in s1:
if i in constant:
l1.append(i+'o'+i)
else:
l1.append(i)
s2="".join(l1)
print(s2)
translate(str) |
9b7f0e17ba1b5b1515c5472d187564535343e565 | impramodp/FSDP2019 | /day11/random_data.py | 566 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Code Challenge
Name:
Random Data
Filename:
random_data.py
Problem Statement:
Create a random array of 40 integers from 5 - 15 using NumPy.
Find the most frequent value with and without Numpy.
Hint:
Try to use the Counter class
"""
"""
import numpy as ... |
336805fbe7a04923ccd0599a0aa944f6c590a356 | Kinshuk0/MycompetitiveProgrammingFolder | /typeB.py | 487 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 22 19:09:16 2021
@author: 007ki
"""
# n=int(input())
# a=input()
# A=a.split()
# b=[]
# for i in range(n):
# b.append(int(A[i]))
# max1=b[0]
# for j in range(n):
# if max1<b[j]:
# max1=b[j]
# print(max1)
def prime(N):
if N==1: return False
if N==2... |
d54bd2b131232a1b0f92aaff434c4951ee305846 | ikki2530/holbertonschool-machine_learning | /supervised_learning/0x08-deep_cnns/0-inception_block.py | 2,140 | 3.84375 | 4 | #!/usr/bin/env python3
"""
that builds an inception block as described in
Going Deeper with Convolutions (2014):
"""
import tensorflow.keras as K
def inception_block(A_prev, filters):
"""
Builds an inception block as described in
Going Deeper with Convolutions (2014).
- A_prev is the output from the p... |
6433023d486b18065e67d30dd1621ecf95301b1e | ikki2530/holbertonschool-machine_learning | /unsupervised_learning/0x03-hyperparameter_tuning/0-gp.py | 1,523 | 3.875 | 4 | #!/usr/bin/env python3
"""Class GaussianProcess that represents
a noiseless 1D Gaussian process"""
import numpy as np
class GaussianProcess:
"""represents a noiseless 1D Gaussian process"""
def __init__(self, X_init, Y_init, l=1, sigma_f=1):
"""Constructor.
- X_init is a numpy.ndarray of shape... |
ff6a9327111545c69ad4f59c5b5f2878def92431 | ikki2530/holbertonschool-machine_learning | /math/0x02-calculus/10-matisse.py | 740 | 4.53125 | 5 | #!/usr/bin/env python3
"""Derivative of a polynomial"""
def poly_derivative(poly):
"""
-Description: calculates the derivative of a polynomial.
the index of the list represents the power of x that the
coefficient belongs to.
-poly: is a list of coefficients representing a polynomial
- Returns:... |
788c196f9947a72e91bce88ad2cb99b40f17b272 | ikki2530/holbertonschool-machine_learning | /supervised_learning/0x06-keras/0-sequential.py | 1,076 | 3.875 | 4 | #!/usr/bin/env python3
"""
Builds a neural network with the Keras library
"""
import tensorflow.keras as K
def build_model(nx, layers, activations, lambtha, keep_prob):
"""
- Builds a neural network with the Keras library.
- nx is the number of input features to the network.
- layers is a list contain... |
d82167ca61a739e2d8c6919137e144a987ee22a3 | ikki2530/holbertonschool-machine_learning | /math/0x00-linear_algebra/8-ridin_bareback.py | 1,123 | 4.3125 | 4 | #!/usr/bin/env python3
"""multiply 2 matrices"""
def matrix_shape(matrix):
"""
matrix: matrix to calcuted the shape
Return: A list with the matrix shape [n, m],
n is the number of rows and m number of columns
"""
lista = []
if type(matrix) == list:
dm = len(matrix)
lista.ap... |
181c2da20188630579f80073830b9345a974babc | ikki2530/holbertonschool-machine_learning | /math/0x00-linear_algebra/14-saddle_up.py | 270 | 3.65625 | 4 | #!/usr/bin/env python3
"""Matrix multiplication (ndarrays)"""
import numpy as np
def np_matmul(mat1, mat2):
"""
Description: performs matrix multiplication mat1 @ mat2
Returns: new matrix with result of mat1 @ mat2
"""
return np.matmul(mat1, mat2)
|
373e7d3e096df3052db150553f7beb76d7ffdb49 | ikki2530/holbertonschool-machine_learning | /math/0x00-linear_algebra/4-line_up.py | 393 | 4.09375 | 4 | #!/usr/bin/env python3
"""add 2 arrays"""
def add_arrays(arr1, arr2):
"""
arr1: array #1 for the sum
arr2: array # 2 for the sum
Returns: an array with element-wise add operation of arr1 + arr2
"""
suma = []
if len(arr1) != len(arr2):
return None
else:
for i in range(le... |
181117260d2bcdc404dcd55a6f51966afa880e83 | ikki2530/holbertonschool-machine_learning | /supervised_learning/0x07-cnn/0-conv_forward.py | 2,649 | 4.53125 | 5 | #!/usr/bin/env python3
"""
performs forward propagation over a convolutional layer of a neural network
"""
import numpy as np
def conv_forward(A_prev, W, b, activation, padding="same", stride=(1, 1)):
"""
- Performs forward propagation over a convolutional layer of a
neural network.
- A_prev is a nump... |
3d33fc4784b2ddc14994ef40c5a73602c405a7f8 | ikki2530/holbertonschool-machine_learning | /supervised_learning/0x06-keras/8-train.py | 2,717 | 3.546875 | 4 | #!/usr/bin/env python3
"""
to also save the best iteration of the model
"""
import tensorflow.keras as K
def train_model(network, data, labels, batch_size, epochs,
validation_data=None, early_stopping=False,
patience=0, learning_rate_decay=False,
alpha=0.1, decay_rate=1... |
4abaada6a6bbae038eb631fa881c4bf17ecc179f | ikki2530/holbertonschool-machine_learning | /math/0x01-plotting/6-bars.py | 726 | 3.65625 | 4 | #!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(5)
fruit = np.random.randint(0, 20, (4, 3))
# main stuff
persons = ["Farrah", "Fred", "Felicia"]
width = 0.5
plt.title("Number of Fruit per Person")
plt.ylabel("Quantity of Fruit")
# bars
plt.bar(persons, fruit[0], width, color='... |
8befc7eef3d698490dbcef345662793af0499643 | pjargo/INF-552-Machine-Learning | /principal component analysis/pca_scikit.py | 2,698 | 3.65625 | 4 | #PART 2: Do PCA on the 3d dataset and report the direction of each
#Report the direction of the first 2 Principal Components
#Use scikit to perform PCA algorithm
import os
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
def clean... |
12c1668d982a5498a25803db64e607b4dc5555bc | Rodrigomelomarc/DailyCodingProblems | /Problem 1/problem1.py | 509 | 3.640625 | 4 | import unittest
def solve(k, arr):
for i in range(0, len(arr)):
for j in range(i+1, len(arr)):
if arr[i] + arr[j] == k:
return True
return False
class Tests(unittest.TestCase):
def test_should_return_true(self):
attempt = solve(17, [10, 15, 7, 5])
self... |
a24147eb506452976e944b14e2207ad74b20df62 | wuhanyu/BTPT | /bugzillaMiner/apriori/apriori.py | 5,795 | 3.796875 | 4 | """
Description : Simple Python implementation of the Apriori Algorithm
Author : Abhinav Saini(abhi488@gmail.com)
Credits : Cesare Zavattari(cesare@ctrl-z-bg.org) for making suggestions and refactoring code
Usage:
$python apriori.py -f DATASET.csv -s minSupport -c minConfidence
Eg.
... |
0e2c8ae71596e86304c9e478996432175eb06ba0 | MartinHvidberg/sudoku | /sudoku/SuDoKu_DaPr.py | 2,318 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8; -*-
""" DaPr - Data Preparation
Small and big pieces of code, to prepare data from wherever, to enter the EC-software SuDoKu universe
"""
import json
import os
def txt2ecs(s_sdktxt):
"""
Converts on line (string) with one SuDoKu in 'raw' text form
to one d_ecs ... |
526e41fedb5882222d929b14e7427d4400554fcb | CodeeChallenge/GetIntoRocket | /aaaa.py | 96 | 3.65625 | 4 | #factor
sum=0
a=int(input("enter a no"))
for x in range (1,a+1):
r=a%x
if r==0:
print(x)
|
38bf253dc00a9775989f3c3cfe649125f304681f | CodeeChallenge/GetIntoRocket | /sol27.py | 430 | 3.625 | 4 | from sys import argv
script,user_name = argv
print("hi,{user_name},i'm the {script}script")
print("i would like to ask you few question")
print("do you like me{user_name}?")
likes=input()
print("where do you live in")
live=input()
print("how many computers do you have")
computers=input()
print("""
alright,so you s... |
9ce3ff474fdf8da3291c6475b0a09f0903b7a0b8 | edking4967/color | /color.py | 811 | 3.546875 | 4 | #!/usr/bin/python
from os import path
# Strings and shortcuts
extn = '.colors' # ".color" files define all the colors in a swatch
# A color.
class Color:
name = "white"
rgb= 0xffffff
# A swatch contains multiple colors.
class Swatch:
color = Color
# Display output modules:
def displayInTerminal():
return; ... |
2b32a74fed8cc23daffbf9f48f108273fa36e03d | bogdankazakov/learn | /DZ_Selfwork/Lesson3_z1.py | 916 | 4.03125 | 4 | # Lesson 3 ==========================================
# Задание один: Напишите программу, которая проверяет, является ли введенная строка панграммой ==========================================
rus=['а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', ... |
e88487f9fcfc5fc24177204b0d0ac304e4cab198 | mqadri9/leetCode-py | /subsets_in_set.py | 507 | 3.796875 | 4 | def subsets_in_set(element, index, array_element, permutation_list):
if index < 0:
return
if element not in permutation_list:
permutation_list.append(element)
subsets_in_set(set(element), index-1 , array_element, permutation_list)
element = list(element)
element.append(array_element[... |
d6ad82f47a8feab41a63544c33d42ce9c17b3d52 | Wangzhipeng777/file | /day3/demo10.py | 749 | 3.53125 | 4 | if __name__ == '__main__':
klist = [
"good ", "good ", "study",
" good ", "good", "study ",
"good ", " good", " study",
" good ", "good", " study ",
"good ", "good ", "study",
" day ", "day", " up",
" day ", "day", " up",
" day ", "day", " up",
... |
7ebdaffbb03f2fffb7587b125d17efa8e9b2cb60 | Wangzhipeng777/file | /day3/demo05.py | 891 | 3.6875 | 4 | if __name__ == '__main__':
klist = [
"good ", "good ", "study",
" good ", "good", "study ",
"good ", " good", " study",
" good ", "good", " study ",
"good ", "good ", "study",
" day ", "day", " up",
" day ", "day", " up",
" day ", "day", " up",
... |
b6ab3bb4635a502f8cbbf598910e64194216c071 | Wangzhipeng777/file | /day3/demo09.py | 615 | 3.78125 | 4 | # if __name__ == '__main__':
# 1.
# mlist=[]
# for i in range(1,11):
# mlist.append(i)
#2.
#如果在list中既包含字符串,又包含其它类型数据,如何修改1中的生成式实现把一个list中所有的字符串变成小写?
#(内建的isinstance(x, str)
# 函数可以判断一个变量是不是字符串)
if __name__ == '__main__':
L = ['Hello', 'World', 'IBM', 'Apple']
l=[i.... |
41f9900ccca0109b0472bd5256d71a3fdf0aaf81 | Wangzhipeng777/file | /day3/mset.py | 1,184 | 3.625 | 4 | # if __name__ == '__main__':
# # mset=set()
# # print(type(mset))
# # n={}
# # print(type(n))
# #
# # mset={1,2}
# # print(type(mset))
# #
# # mset=set("good luck")
# # print(mset)
# #
# # lset=set({1,2,3,4,5})
# #
# # if 4 in lset:
# # print("是的")
# # if 10 not in ls... |
d5435c2f2cca0098f13f5d2ca37100b58eed8515 | David-Papworth/qa-assessment-example-2 | /assessment-examples.py | 2,639 | 4.1875 | 4 | # <QUESTION 1>
# Given a word and a string of characters, return the word with all of the given characters
# replaced with underscores
# This should be case sensitive
# <EXAMPLES>
# one("hello world", "aeiou") → "h_ll_ w_rld"
# one("didgeridoo", "do") → "_i_geri___"
# one("punctation... |
7fded9d884f43d2fcc53f17647b3a2fe78e32b74 | andyless/maple-bot | /rune_solver.py | 5,321 | 3.625 | 4 | import cv2 as cv
import os
import numpy as np
def find_arrow_directions(img, debug=False):
"""
Given an image in BGRA format, will attempt to find "arrows" through
classifying the directions of gradients that start and end at certain HSV values.
Debugging will show parsed pictures of the image.
""... |
4e128b907dfa241ce3b3a3dbc01be39e0ff01cee | ex-hibition/unittest_py | /sample.py | 722 | 4.0625 | 4 | import datetime as dt
# -- クラスつくる
class DateCalculation:
# -- コンストラクタ
def __init__(self, yyyymmdd):
self.target_date = dt.datetime.strptime(yyyymmdd, "%Y%m%d")
# -- mm日前を計算するメソッド
def calc_before_days(self, mm):
calc_date = self.target_date - dt.timedelta(days=+int(mm))
return calc_date
if __... |
9de946f8e7625b335a4dd555bcefd155099786a2 | mvdssel/adventofcode2020 | /12/puzzel1.py | 3,120 | 3.9375 | 4 | INPUT = '12/input1.txt'
print("------------------------------------------")
print(" PUZZEL 1")
print("------------------------------------------")
inputFile = open(INPUT, 'r')
# # example
# inputFile = [
# 'F10',
# 'N3',
# 'F7',
# 'R90',
# 'F11'
# ]
NORTH = 'N'
EAST = 'E'
SOUTH = 'S'
WES... |
53bd0caa8227f1b084e41c0503b81e9b0abcc9c4 | mvdssel/adventofcode2020 | /08/puzzel2.py | 2,233 | 3.53125 | 4 | import re
INPUT = '08/input1.txt'
print("------------------------------------------")
print(" PUZZEL 1")
print("------------------------------------------")
inputFile = open(INPUT, 'r')
code = list()
# Read input file
for line in inputFile:
pattern = r'(\w+) ([+-]\d+)'
matchObj = re.match(pattern,... |
826fe938535cd3bd66c9cd1b8c49c0dd972be7c9 | siddarthjha/Python-Programs | /08_file.py | 250 | 3.671875 | 4 | with open("file.txt") as file:
stuff=file.read()
print(stuff)
print(file.closed)
print(stuff)
with open("file.txt",'w') as file1:
file1.write("Yes motherfucker")
with open("file.txt") as file:
stuff=file.read()
print(stuff)
|
81180dba20e2c730b5cbd3537abc22fb797ceafa | siddarthjha/Python-Programs | /10_fundamentals.py | 1,681 | 3.75 | 4 | """
Please uncomment and execute as there may be use of similar variables.
List Set Tuple Dictionary
"""
# List
"""
l = ['Siddarth', 40, 'CSE']
print(l)
print('Student Name is {0} and his roll number is {1} enrolled with in {2}'.format(l[0], l[1], l[2]))
print(l[-1])
l = [1, 98, 3, 4]
print(max(l))
# s='hey... |
0875700b5375f46ffcb44da81fff916e10808e6d | siddarthjha/Python-Programs | /06_inheritance.py | 1,338 | 4.28125 | 4 | """
Concept of Inheritance.
"""
print('I am created to make understand the concept of inheritance ')
class Upes:
def __init__(self, i, n):
print('I am a constructor of Upes ')
self.i = i
self.n = n
print('Ok i am done bye....')
def fun(self):
print('I am ... |
b9f0b7f7699c8834a9c3a7b287f7f68b09b100ee | GabrielByte/Programming_logic | /Python_Exersice/ex018.py | 289 | 4.34375 | 4 | '''
Make a program that calculates sine, cosine and tangent
'''
from math import sin, cos, tan, radians
angle = radians(float(input("Enter an angle: ")))
print(f"This is the result; Sine: {sin(angle):.2f}")
print(f"Cosine: {cos(angle):.2f}")
print(f"and Tangent: {tan(angle):.2f}")
|
45e8158ac5e78c5deea43e77bebb2773c3aee215 | GabrielByte/Programming_logic | /Python_Exersice/ex017.py | 230 | 4.1875 | 4 | '''
Make a program that calculates Hypotenouse
'''
from math import pow,sqrt
x = float(input("Enter a number: "))
y = float(input("Enter another one: "))
h = sqrt(pow(x,2) + (pow(y,2)))
print(f"This is the result {h:.2}")
|
ac9078c486f000f6b09495518f7f7a7f688d5e80 | Julienpir/sb7-pgz | /actor/actor_fetch.py | 938 | 3.734375 | 4 | # Example using pygame-zero actor object
# move the ball to where the mouse is clicked
# with the pgz animation function
BACK_COLOR = (200, 225, 255)
HEIGHT = 300
WIDTH = 500
BALL = 'ball_64x64'
DOG2 = 'dog2_100x100'
ball = Actor(BALL, (100, 100))
dog = Actor(DOG2, (100, 100))
def draw():
screen.fill(BACK_COLOR)... |
c95c66c58869030e512f3f6a92cdacae67f81bf4 | Julienpir/sb7-pgz | /actor/actor_jump.py | 2,165 | 3.984375 | 4 | # Example using pygame-zero actor object
# To jump use 'decelerate' to move up
# then 'accelerate' for down
BACK_COLOR = (200, 225, 255)
HEIGHT = 300
WIDTH = 500
DOG1 = 'dog1_100x100'
DOG2 = 'dog2_100x100'
BALL = 'ball_64x64'
GROUND_X = WIDTH / 2
GROUND_Y = HEIGHT - 50
JUMP_T = 0.8
JUMP_Y = 150
class Game:
def ... |
3980bc3d432d3d8429b833d77a1cdf3e7116b9e6 | olilo/tools | /print_square.py | 492 | 3.890625 | 4 | #!/usr/bin/python3
import sys
def main(argv):
if len(argv) > 0:
size = int(argv[0])
else:
size = 10
for i in range(0, size):
print('*', end='')
print()
for i in range(0, size - 2):
print('*', end='')
for j in range(0, size - 2):
print(' ', end=... |
a2744e9fa087fafe480ab54ec4fed15a4acf1d74 | k0psutin/ohte-2020 | /src/ui/components/label.py | 867 | 3.53125 | 4 | class Label():
def __init__(self,
text,
size_x,
size_y,
offset_x,
offset_y,
gamestate,
font, font_color=(0, 0, 0)):
self.width = gamestate.width
self.height = gamestate.height
... |
20d13dfc9110f69eef936e08ac88f2951708d5e5 | SurendraGoutham/Project-Euler-in-Python | /EulerP007.py | 484 | 3.84375 | 4 | '''
Created on 27-Nov-2013
@author: 00003179
'''
import math
def is_prime(n):
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
# count = 1
# num = 2
# limit = 10
# while True:
# if count > limit:
# break
# elif is_prime(n... |
c82a61ef6f0661362bdc638a56668172cb8e3883 | jiehawes/ScientificallySound_files | /fitness_argparse.py | 3,006 | 4.09375 | 4 | from argparse import ArgumentParser
def main(args):
print_results(args)
def bmi_calc(weight_kg, height_m):
"""Calculate BMI from weight in kg and height in meters"""
bmi = int(weight_kg / height_m ** 2)
return bmi
def predict_max_HR(age):
"""Age predicted maximal heart rate"""
max_HR = 208... |
5882e1b0071661196840df222828a46d0185519c | gordoning/python_basic | /basic_02.py | 2,015 | 3.734375 | 4 | """
python基础知识02
正则表达式
"""
# 如何表示空格
# '\s'
# 如何表示字母
# '\w'
# 如何表示数字
# '\d'
# 如何表示特殊字符'-'
# '\-'
# 如何表示任意字符
# '.'
#############
# 如何表示0到5和a到y的数字范围
# [0-5][a-y]
# 如何表示2个当中的任意一个
# a|bc
#############
# 如何表示0或1个
# 'a?' 可表示为空,也可表示为a
# 如何表示3到5个字符
# 'a{3,5}'
# 如何表示1-n个字符
# 'a+',可表示a,也可表示aaaaaa
# 如何表示0-n个字符
# 'a... |
38b524a20fa88a549e0926230a63571a113c6249 | tabssum/Python-Basic-Programming | /rename_files.py | 997 | 4.21875 | 4 | #!/usr/bin/python
import os
import argparse
def rename_files():
parser=argparse.ArgumentParser()
parser.add_argument('-fp','--folderpath',help="Specify path of folder to rename files")
args=parser.parse_args()
#Check for valid folderpath
if args.folderpath :
#Get files in particular folder
... |
4fb5fbd0fe56e4c4224310a6aeeef6186a93e261 | smakireddy/python-playground | /ArraysAndStrings/hackerrank_prime.py | 831 | 3.90625 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import math
n = int(input())
arr = []
for i in range(n):
number = int(input())
arr.append(number)
# for element in arr:
# print("processing.....", element)
# result = "Prime"
# if element == 1:
# result = "Not prime"
# ... |
dbccaa5b83a7764eb172b0e1653f7f086dd7b95e | smakireddy/python-playground | /ArraysAndStrings/PrisonCellAfterNDays.py | 2,265 | 4.21875 | 4 | """"
There are 8 prison cells in a row, and each cell is either occupied or vacant.
Each day, whether the cell is occupied or vacant changes according to the following rules:
If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.
Otherwise, it becomes vacant.
(Note... |
7d543273ad847de56beaae7761f9280640cfe012 | smakireddy/python-playground | /ArraysAndStrings/hackerrank_binary.py | 1,396 | 4.15625 | 4 | """
Objective
Today, we're working with binary numbers. Check out the Tutorial tab for learning materials and an instructional video!
Task
Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation. When working... |
9b1451d90cc82162418884d45d25ff225b44b7da | saikrishna6415/python-problem-solving | /newp2.py | 522 | 3.59375 | 4 | n = int(input("enter a number : "))
# for i in range(1,n+1):
# print((n-i)*(" "),end=" ")
# k = 1
# for j in range(1,i+1):
# print(str(k),end = " ")
# k = k*(i-j)//j
# print()
a = [[" " for i in range(n)]for j in range(n)]
for i in range(0,n):
for j in range(1,i+1):
... |
894e1b7a8b3255b3d0c3a253526eb1dcc2a3831c | saikrishna6415/python-problem-solving | /spiralnumbers.py | 351 | 3.5 | 4 | n = int(input("enter a number : "))
a = [['' for i in range(n)]for j in range(n)]
num = 1
i = 0
j = 0
while i>=0 and j<n:
a[i][j]=num
num+=1
j+=1
i= 1
j = n-1
num = n+1
while i < n:
a[i][j]=num
num+=1
i+=1
i = n-1
j = n-1
num = 2* n - 1
while j >=0:
a[i][j]=num
num+=1
j-=1
for... |
f199e0aa6f2cc2206085e445576734d0db8b2b93 | saikrishna6415/python-problem-solving | /numtriangle4.py | 193 | 3.921875 | 4 | n =int(input("enter a number : "))
for i in range(1,n+1):
print(" "*(n-i),end="")
for j in range(1,n-i+1):
if j==1 or j == 1:
print(1,end="")
print() |
8bcde6601d734d0395d1dacb4e8fc795bbd75b94 | saikrishna6415/python-problem-solving | /sumofpairseqnum.py | 264 | 3.609375 | 4 | arr = [1,3,2,3,8,9,5,4,8,10]
number = 6
arr2 = [ ]
k=0
for j in range(len(arr)):
for i in range(len(arr)):
if arr[k] + arr[i]==number:
arr2.append((arr[k],arr[i]))
k+=1
print(list(set(arr2)))
# [(5, 1), (3, 3), (1, 5), (4, 2), (2, 4)] |
5b6418239c5f83fbe41c0bd1c30570d1dfc1938d | saikrishna6415/python-problem-solving | /hshapenum.py | 504 | 3.546875 | 4 | n = int(input("enter a number : "))
a = [[' ' for i in range(n)]for j in range(n)]
for i in range(n):
for j in range(i+1):
a[i][j]= j+1
for i in range(n):
ar=a[i][:n-1]
print(*(a[i]+ar[::-1]) )
for i in range(n-1)[::-1]:
ar=a[i][:n-1]
print(*(a[i]+ar[::-1]) )
# output
# enter a number :... |
321e704bf25e0c0f81772d1a1ec96eaccf02e86d | saikrishna6415/python-problem-solving | /nqueens.py | 2,644 | 3.84375 | 4 | # global N
# N = int(input("enter board size : " ))
# def printSolution(board):
# for i in range(N):
# for j in range(N):
# print (board[i][j], end = " ")
# print()
# def isSafe(board, row, col):
# for i in range(col):
# if board[row][i] == 1:
# return... |
ecebfdebc75273e541cb587fd3c3757a4ea9f76c | saikrishna6415/python-problem-solving | /strinarray.py | 436 | 3.703125 | 4 | s = input("enter a string : ")
s=s.strip()
s1=s.split(" ")
l= len(max(s1, key=len))
a = [[" " for x in range(len(s1))] for y in range(l)]
for i in range(len(s1)):
for j in range(len(s1[i])):
a[j][i]=s1[i][j]
for i in range(l):
print(a[i])
# enter a string : kotagiri saikrishna
# ['k', 's']
... |
eb8e3baaa890325486ebfd78c3dfebdbc2da5106 | saikrishna6415/python-problem-solving | /diagonalstring.py | 658 | 3.671875 | 4 | s = input("enter a string : ")
n = int(input("enter number : "))
if n==1:
print(s)
l=len(s)
row = 0
a = [[" " for x in range(l)] for y in range(l)]
for i in range(l):
a[row][i] = s[i]
if row == n - 1:
down = False
elif row == 0:
down = True
if... |
858edbbb18d40817d7fb56ee56164cda278eb7ae | saikrishna6415/python-problem-solving | /numstar.py | 160 | 3.609375 | 4 | n = int(input("enter number : "))
for i in range(n,0,-1):
print((i)*" "+( str(i)+ " ")*(n-i+1))
# enter number : 4
# 4
# 3 3
# 2 2 2
# 1 1 1 1
|
79a322061721f3e6d991497c3faebd729c1e3137 | winry-fruitiwi/particlesystems | /Emitter.py | 899 | 3.5625 | 4 | # this object represents a class that can emit particles from Particle.py
from Particle import *
class Emitter(object):
def __init__(self, x, y):
self.pos = PVector(x, y)
self.particles = [] # this is a list of all the particles this emitter has.
# this shows the emitter, although th... |
601af2904606d97eb397db5593ea1d1fd369d41b | PrasanthiGummaraju/matrix | /zipmatrix.py | 194 | 3.859375 | 4 | def spiralOrder(arr):
ans=[]
while arr:
ans+=arr.pop(0)[::-1]
arr= (list(zip(*arr)))[::-1]
return ans
arr=[[1, 2, 3],[4,5,6],[7,8,9]]
print(spiralOrder(arr))
|
913f03abb39b003d5ba038a2760988a231ecf03c | baron159/LearningPython | /Lesson 23/Read_Write.py | 320 | 3.71875 | 4 | __author__ = 'Scott'
fw = open('sample.txt', 'w')
fw.write('Write this into the file\n')
fw.write('Scott wrote this line too\n')
fw.close()
fr = open('sample.txt', 'r')
text = fr.read()
print(text)
fr.close()
print('\n')
# TODO write codte here that will print out only the first line of text in the file
print(text) |
1db170c873de17416b6adee602a36d5ab915af6e | zmader/CFHT-2021-Internship-Project | /check_obs_daily.py | 8,154 | 3.609375 | 4 | #using tuples to hold the values for declination, right alignment
from collections import namedtuple
#to use for calculating time since default date
from datetime import date, datetime
#tuples to hold min/max measurements or coordinates
#to change the value of a specific element, use ****._replace(field=val)
#the dec... |
6a295d0ce64bf4a409f0c0162e6e00bc3214571b | sammycosta/uri-python | /uri_1652.py | 999 | 3.640625 | 4 | # URI Online Judge | 1652
L, N = [int(x) for x in input().split()]
irregulares = {} #dicionário
consoantes = "bcdfghjklmnpqrstvwxyz"
for i in range(L): #descrição das palavras irregulares e sua forma plural
singular, plural = input().split() #str
irregulares[singular] = plural
for c in range(N): #input de uma ... |
a34244723982dcb283ae9907e2576c59f0f40025 | sammycosta/uri-python | /uri_1181.py | 501 | 3.578125 | 4 | # URI Online Judge | 1181
# nome: Samantha Costa
L = int(input()) #linha de operação
T = input().upper() # soma ou media
soma, media = 0, 0
matriz = list()
for i in range (12): #faz 12 listas de 12 dentro
matriz.append(list(range(12)))
for linha in range(12):
for coluna in range(12):
matriz[linha][colu... |
75a59b2fff73615002002fb1e566ca1a0c4cb012 | sammycosta/uri-python | /uri_1008.py | 157 | 3.625 | 4 | numero = int(input())
horas = int(input())
porhoras = float(input())
salario = porhoras*horas
print(f'NUMBER = {numero}')
print(f'SALARY = U$ {salario:.2f}') |
84a6d751b05606f22ba9a6b08b0ddbe4699ea3e1 | sammycosta/uri-python | /uri_1168.py | 489 | 3.703125 | 4 | # URI Online Judge | 1168
# nome: Samantha Costa
N = int(input())
leds = 0
for i in range(N):
leds = 0 #zera a contagem
V = input()
for c in V:
if c == '1':
leds += 2
elif c == '2' or c == '3' or c == '5':
leds += 5
elif c == '4':
leds += 4
... |
63f9d4957eae43adc01cc7540f7e44e04f21c5fa | sammycosta/uri-python | /uri_2313.py | 548 | 3.828125 | 4 | # URI Online Judge | 2313
A, B, C = [int(x) for x in input().split()]
if A >= (B + C) or B >= (A + C) or C >= (A + B): # não forma triangulo
print('Invalido')
else:
if A == B == C:
tipo = 'Equilatero'
elif A == B != C or A == C != B or B == C != A:
tipo = 'Isoceles'
elif A != B != C:
... |
3a371745b8f4c72088a6ad2bb6718458d764e032 | sammycosta/uri-python | /uri_1020.py | 180 | 3.65625 | 4 | dias = int(input())
ano = dias // 365
mes = (dias - (ano*365)) // 30
diasr = dias - (ano*365) - (mes*30)
print (f'{ano} ano(s)')
print (f'{mes} mes(es)')
print (f'{diasr} dia(s)') |
92c49e69dac286a3f9b4ee7f6e209f07a5084e49 | Raj-Karan-Tripathi/Sal_model | /Ml_model_on_top_of_docker.py | 900 | 3.765625 | 4 | import pandas as pd
sal = pd.read_csv('SalaryData.csv')
x = sal['YearsExperience'].values.reshape(30,1)
y = sal['Salary']
from sklearn.linear_model import LinearRegression
salmodel = LinearRegression()
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train... |
f95d98f173a64dbc42b97dd6b363a66686038cbd | betpagal/slave | /pycode/main/wheel.py | 383 | 3.625 | 4 | # Helper to give us a nice color swirl
def wheel(pos):
if (pos < 0):
return (0, 0, 0)
if (pos > 255):
return (0, 0, 0)
if (pos < 85):
return (int(pos * 3), int(255 - (pos*3)), 0)
elif (pos < 170):
pos -= 85
return (int(255 - pos*3), 0, int(pos*3))
else:
... |
48e06717e9b7519b63181de3de0afe536c9e71ba | kalyan678/SemanticNetworkStockMarketAnalysis | /scrape.py | 2,925 | 3.578125 | 4 | """
Using NewsAPI:
API Key: 798a9003a6254698ad9117441ce75124
"""
import json
import requests
import csv
import pandas as pd
from newsapi import NewsApiClient
from newspaper import Article
################## Helper Functions ##################
def read_url(url):
"""
Read text from url using Newspaper
"""
article = ... |
7ff73c80c0b6f40366b40349cf46997c30c0c6eb | n3mes15/matasano-cryptochallenges | /challenge1.py | 915 | 3.625 | 4 | import base64
def challenge1():
operation_id = int(raw_input("Please give 1 for base64 to hex or 2 for hex to base64 encoding: "))
if operation_id == 1:
str_result = base64_2_hex()
elif operation_id == 2:
str_result = hex_2_base64()
else:
print "Operation not available."
pri... |
52551aa9b5d16de70d72365e18ffba37b5557b98 | raquelinevr/estruturasdedados | /listaSequencial.py | 4,113 | 3.859375 | 4 | #Aplicando tratamento de exceção em uma lista sequencial
from typing import List
class ListaException(Exception):
def __init__(self, msg):
super().__init__(msg)
class ListaSequencial:
def __init__(self):
self.__dados = []
def vazia(self):
return len(self.__dado... |
2034b70820692cd97091c7743cef644cac488ae5 | TommyHuang-dev/shapeDefense | /functions/waveParse.py | 1,086 | 3.5625 | 4 | # this function parses a map data file for the coordinates and difficulty
def parse_wave_info(file_name):
# setup file and return list
file = open("data/" + file_name, "r")
wave_info = [] # list of lists. Inside each array is the following: [enemy name, amount, delay, interval]
cur_wave = 0
for li... |
10000b439f18c35a9cdfffee484dc5f82a403433 | TommyHuang-dev/shapeDefense | /functions/waveGenerator.py | 2,737 | 3.625 | 4 | import random
valueList = {} # list of [['enemy name', cost], [...]].
# enemyValues file contains the base "cost" to spawn enemies. Higher cost = stronger enemy = less.
# additionally spawning enemies with less delay in between also costs more (default = 1sec)
with open("data/enemyCost", "r") as f:
for line in f:... |
ec35772481efbcee470105edb379c38655b1acc0 | MCCiupek/bootcamp_python | /Module00/ex09/guess.py | 929 | 4.0625 | 4 | import sys
from random import randint
print("This is an interactive guessing game!\n\
You have to enter a number between 1 and 99 to find out the secret number.\n\
Type 'exit' to end the game.\n\
Good luck!\n")
douglas_adams = "The answer to the ultimate question of life, \
the universe and everything is 42."
soluti... |
86a9e79cb7debb677e77cd67d7ea5d43b50be872 | MCCiupek/bootcamp_python | /Module01/ex02/test.py | 1,046 | 3.921875 | 4 | from vector import Vector
import sys
list1 = [0.0, 1.0, 2.0, 3.0]
list2 = [[0.0], [1.0], [2.0], [3.0]]
list3 = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
list4 = ["a", "b", "c"]
vec0 = Vector()
vec1 = Vector(list1)
vec2 = Vector(list2)
# vec3 = Vector(list3)
vec4 = Vector(3)
vec5 = Vector(range(10, 15))
# vec6 = Vector(list4... |
c70923e47f401f1d11aa56d7a8fddb88476e96de | MCCiupek/bootcamp_python | /Module00/ex02/whois.py | 331 | 3.90625 | 4 | import sys
def is_intstring(s):
try:
int(s)
return True
except ValueError:
return False
if len(sys.argv) != 2 or not is_intstring(sys.argv[1]):
sys.exit("ERROR")
n = int(sys.argv[1])
if (n == 0):
print("I'm Zero.")
elif (n % 2) == 0:
print("I'm Even.")
else:
print("... |
89b256585b65aa976f8ed6e3a67cea5b5baa4004 | MCCiupek/bootcamp_python | /Module01/ex05/the_bank.py | 3,680 | 3.59375 | 4 | class Account(object):
ID_COUNT = 1
def __init__(self, name, **kwargs):
self.id = self.ID_COUNT
self.name = name
self.__dict__.update(kwargs)
Account.ID_COUNT += 1
def transfer(self, amount):
self.value += amount
class Bank(object):
"""The bank"""
def __i... |
23c10c9d796aa06c5cfcfa835c53e88536217a85 | Mohammed-Sunasra/029-max-min-dict-values | /build.py | 164 | 3.515625 | 4 | def solution(dic):
l = dic.values()
max_val = max(l)
min_val = min(l)
return (max_val,min_val)
dic = {'a': 1, 'b': 2, 'c': 3}
print solution(dic)
|
034c0e12e6ac9da5e23956a52a1d0ba514b59966 | yangtao0304/python-cookbook | /c1 数据结构和算法/1_11.py | 983 | 3.734375 | 4 | # 命名切片
record = '....................100 .......513.25 ..........'
cost = int(record[20:23]) * float(record[31:37])
print(cost)
# 使用切片
SHARES = slice(20, 23)
PRICE = slice(32, 37)
cost = int(record[SHARES]*record[PRICE])
# 具体使用方法
items = [0, 1, 2, 3, 4, 5, 6]
a = slice(2, 4)
items[2:4]
# [2, 3]
items[a]
# [2, 3]
it... |
2e858bc66ee15035b7eafe8aafb2a3d73da6f7fb | Shruthi007/Pieinfocomm_internship | /add_si.py | 288 | 3.984375 | 4 | #addition
print("\n\nAddition\n\n")
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
print("Sum:",a+b)
#Simple Interest
print("\n\nSimple Interest\n\n")
p=float(input("P="))
r=float(input("R="))
t=float(input("T="))
print("SI=",(p*r*t/100))
|
68d9e9b498aee06efd6302367344789db3c78fdc | Shruthi007/Pieinfocomm_internship | /Set1.py | 336 | 3.890625 | 4 | #Set -> Datatype similar to set in maths
#Doesnot support duplication and indexing
# Represented useing {}
# output is always in random order
a={1,6,5,8,7,9,4,11,5,6,6}
print("a=",a)
b={1,5,7,8,9,4,6,8,10,5}
print("b=",b)
print("a-b=",a.difference(b))
print("a U b=",a.union(b))
print("a intersection b =",a.in... |
55fb04400f63fd52e0c498ec11e722e24f85778d | Shruthi007/Pieinfocomm_internship | /multi_inherit.py | 540 | 3.875 | 4 | class Room:
area = 0
def cal_area(self):
l=int(input("Enter the length of the room in metre:"))
b= int(input("enter the breadth of the room in metre:"))
self.area=l*b
class Cost:
cost=0.0
def acc(self):
self.cost = float(input("Enter the cost for paining one ... |
036e387006d6ef2135fe55b5d8fac167f3b80b5d | daofeng123/ClassCodes | /d09_mongdb_redis_cvs/crawle/mongostorage.py | 823 | 3.53125 | 4 | import pymongo
"""
MongoDB的数据存储
"""
class MongoDBStorage:
def __init__(self):
# 定义服务器数据(参数传递,或者配置文件ini,xml,json,csv)
self.__host = '127.0.0.1'
self.__port = 9988
# self.__user = ''
# self.__password = ''
# 直接链接
self.__client = pymongo.MongoClient(host=... |
4ab3cdc7317c34e1b15309da948c248189811658 | daofeng123/ClassCodes | /d15_plot_axes/p02_ndarray_shape.py | 774 | 3.828125 | 4 | import numpy as np
# 一组类型相同的元素:ndarray(数据集) : 类型不同的元素:DataFrame(记录)
m = np.array([
[
[1, 2, 3, 4],
[3, 4, 5, 6],
[5, 6, 7, 8]
],
[
[1, 2, 3, 4],
[3, 4, 5, 6],
[5, 6, 7, 8]
],
[
[1, 2, 3, 4],
[3, 4, 5, 6],
[5, 6, 7, 8]
],
])... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.