blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
fce68e45db6a71d3c66ca086addf06afde31d901 | AlGaRitm2020/Algorithms_training_Young_Yandex | /1_Complexity_and_testing_and_special cases/D_equation_with_ the_root.py | 744 | 3.84375 | 4 | a, b, c = (int(input()) for _ in range(3))
# 0 0 0 +
# 0 0 1 +
# 0 1 0
# 0 1 1
# 1 0 0
# 1 0 1
# 1 1 0
# 1 1 1
if c < 0:
print('NO SOLUTION')
elif c == 0:
if b == 0:
if a == 0:
print('MANY SOLUTIONS')
else:
print(0)
elif a == 0:
print('NO SOLUTION')
else:... |
ba70e435756d4e2247eb1e14026607b1cc8a23db | icescrub/code-abbey | /rotate_string.py | 677 | 3.546875 | 4 | def f():
with open('C:\\Users\\Duchess\\Desktop\\Data.txt') as data:
for line in data:
rot, word = line.split()
rot = int(rot)
lst = [c for c in word] # Manipulate string as list, which is easier.
if rot < 0:
lst.revers... |
66c9d91f52170d473f6a252b9cd30520e9b39096 | WokLibCodeClub/Rock-Paper-Scissors-with-Turtles | /Template/step1-3.py | 2,143 | 3.640625 | 4 | from turtle import *
from random import randint
from time import sleep
from sys import exit
#############################################
# VARIABLES
#############################################
screen = Screen()
setup(800,700)
screen.register_shape("computer_rock.gif")
screen.register_shape("computer_paper.gif")
s... |
0931098ba5ba029e28cb1e0237b1141f7ee8f223 | PaulChirlikov/first-repo | /key_value.py | 378 | 3.9375 | 4 | #Написать программу, которая берет словарь и меняет местами ключи и значения
distionary ={'name': 'Channing', 'surname': 'Tatum'}
for key in distionary:
print(key, distionary[key])
new_distionary = {value:key for key, value in distionary.items()}
for key in new_distionary:
print(key, new_distionary[key])
|
223a5c5880ffcde76b908d9c50471262265605cc | wenzhe980406/PythonLearning | /day16/WangShoot.py | 6,133 | 3.515625 | 4 | # _*_ coding : UTF-8 _*_
# 开发人员 : ChangYw
# 开发时间 : 2019/8/5 21:52
# 文件名称 : WangShoot.PY
# 开发工具 : PyCharm
'''
#1. 创建老王对象
#2. 创建一个枪对象
#3. 创建一个弹夹对象
#4. 创建一些子弹
#5. 创建一个敌人
#6. 老王把子弹安装到弹夹中
#7. 老王把弹夹安装到枪中
#8. 老王拿枪
#9. 老王开枪打敌人
#10. 召唤电脑选手
'''
#玩家
import random
clip_num = 30
... |
ad950dc7687f1ee46f10dc86b0bd3b1475d0d9e4 | sujin16/studycoding | /level_3/int_triangle.py | 575 | 3.515625 | 4 | def solution(triangle):
for i,tri in enumerate(triangle):
if i ==0:continue
for j in range(len(tri)):
if j ==0:
triangle[i][j] += triangle[i-1][0]
elif j ==len(tri) -1:
triangle[i][j] += triangle[i-1][-1]
elif triangle[i-1... |
e67454f08fcd0336612388fc96270ce57ea57617 | rechhabra/Cattis | /unlockpattern.py | 409 | 3.515625 | 4 | from decimal import Decimal
pad = [list(map(int, input().split(" "))) for i in range(3)]
def computeD(n):
nx,ny=0,0
dx,dy=0,0
for i in range(3):
for j in range(3):
if pad[i][j]==n:
nx,ny=i,j
elif pad[i][j]==n+1:
dx,dy=i,j
return Decimal(((dx-nx)*(dx-nx)+(dy-ny)*(dy-ny))**0.5)
pri... |
c1bcbd7bd8fe85608a3d0289d2429885012189c3 | saurabhchris1/Algorithm-Pratice-Questions-LeetCode | /Remove_Vowels_from_a_String.py | 477 | 3.671875 | 4 | # Given a string S, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string.
#
# Example 1:
#
# Input: "leetcodeisacommunityforcoders"
# Output: "ltcdscmmntyfrcdrs"
# Example 2:
#
# Input: "aeiou"
# Output: ""
class Solution:
def removeVowels(self, S):
dict = {'a': 'a', 'e': 'e', ... |
589400a64f393a3517f861913b041fb3df6f4d3e | ayz73/testl | /classes learning/test_fractions_class.py | 2,400 | 3.734375 | 4 | import unittest
from fractions_class import Fraction
import fractions_class
class fractions_class_test(unittest.TestCase):
def test_gcf(self):
self.assertEqual(fractions_class.gcf(78, 66), 6)
self.assertEqual(fractions_class.gcf(10, 0), 0)
self.assertEqual(fractions_class.gcf(-100, -5), -5)... |
ca532af18a83a578a9d41b71d37d2bf140276f7f | bostonbrad/Codility_Python | /Binary_Gap.py | 1,882 | 4.21875 | 4 | """
Task: BinaryGap
Goal: Find longest sequence of zeros in binary representation of an integer.
Website: https://app.codility.com/programmers/lessons/1-iterations/binary_gap/
-----------------------------------------------------------
A binary gap within a positive integer N is any maximal sequence of
consecutive ze... |
469dacf6949a53af582464c94a41596b3951351c | AG3X29M4Nc5DJN0-FNkr5MSgiwR4YxBz/course-AI | /assignment2/knowledgeAgent.py | 7,262 | 3.5 | 4 | from logic import *
from utils import *
from exploration import *
#import time to test performance
import time
#A knowledge base for a wumpusWorld
class wumpusKB():
def __init__(self, wumpusWorld):
self.kb = PropKB()
#Add in the KB basic information
#No pit and wumpus at (0,0)
... |
0749311554fd775da25a2b9975209a20d00efd84 | xxxsssyyy/offer-Goal | /21栈的压入、弹出序列.py | 1,446 | 3.640625 | 4 | # coding:utf-8
class Solution:
def IsPopOrder(self, pushV, popV):
# write code
if pushV==[]:
return True
#https://www.cnblogs.com/xueli/p/4952063.html
# 直接赋值:python中对象的赋值是对象的引用,当把它赋值给另一个变量时,并没有拷贝这个对象
# copy浅拷贝:没有拷贝子对象,所以原始数据改变,子对象会改变
# 深拷贝:包含对象里面的自对象的拷贝,所以... |
19e7386806f2830f225077700037f320f37914a4 | vladvlad23/UBBComputerScienceBachelor | /FundamentalsOfProgramming/Assignment 05-07/operations/statistics.py | 5,882 | 3.53125 | 4 | from movie import searchMovieWithId,getBiggestMovieId
from client import searchClientById
from rental import searchRentalWithId
from dateOperations import *
def moviesDescendingByRentingTimes(movieList,rentalList):
'''
Procedure : will create a list counting how many times each movie has been rented and then
... |
2778abbc231790d01db39a5d0fab6ddc6fa9be28 | theIncredibleMarek/algorithms_in_python | /merge_sort.py | 1,769 | 4.28125 | 4 | #!/usr/bin/env python3
import math
def sort(input, ascending=True):
print("Original: {}".format(input))
print("Ascending sort: {}".format(ascending))
# empty and one item lists are considered sorted
if((len(input)) <= 1):
return input
output = mergesort(input, ascending)
return outpu... |
a46ef724946453086c4bb2935a7f202da514669f | RobertoChapa/Python_OOP_Example | /ProceduralProgramming.py | 538 | 3.515625 | 4 | def main():
product1 = 'Milwaukee Drill Gun'
price = 129.99
discountPercent = 5.0
da = discountAmount(price, discountPercent) # discount amount
dp = discountPrice(price, da) # discount price
print(product1, " Discount Price: ${:.2f}".format(dp))
return
def discountAmount(pr... |
02abbfd54d67e90ee305b4ca36d57de3d4d8b5a6 | caliche22/ADA | /Tarea3/install.py | 1,626 | 3.609375 | 4 | from sys import stdin
from math import *
# Carlos Arboleda ADA Camilo Rocha
# Install
# se hace uso de Activity Scheduling de la clase y se saca un arreglo con el numero de radares x-d y x+d
#donde d es uno de los catetos del triangulo es decir se hace uso de la libreria math para calcularlo
# con pow y sqrt y sus r... |
032ab21c048c41519e1a6bf8b22b50a292692e60 | NeilWangziyu/Leetcode_py | /isSymmetric.py | 2,066 | 3.921875 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def isSymmetric_old(self, root):
"""
:type root: TreeNode
:rtype: bool
"""
list_left = []
def retu... |
db4a9351de478356132afdf75ffea7286a6bbe89 | saroj1017/Python-programs | /hangman/hangman-code.py | 4,541 | 4.28125 | 4 | import random
from hangman_art import stages, logo
from hangman_words import word_list
from replit import clear
# clear is module in replit platform you can use other modules to clear the data
#prints the logo from the module hangman_art
print(logo)
# itiallly sets set a varibale that points to false and upon some ... |
7fa8e2f20fdabfc468b3929bbdf0e7817a71b1dd | ewilson/codeclubstarters | /hangman/hangman.py | 680 | 3.921875 | 4 | secret = ''
correct_letters = []
missed_letters = []
def check_letter(letter):
in_word = letter.upper() in secret
if in_word:
correct_letters.append(letter)
else:
missed_letters.append(letter)
return in_word
def hide_word():
display = []
for letter in secret:
if _lett... |
cd3276e4fd92c661999b531959916c606ba56d27 | SachinMadhukar09/100-Days-Of-Code | /08.Circular Linked Lis/Day 40/22 August 02 Insert at Beginning.py | 219 | 3.703125 | 4 | def insertBeg(head,x):
temp=head(x)
if head==None:
temp.next=temp
return temp
curr=head
while curr.next!=head:
curr=curr.next
curr.next=temp
temp.next=head
return temp |
be524a5d888aaf6509b3cfd872d87d3c43fa6d60 | daniel-reich/turbo-robot | /ub2KJNfsgjBMFJeqd_15.py | 2,514 | 4.28125 | 4 | """
In this challenge we're going to build a board for a **Minesweeper** game
using **OOP**. Create two classes: `Game` and `Cell`.
`Game` should take in 3 arguments: number of **rows** , number of **columns**
and total number of **mines** , set the default values to 14, 18 and 40
respectively. Each instance should... |
c363c60b22cda2cdae00e211becffdb188889621 | diogo55/OnlinePythonTutor | /v3/tests/doctest-tests/lab1.py | 2,859 | 3.640625 | 4 | '''
# My first Labyrinth lab
This is the lab description -- write whatever you want in here in
*markdown* format and it will show up as the toplevel docstring for this module
- shawn
- is
- cool
1. code code code
2. write paper
3. profit $$$
woohoo!
'''
def factorial(n):
"""
Lab part 1
lab descript... |
2dacb9a42546cce32d7f7c6d230b279df4e615c5 | PaGr0m/Courses-FogStream- | /Practice 2/List_2.2.py | 322 | 3.84375 | 4 | # lst = list(input("Enter the numbers"))
lst = [1, 1, 1, -2, 2, -3, -23, -23, -23]
myList = list()
# for index in range(0, len(lst) - 1):
# if ((lst[index] > 0 and lst[index + 1] > 0) or
# (lst[index] < 0 and lst[index + 1] < 0)):
# myList.append([lst[index], lst[index + 1]])
# print(myList[0]... |
a40807c41bede478cde0b09e929186c1bf5a93b1 | pardo13/python | /Practica 1 E3.py | 97 | 3.90625 | 4 | N=int(input("dame int"))
if (N%2==0):
print ("Si es par")
else:
print ("No es par")
|
14fdc47e0da036c1cda4ceecfa644e45c17900c9 | kmdtty/ucspp | /98-Graph/small-world/graph.py | 1,435 | 4.03125 | 4 | """
Example
-------
% more tinyGraph.txt
A B
A C
C G
A G
H A
B C
B H
% python graph.py < tinyGraph.txt
A B C G H
B A C H
C A B G
G A C
H A B
"""
import sys
import itertools
from collections import defaultdict
class Graph():
def __init__(self, f=None, delimiter=" "):
"""Create graph from a file
f -- input... |
866da6d7a9723faa21b8299c8e85579c6618b371 | thirukkumaransv/progarmming | /character.py | 94 | 3.765625 | 4 | ch = input(" ")
if(ord(ch) >= 97 and ord(ch) <= 122):
print("Alphabet")
else:
print("No")
|
153e36ad840072bf79f2108547db1145c67f1aaf | shoni1/sr6 | /sr6..py | 653 | 3.609375 | 4 | try:
n = int(input('Введите кол-во элементов массива: ')) #Кол-во элементов массива
a = [] #Создаем массив
for i in range (n):
a.append(int(input('Введите массив: '))) #Заполняем его
delta = int(input('введите delta: ')) #Вводим дельту
counter = 0 #Создаем счетчик отличающихся элементов
... |
c10a2a1eba6a09bf5cdf8337aa0dbe4bc7c93cc4 | qagroup-py/python-october-2016-test-Olhaa | /OOP_food.py | 1,174 | 3.8125 | 4 | # coding: utf-8
"""
Implement class structure/hierarchy for following classes:
Basil (базилік)
Beetroor (буряк)
Blueberry (чорниця)
Cabbage (капуста)
Carrot (морква)
Concorde (pear) (груша "Конкорд")
Dill (кріп)
Domestic strawberry (полуниця)
Golden delicious (apple) (яблуко "Голден")
Granny Smith (apple) (... |
3652cf23194b2709a49b61009c83b7b5dd81e74e | akueisara/leetcode | /P147 Insertion Sort List/solution.py | 1,218 | 4.03125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
# https://en.wikipedia.org/wiki/Insertion_sort
# If's often to preform this algo using an Array, here we use a linked list
# Insertion Sort A... |
40df232bad72079919295e9587d7333cc3c86990 | assassint2017/leetcode-algorithm | /Sum of Left Leaves/Sum_of_Left_Leaves.py | 798 | 3.890625 | 4 | # 64ms 65.08%
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def sumOfLeftLeaves(self, root):
"""
:type root: TreeNode
:rtype: int
"""
... |
ebd59d0e8f04b60c76fca5b73892b88cff67206e | CollinErickson/LeetCode | /Python/109_SortedListToBSTv2.py | 2,595 | 3.96875 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def __repr__(self):
s = "(" + str(self.val)
n = self.next
if n is None:
return s + ")"
#print('s', s, n.val)
while n ... |
5b573db3eed92b7c7a82af5cb1f942e5c3c9ebb9 | deepankerkoul/SudoPlacement19 | /Week 1/Arrays and Searching/Immediate Smaller Number.py | 1,511 | 3.96875 | 4 | '''
Immediate Smaller Element
Given an integer array of size N. For each element in the array, check whether there exist a smaller element on the next immediate position of the array. If such an element exists, print that element. If there is no smaller element on the immediate next to the element then print -1.
Input... |
43c201ead0f36f47e74b7287614f209b4452ea4e | xiaolinian/myCodeAboutCourse_PythonFundamental | /temp/CostCal.py | 359 | 3.828125 | 4 | # 假设每考一次试的费用为X,每次考试通过的概率为P1.求考试通过的成本的数学期望。
def totalcost(X,P1):
totalcost=0
for i in range(1,100):
#print(i)
costith=X*i*P1*pow(1-P1,i-1)
#print(costith)
totalcost+=costith
print(totalcost)
totalcost(4500,0.95)
totalcost(2500,0.4)
|
d7ed1986a0650f43d04e7007ace1219085e8b367 | adsl305480885/leetcode-zhou | /922.按奇偶排序数组-ii.py | 1,704 | 3.5 | 4 | '''
Author: Zhou Hao
Date: 2021-01-28 17:23:23
LastEditors: Zhou Hao
LastEditTime: 2021-01-28 21:16:22
Description: file content
E-mail: 2294776770@qq.com
'''
#
# @lc app=leetcode.cn id=922 lang=python3
#
# [922] 按奇偶排序数组 II
#
# @lc code=start
class Solution:
#方法一:奇偶分开再遍历合并
# def sortArrayByParityII(self, ... |
50062c0fe2708bcb0a3abca2a52d3a932fec4ec1 | mrmuli/bootcamp_9_ke | /toy_problems/fibonacci.py | 647 | 3.8125 | 4 |
def fibby(n):
# initialize two counter vaiables
a, b = 0, 1
# create a new list to hold sequence
my_list = [1]
# loop through range of 0 and input
for i in range(0,n):
# fibonacci sequence moderator
# num is a placeholder for the original value of a
num = a
# a is assigned the value of b in the ad... |
67e2c400c8718037fab67dfa60dcabb0e67a537c | hyunbeen/python--training | /list/sample4.py | 934 | 4.09375 | 4 | #list/sample4.py
#리스트 연산
a=[1,2,3,4,5]
b=[5,7,8,9,10]
# -,/ 연산은 지원되지 않는다
print("---------------------------------------------");
result = a + b
print(result)
result = a * 2
print(result)
leng = len(result)
print(leng)
# print(a[3]+"hi"); error 강제 형변환 시켜야된다
print("---------------------------------------------");
prin... |
16f8a7df398b466fe71ab06c0c2b90a15653f112 | Vladimyr23/Python-Exercises | /w2prog1.py | 878 | 3.734375 | 4 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Vlad
#
# Created: 15/02/2016
# Copyright: (c) Vlad 2016
# Licence: <your licence>
#-------------------------------------------------------------------------------
len... |
b3963f8d076c4590caf29c7311014324abf7f079 | Edersheckler/Automatas2 | /CalcularAreas.py | 699 | 3.9375 | 4 | import math as mat
#---------------------
# funcion para calcular area
#--------------------------
def calcularArea(r):
area = mat.pi*(mat.pow(r,2))
return area
def calcularDiametro(d):
diam = d*2
return diam
def main():
ciclo = True
while ciclo == True:
print ('Script para calcular area de circunferencia')... |
aec0260b73b27752601eb68be633f37357c1821b | Aasthaengg/IBMdataset | /Python_codes/p03130/s902576013.py | 335 | 3.515625 | 4 | from collections import defaultdict
dic = defaultdict(int)
for i in range(3):
p,q = map(int,input().split())
dic[p] += 1
dic[q] += 1
#print(dic)
L = []
for v in dic.values():
L.append(v)
odd = [x%2 ==1 for x in L]
even = [x%2 ==0 for x in L]
if sum(odd) == 2 or sum(even) == 4:
print("YES")
else:
... |
778d98836c0f3b686dadb9a2bdc4629efa5af5ff | Darlan-Freire/Python-Language | /exe70 - Estatísticas em produtos.py | 936 | 3.828125 | 4 | #Crie um prog que leia o NOME e o PREÇO de VÁRIOS PRODUTOS.
#O prog deverá perguntar se o USUÁRIO vai continuar.
#No final, mostre:
# (a) Qual é o TOTAL DE GASTO na compra.
# (b) Quantos produtos custam MAIS de R$1000.
# (c) Qual é o NOME do produto mais BARATO.
total = MaiorMil = menor = cont = 0
produto = ' '
... |
76e6413ec1d805f7889212e90f3da825a01e2d7b | sandhyalethakula/Iprimed_16_python | /Aug-23 Assign Ocollections prathyusha.py | 5,305 | 4.15625 | 4 | '''
Code based assessment
````
1.Question
A student has joined a course costing as per the given table.
If the fee is paid via card, an additional service charge of Rs. 500/- is added but if payment is made through e-wallet, a discount of 5% is given for the payment.
Use this reference table:
python 15000
j... |
3513ef10e8e8f7d62b66fdedb87a9b8c3b631b05 | liguanghe/test2 | /try/ex15-test.py | 714 | 3.984375 | 4 | # 用 argv参数变量, 获取文件名。 解包为命令名和文件名
from sys import argv
script, filename = argv
# open是一个命令,跟脚本、input等命令类似,接受一个参数,返回一个值,讲这个值赋予一个变量。
# 在txt上调用了open这个函数 用等号,并且文件名也有txt
print ("Here's your file %r" % filename)
# 用. 后面是命令,无需任何参数
print (txt.read())
print ("Type the filename again:")
# 赋值,文件是输入的文件名
file_again = input("> "... |
c2e90893e27b289c7432be18d897bc53e8037b16 | wan-catherine/Leetcode | /problems/RotateArray.py | 739 | 3.5625 | 4 | class Solution(object):
def rotate_old(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
"""
if nums == None or len(nums) < 2:
return
l = k % len(nums)
if l == 0:
... |
cb0f30cf0cf9081f4b90c9f44c3307bb6d139edd | LukeBreezy/Python3_Curso_Em_Video | /Aula 21/Aula 21b.py | 779 | 4.03125 | 4 | def linha():
print('\033[1;33m=-' * 50, '\033[0m')
# =-=-=-= RETORNANDO VALORES (return) =-=-=-=
# Ao usar um return em uma função, podemos utilizar no escopo global, o valor gerado por ela
def soma(a=0, b=0, c=0):
s = a + b + c
return s
res = soma(10, 5, 2)
print(res)
linha()
print(f'Foram realizada... |
08b0c566c53a599e6335cc8cef0b9811afa0606e | srinijadharani/DataStructuresLab | /01/01_g_swap_numbers.py | 367 | 4.3125 | 4 | # 1g. Program to swap two numbers
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
print("The numbers before swapping are - num1: {} and num2: {}." .format(num1, num2))
# logic for swapping two numbers
num1, num2 = num2, num1
print("The numbers after swapping are... |
503a6763fb8f899e13252b931958984e2be48d74 | JoeyShepard/RobotGame | /c/pre-reorganization/bin2hex.py | 1,616 | 4.0625 | 4 | """
Short script to convert to hex format
THIS IS NOT A GENERAL PURPOSE UTILITY!
"""
import sys
print("Generating hex file...")
try:
address=int(sys.argv[1],16)
except:
print(" Error: bad or missing address - "+sys.argv[1])
sys.exit()
try:
read_file=open(sys.argv[2],mode="rb")
except:
print(" ... |
bbc812b024751f8ecfbe3a270ecbf90710fd4f76 | yunyuntsai/Computer-Vision-HW | /hw3/code/get_tiny_images.py | 1,686 | 3.65625 | 4 | from PIL import Image
import pdb
import numpy as np
from numpy import linalg as LA
def get_tiny_images(image_paths):
'''
Input :
image_paths: a list(N) of string where where each string is an image
path on the filesystem.
Output :
tiny image features : (N, d) matrix of resized an... |
98598d717e875d9a0bb27de6ca314c395846ef8f | houyinhu/AID1812 | /普通代码/practice/达内/python/day10/function_as_args2.py | 297 | 3.734375 | 4 |
# def goodbye(L):
# for x in L:
# print("再见:",x)
#
# def operator(fn,L):
# fn(L)
#
# operator(goodbye,['Tom','Jerry','Spike'])
def myinput(fn):
L = [1,3,5,7,9]
return fn(L)
print(myinput(max))
print(myinput(min))
print(myinput(sum))
|
b2656a3e30f634e5949dd4b961c99a422c900d27 | joelb-2011/Estructura-de-Datos-UNEMI | /Ejercicio 9 - Numeros Iguales.py | 651 | 4.09375 | 4 | class Condicion:
def __init__(self,n1,n2):
self.numero1=n1
self.numero2=n2
numero = self.numero1+self.numero2
self.numero3=numero
def Condicion(self):
if self.numero1 == self.numero2:
print("El Numero 1: {} y Numero 2: {} son iguales".format(self.n... |
2bb679e0c5ead6d3d2889acc916584aed2461ced | rohitjain994/Leetcode | /amazon/get-intersection-node.py | 1,070 | 3.65625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
# 2-pointer streatgy
h1 = headA
h2 = headB
while h1!= h... |
54d19bedf6e9bf0b5a3e70eca985fe6fdc9acbf6 | MihoKim/bioinfo-lecture-2021-07 | /bioinformatics/bioinformatics_2_5.py | 364 | 3.625 | 4 | # 두 개의 문자열 s1과 s2를 입력받아 s1의 길이가 홀수이고 s2보다 짧으면 s1, s2의 순서로 출력하고,
# 그렇지 않으면 반대 순서로 출력하는 프로그램을 완성하시오.
s1 = str(input("Enter s1: "))
s2 = str(input("Enter s2: "))
if len(s1) % 2 == 1 and len(s1) < len(s2):
print(s1 + s2)
else:
print(s2 + s1)
|
14eb0117f986d979f4e9d20b5d4f78bcd01b83f1 | eduardoramirez/Microsoft-Coding-Challenge | /NDrome/NDrome.py | 1,228 | 3.53125 | 4 | import sys
def isEqual(m,n):
length = len(n)
for i in range(0, length):
if m[i] != n[i]:
return False
return True
def isPali(n):
return n == n[::-1]
##str = raw_input("String: ")##sys.stdin.read(1)
inputs = ["ab|1",
"123456123455|6",
"123456789987654321|9",
"1234abcd|4",
"1234567891234... |
7d187493194b49c93692f47ef1b6906e5dd5efea | QingxinL/MIT-6.00.1x | /ProblemSet/ps6/test.py | 758 | 3.875 | 4 | import string
print(type(string.ascii_lowercase))
def build_shift_dict(shift):
map_cipher = {}
# string.ascii_lowercase
# string.ascii_uppercase
# the key is the origin letter
# the value is the letter after
letters = string.ascii_uppercase + string.ascii_lowercase
for char in letters:
... |
024972a13a4a8bd2e20ec9838e14028744747339 | sweetrain096/rain-s_python | /programmers/level 1/04_k번째수.py | 282 | 3.640625 | 4 | def solution(array, commands):
answer = []
for cnt in range(len(commands)):
i, j, k = commands[cnt]
answer.append(sorted(array[i - 1 : j])[k - 1])
return answer
result = solution([1, 5, 2, 6, 3, 7, 4], [[2, 5, 3], [4, 4, 1], [1, 7, 3]])
print(result) |
5c6d0377189e76affd18213cbe7b5e3414511f6a | gourav47/Let-us-learn-python | /83 Data Hiding.py | 1,433 | 4.34375 | 4 | class Test:
x=10 #static, visible from outside the class
__h=20 #static, hidden variable
print(Test.x)
#print(Test.__h)
#it will print x as 10 but will give error for __h as it gets hidden because of the prefix.
#here what python actually does is, it change the hidden variable name internally
#it adds ... |
7af22abde98a13b89bdcec4e50e56476b5b96bb5 | aseemchopra25/Integer-Sequences | /Central Binomial Coefficients/Central Binomial Coefficient.py | 713 | 3.5625 | 4 | ########################################
### Central Binomial Coefficient ###
########################################
#Example : 1, 2, 6, 20, 70, 252, 924, 3432 ....
#Formula : Check Wikepedia
def coeff(n,k):
c = [[0 for i in range(k+1)] for j in range(n+1)]
for i in range(n+1):
... |
a540865f500c0c5d28f1b2407d9a688ff0556c10 | jainilp/Python-Projects | /Ball and Block Game/block.py | 1,366 | 3.5625 | 4 | '''
Name: Jainil Patel
Drexel ID: jbp85
Purpose: This class was used to create the blocks, the user hits.
'''
#imports abstract base class drawable
from drawable import *
#Creates block class
class Block(Drawable):
#Initializes the variables passed in when creating a block object
def __init__(self,x,y):
... |
3aae8f998e169d2b8c52f07e7e3b8ad9a7e7fa27 | swarnanjali/pythonproject | /tr1h.py | 129 | 3.515625 | 4 | t = int(input(""))
s = 1
for i in range(t):
st = ""
for x in range(0,s):
st+="1 "
print(st.strip())
s+=2
|
2c3e73d7351bca34aee3094bb6804e00f51c7992 | Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021 | /answers/vjha21/Day12/question2.py | 593 | 4.125 | 4 | """Count number of substrings that start and end with 1
if there is no such combination print 0
"""
def generate_substrings(string):
sub_strings = [
string[i:j] for i in range(len(string)) for j in range(i + 1, len(string) + 1)
]
return sub_strings
def count_substrings(sub_string):
count... |
eb0267553457299c22d7d2c0c0ef3705cd8e60ca | yzl232/code_training_leet_code | /Reconstruct Itinerary.py | 2,927 | 4.0625 | 4 | '''
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.
Note:
If there are multiple valid itineraries, you should return the itinerar... |
c1817cf0fdc22dfedf1f0f003d55ce0bc7774409 | ekta1007/Hello-world | /Logistic_regression_python.py | 7,149 | 3.796875 | 4 | # Running a logistic regression in Python
#code source from http://blog.yhathq.com/posts/logistic-regression-and-python.html
import pandas as pd
import statsmodels.api as sm
import pylab as pl
import numpy as np
def cartesian(arrays, out=None):
"""
Generate a cartesian product of input arrays.
Parameter... |
664487a49ba571f7bd77744fab3fa6f6de554f9a | pwicks86/adventofcode2020 | /13/2.py | 552 | 3.53125 | 4 | from math import gcd
import math
with open("input.txt") as f:
data = f.readlines()
def lcm(a, b):
return abs(a*b) // math.gcd(a, b)
busses = [(int(b), ind) for ind, b in enumerate(data[1].split(",")) if b != "x"]
base_bus = busses[0]
base_amt = 0
n = 1
mult = base_bus[0]
for bus in busses[1:]:
while Tru... |
31bcaef5cfe9d0e3a5280ce1a4bc65e63bef46c2 | StardustGogeta/Math-Programming | /Python/Unfinished/Euler/187/sieve.py | 1,428 | 3.515625 | 4 | import math, time
##def prime(n):
## for d in range(2, math.floor(math.sqrt(n))+1):
## if not n % d: return False
## return True
##
##def primeSieve(N):
## allNums = range(2, N)
## primes = []
## for n in allNums:
## passing = True
## for p in primes:
## if p > math.sqrt(n... |
a120c20ade6ab2868a5df51baac30b91eb0b4ab3 | EMIAOZANG/leetcode_questions | /285_inorder_successor_in_BST/main.py | 1,476 | 4.1875 | 4 | '''
how to PASS BY REFERENCE using python:
just use an mutable object, e.g. if you want to pass a reference, wrap the object in a list, and then pass the list as a function, then modify the object by list subsctription
IDEA:
Consider 2 cases:
1) if p has rightChild: then the successor is the leftmost node... |
5d801eae8b52f2e4b26b81bd0f972da93719a68b | xzpjerry/learning | /Coding/playground/general/recurrsive/recurrsively_reverse_str_join.py | 508 | 3.953125 | 4 | #!/usr/bin/env python3
'''
Author: Zhipeng Xie
Topic:
Effect:
'''
import re
def reverseStr(astr):
if len(astr) == 1:
return astr
else:
return astr[1:] + astr[0]
def isPalindrome(astr):
astr = ''.join(re.split(r'[\s\'\;\.\-]', astr)).upper()
print(astr)
if len(astr) <= 1:
... |
406ad445384ed1092863f51f1af4686236e91fde | mattyr3200/Dice-Game | /Game.py | 7,499 | 3.9375 | 4 | from PlayerClass import Player
import sys
import random
import re
def add_new_player():
with open('Players.txt', 'a+') as player_file:
new_player = Player((input("username:\n")), "")
while True:
new_player.password = input("Password:\n")
if len(new_player.password) not in ra... |
210906e7cc0a4c955305425b98d76a76a52d80e3 | tfarnecim/BenchmarkApp | /BenchmarkApp/LINEAR - SEM ORDENAÇÃO.py | 848 | 3.6875 | 4 | import time
import random
# Adicionar as funções de Ordenamento e Pesquisa.
def SemOrdenacao(lista):
pass
def BuscaLinear(lista, item):
comp = 0
posicao = -1
for i in lista:
posicao+=1
comp += 1
if(i == item):
break
print("comparacoes da busca: %d... |
b5cf73ac080d46588d00ce063156842120d49f2b | ceciless/python | /sTD4/MulListe.py | 2,690 | 4.4375 | 4 | # -*-coding:Latin-1 -*
# etude multiplication et addition de liste point point
class ListMul(list):
# constructeur
def __init__(self,Maliste):
super(ListMul,self).__init__(Maliste)
#ou encore
#list.__init__(self,Maliste)
# ou encore
#se... |
4b44b9abfe6217c6df5e41a434c56100ef2aac0d | 15194779206/practice_tests | /A_Project/Student_project/student_controller.py | 3,627 | 3.640625 | 4 | '''
class StudentManagerController:
"""
学生逻辑控制器
"""
def __init__(self):
self.__stu_list = []
@property
def stu_list(self): #做成只读属性
return self.__stu_list
def add_student(self, stu):
stu.id =self.__generate_id()
self.__stu_list.append(stu)
... |
ef4aa9f32e31f4e105555ea629e699c2c3be28b9 | tamimio/digdes | /py_test/test_3_encrypt.py | 827 | 3.828125 | 4 | alphabet = 'abcdefghijklmnopqrstuvwxyz'
symb=' .,!?:;"-+=)(*&^%$#@[]{}\/|'
offset = int (input ("Input offset -> "))
orig_txt = input("Input text -> ")
orig_txt=orig_txt.lower()
enc_txt=""
dec_txt=""
print("Offset: ", offset)
print ("Original text: ", orig_txt)
for i in range(0, len(orig_txt)):
if symb.find(orig_t... |
458044d826ad100477969ad1b392d7c4fadb3eac | maeng2418/algorithm | /15-2_그래프_탐색.py | 322 | 3.6875 | 4 | def graph_search(g, start):
if len(g[start]) == 0:
return
for i in range(len(g[start])):
print(start, ' -> ', g[start][i])
for i in range(len(g[start])):
graph_search(g, g[start][i])
g = {
1 : [2, 3],
2 : [4, 5],
3 : [],
4 : [],
5 : []
}
graph_search(g, ... |
12a70b68881d3f1cdb83d235678a9935f76bb702 | huhudaya/leetcode- | /LeetCode/355.设计推特.py | 5,998 | 3.859375 | 4 | # 355涉及推特.py
'''
'''
# 例子
'''
class Twitter {
/** user 发表一条 tweet 动态 */
public void postTweet(int userId, int tweetId) {}
/** 返回该 user 关注的人(包括他自己)最近的动态 id,
最多 10 条,而且这些动态必须按从新到旧的时间线顺序排列。*/
public List<Integer> getNewsFeed(int userId) {}
/** follower 关注 followee,如果 Id 不存在则新建 */
public voi... |
eea969191ab19b1450c0d732e7953c5984400df7 | syurskyi/Python_Topics | /125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/119_v2/xmas.py | 493 | 4.09375 | 4 | def generate_xmas_tree(rows=10):
"""Generate a xmas tree of stars (*) for given rows (default 10).
Each row has row_number*2-1 stars, simple example: for rows=3 the
output would be like this (ignore docstring's indentation):
*
***
*****"""
star = "*"
max_length = rows * 2 -1
... |
80b910c4790d71ac0d402eed0af17493bd1ce207 | EHOTIK911/Inform-EGE | /25/25.18.py | 740 | 3.515625 | 4 | """
(№ 3982) Найдите все натуральные числа, N, принадлежащие отрезку [100 000 000; 300 000 000],
которые можно представить в виде N = 2**m•7**n, где m – нечётное число, n – чётное число.
В ответе запишите все найденные числа в порядке возрастания, а справа от каждого числа – сумму m+n.
"""
a = []
for i in range(10000... |
bca7f346b2ada7aabc8b6792e93a90d09ea37ce5 | esphill/course | /PA5/crack.py | 6,946 | 3.96875 | 4 | # CSE 130: Programming Assignment 5
# crack.py
# Jay Ceballos
# A09338030
# jjceball@ieng6.ucsd.edu
from misc import *
import crypt
def load_words(filename,regexp):
"""Load the words from the file filename that match the regular
expression regexp. Returns a list of matching words in the order
they... |
2d8fb9f3a10c7620447f7ea68ff6f2680064386c | Tijzz/ComptencyAnalysisTool | /SpeechToText.py | 3,780 | 3.59375 | 4 | # importing libraries
import speech_recognition as sr
import os
import csv
from pydub import AudioSegment
from pydub.silence import split_on_silence
from pydub.silence import detect_nonsilent
from datetime import datetime
from playsound import playsound
# Adjust target amplitude
def match_target_amplitude... |
43bc5db510a3eae95fcb491c428a6c1d71ca4b81 | yuukou3333/study-python | /init_py/python_init.py | 1,301 | 3.75 | 4 | # 5/14:Hello World 出力
# 6/14:変数とは
# 7/14:データ型
# 8/14:リスト
# 9/14:演算子
# 10/14:条件式
# =========================================
print("Hello World")
# =========================================
num = 1
print(num)
# 大文字小文字は区別される
Num = 2
print(Num)
# 予約語はダメ
# return = 3
# print(return)
# =================================... |
a2d26c672a3e420257e32136a2faf53912faf861 | saundera0436/CTI-110 | /P3T1_AreasOfRectangles_AnthonySaunders.py | 758 | 4.4375 | 4 | #CTI - 110
#Area of a rectangle
#Anthony Saunders
#October 7 2018
#Ask user to input the length and width of rectangle 1.
length1 = int(input("Please enter the length of rectangle 1: "))
width1 = int(input("Please enter the width of rectangle 1 : "))
#Ask user to input the length and width of rectangle 2.
l... |
b581de55eec9ae06cb884823758394f350e8ec67 | charleycodes/leetcode | /152_maximum_product_subarray.py | 1,141 | 4.125 | 4 | """Find the contiguous subarray within an array (containing at least one number)
which has the largest product.
For example, given the array [2, 3, -2, 4],
the contiguous subarray [2, 3] has the largest product = 6.
"""
class Solution(object):
def maxProduct(self, nums):
"""
:type nums: List[int]
... |
139f5fd80d1c01b8a7909aaabbbe016a7989e085 | kcmuths/Python-work | /pay_debt_month.py | 1,235 | 4.46875 | 4 | ##Write a program that calculates the minimum fixed monthly payment needed in
##order pay off a credit card balance within 12 months. We will not be dealing
##with a minimum monthly payment rate.
##retrieve the input from user
initialBalance = float(raw_input('Enter the outstanding balance on your credit card:'... |
4372b1873e245dedeb8122b07a1c02bf30a8ab4d | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4152/codes/1723_2498.py | 444 | 3.78125 | 4 | hA = int(input("Digite aqui o numero de habitantes a cidade A: "))
hB = int(input("Digite aqui o numero de habitantes a cidade B: "))
pA = float(input("Digite aqui o percentual de crescimento populacional da cidade A: "))
pB = float(input("Digite aqui o percentual de crescimento populacional da cidade B: "))
percA = pA... |
14c72c37389f705f131968971ac86dcbb3d173b1 | dengs08/pyCAM | /node.py | 504 | 3.84375 | 4 | class node(object):
def __init__(self, value, children = []):
self.value = value
self.children = children
def __repr__(self, level=0):
ret = "\t"*level+repr(self.value)+"\n"
for child in self.children:
ret += child.__repr__(level+1)
return ret
def walk(nod... |
68d80bb61b43159d020a5ec93378c6383adf799c | metmirr/project-euler | /answers/ex6.py | 334 | 3.578125 | 4 | """
Problem 6:
Find the difference between the sum of the squares of the first one hundred
natural numbers and the square of the sum.
"""
from functools import reduce
squre1 = reduce(lambda acc, x: x**2 + acc, range(1, 101))
squre2 = reduce(lambda acc, x: x + acc, range(1, 101))**2
print('answer:', squr... |
7fa79ead132756657f7a3694eb4f29e23de4ee22 | lrlichardi/Python | /tp5/Ej10.py | 304 | 3.890625 | 4 | # Escribir un programa que almacene en una lista los siguientes precios, 50, 75, 46, 22, 80,
# 65, 8, 23, 15, 5, 86, 43, 11 y muestre por pantalla el menor y el mayor de los precios
lista_precios = [50 , 75 , 46 , 22 , 80 , 65 , 8 , 23 , 15 , 5 , 86 , 43 , 11]
lista_precios.sort()
print(lista_precios) |
8307ec8f3e8a32e627f3af15f9d0bb339d8b8614 | littlezz/sec-pass-gen | /core/core.py | 2,029 | 3.5 | 4 | from string import ascii_lowercase, ascii_uppercase, digits
import itertools
from hashlib import sha512
__author__ = 'zz'
# allow_letter_mode
# bit mean low, upper, digits
ALL = 7 # 111
EXCLUDE_UPPER = 5 # 101
ONLY_DIGITS = 1 # 001
DEFAULT_MAX_LENGTH = 10
class BaseGenerator:
"""
hash the main passwo... |
e5352cbf473f7ab375f231e86816504c42194f5e | Navyashree008/functionsQuetions | /loop/kbc_part_1.py | 4,145 | 4.15625 | 4 | question_list = ["How many continents are there?", "What is the capital of India?","NG mei kaun se course padhaya jaata hai?" # teesra question
]
options_list = [
#pehle question ke liye options
["Four", "Nine", "Seven", "Eight"],
#second question ke liye options
["Chandigarh", "Bhopal", "Chennai", "Delhi"],
#thir... |
8e7959cd4e51eb9199e9ea3d400fc6cf446bfd3b | oeseo/-STEPIK-Python- | /7.9.py | 1,497 | 3.53125 | 4 | """
/step/1
n = int(input())
sum = 0
for i in range(1, n+1):
sum += i
l = [i for i in range(1, sum+1)]
counter = 0
for i in range(1, n+1):
s = []
for j in range(i):
s.append(l[counter + j])
counter += i
print(*s)
/step/2
n = int(input())
for i in range(1, n+1):
l = [str(j) f... |
7861e62dfacfd2dd8f4dd8c45da0667dd65bb85d | jfidelia/Chapter1_exercises | /uniqueCharacters2.py | 236 | 3.90625 | 4 | def is_unique_chars(str):
arr = [False] * 128
for char in str:
index = ord(char)
if arr[index]:
return False
else:
arr[index] = True
return True
print(is_unique_chars("yelp")) |
10ff851fa024a7b7a3c1bb8d985725c9fe8d8fbc | Meena25/python-75-hackathon | /tuples.py | 789 | 4.53125 | 5 | # TUPLES:
#2 tuples are created
tuple1 = ('tact','python')
tuple2 = (1,2,3,4)
print("tup1[0]: ",tuple1[0])
print("tup2[1:3]: ",tuple2[1:3])
""" OUTPUT:
tup1[0]: tact
tup2[1:3]: (2, 3) """
#Updating tuple1
tuple1 = ('python','challenge')
tuple3 = tuple1 + tuple2 # Concatenation of tuple1 and tuple2
... |
56c1e96c7393e70111d364e0762c8ba854a6d070 | JaspinderSingh786/Python3BasicsToAdvance | /functions/iterator.py | 255 | 4.28125 | 4 | # iterator function is used to generate a sequence value on by one
b = [1,2,3,4,5,26,7,8,8]
a = iter(b)
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))
|
3d710d07da1b9ed632328de08939d1f11aa77e13 | cczhouhaha/data_structure | /1010虚拟结点/虚拟结点/哑结点dummy.py | 3,766 | 3.75 | 4 | # 链表相关操作
# 删除某结点
# 虚拟结点:将头结点当做普通结点看待
"""
:Author:Miss zhou
:Creat : 2020/10/10 11:09
"""
class Node:
def __init__(self,data):
self.data = data
self.next = None
def __repr__(self):
return f"Node({self.data})"
class Slution:
def __init__(self):
self.head = None
# 删除链表中... |
c7c837510b2fd8812fbea06187dab54c1a0e82d3 | nesaro/london-code-dojo-27 | /test.py | 1,965 | 3.578125 | 4 | import unittest
from pub import Glass, Customer
class MyTest(unittest.TestCase):
def test_glass(self):
glass = Glass()
self.assertEqual(glass.content, 20)
def test_drink(self):
customer = Customer()
customer.buy_beer()
customer.drink()
self.assertEqual(customer.... |
563956ece5db99753c513816a72aaa1dd9902b39 | yournameherex337/lpthw | /ex18.py | 519 | 3.9375 | 4 | # This one is like your script with argv
def print_two(*args):
arg1, arg2 = args
print "arg1: %r, arg2: %r" % (arg1, arg2)
# ok that *args is acutally pointless, we can do it this way
def print_two_again(arg1, arg2):
print "arg1: %r, arg2: %r" % (arg1, arg2)
# this just takes one argument
def print_one(ar... |
dad81e08090ad26e4064540735afffddfc072cb7 | adaray/cvp316 | /Blockchain/blockchain.py | 1,882 | 3.71875 | 4 | blockchain = []
def last_value():
if len(blockchain) < 1:
return None
return blockchain[-1]
def get_tx_value():
return float(input('Enter transaction value: '))
def get_user_choice():
return input('\nEnter your choice: ')
def add_value(transaction, last_transaction = [1]):
if last_transa... |
46e9dba85615a1272b2287253728c311d410749b | srikanthpragada/22_JAN_2018_PYTHON | /fun/lambda_sorted.py | 364 | 3.78125 | 4 | def length(s):
return len(s)
def last_name(s):
return s.split()[-1]
names = ['Bill Gates','Larray Ellison','Micheal Dell','Jeff Bezzos','Larry Page','Steve Jobs']
# for n in sorted(names):
# print(n)
#
# for n in sorted(names,key=length):
# print(n)
# for n in sorted(names,key=last_name):
# pri... |
d2096029c331797d7a2f97661379b448643139a2 | imwarsame/DataStructures | /Python/queue.py | 519 | 4.0625 | 4 | # first element in is first element out
# that's about it
queue = []
queue.append('a')
queue.append('b')
queue.append('c')
queue.append('d')
print("\nElements dequeued from queue")
print(queue.pop(0))
print(queue.pop(0)) #removes element at index 0, then after inserts moves element at index 1 to index 0 i.e. fir... |
a1338cafef4fdf4e108c2ebe38e6a2ddca9e3d71 | ChengHsinHan/myOwnPrograms | /CodeWars/Python/8 kyu/#093 The 'if' function.py | 435 | 4.28125 | 4 | # Create a function called _if which takes 3 arguments: a boolean value bool and
# 2 functions (which do not take any parameters): func1 and func2
#
# When bool is truth-ish, func1 should be called, otherwise call the func2.
#
# Example:
# def truthy():
# print("True")
#
# def falsey():
# print("False")
#
# _if(Tru... |
996a9b13f6f483fa6ee30e07046355caad873652 | RRoundTable/Data_Structure_Study | /array/delete_nth.py | 1,478 | 3.78125 | 4 |
# 문제
"""
Given a list lst and a number N, create a new list
that contains each number of the list at most N times without reordering.
For example if N = 2, and the input is [1,2,3,1,2,1,2,3], you take [1,2,3,1,2],
drop the next [1,2] since this would lead to 1 and 2 being in the result 3 times, and then take 3,
which ... |
bec9fcf42c1028e8dc702904fd06da5cf5b79bb7 | ChenLiangbo/Learning-python | /sort/search.py | 1,199 | 3.765625 | 4 | #!usr/bin/env/python
# -*- coding: utf-8 -*-
# 第一种
# 无序列表中的查找,随机查找,循环遍历
#第二种 有序表的查找一般使用二分法
#不断从中间选取元素进行查找,这样的时间复杂度是log(n)
#在查找表中不断取中间元素与查找值进行比较,以二分之一的倍率进行表范围的缩小
def binary_search(lis, key):
low = 0
high = len(lis) - 1
time = 0
while low < high:
time += 1
mid = int((low + high) / 2)
... |
e9f3ee963e8eac79cc0924740d1ee4c1fd777ed2 | dewhallez/python_Projects | /ping.py | 366 | 3.828125 | 4 | import os
# define the ping function
def pingComputer():
# Get hostname Ip address
hostname = input("Enter the ip address: ")
# ping host for response
response = os.system("Ping -c 2 " + hostname)
if response == 0:
print(f'{hostname} is up')
else:
print(f'{hostname} is down')
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.