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 |
|---|---|---|---|---|---|---|
156391fb75db88ca2cf54211feac81680a7a7fb4 | Windsooon/LeetCode | /KMP.py | 785 | 3.65625 | 4 | class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
if not needle:
return 0
if len(needle) > len(haystack) or not haystack:
return -1
pointer = 0
# for in... |
a9f109eca4ee27fbd4cd6270167343409f4b325f | Windsooon/LeetCode | /Implement strStr().py | 507 | 3.609375 | 4 | class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
if not haystack and not needle or not needle:
return 0
if not haystack:
return -1
for k, v in enumerate(haysta... |
3297064fd57418795b15fc69a30b1f3fe78c2f16 | Windsooon/LeetCode | /Reverse Nodes in k-Group.py | 1,122 | 3.78125 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def reverseKGroup(self, head, k):
"""
:type head: ListNode
:type k: int
:rtype: ListNode
"""
if not head or ... |
2b76d5f781412b9d40ff53243edabf9fe639cabc | Windsooon/LeetCode | /Swap Nodes in Pairs.py | 1,161 | 3.78125 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def swapPairs(self, head):
pre, pre.next = self, head
# 1, 2, 3, 4
while pre.next and pre.next.next:
a = pre.next
b ... |
7344745d243c9fd670d9feb510d6942681ca5a34 | Windsooon/LeetCode | /Middle of the Linked List.py | 566 | 3.9375 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def middleNode(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
slow = fast = head
while fast and fast.next:
... |
931194b262550d58fbb7d0b7686dc89386d3d702 | Windsooon/LeetCode | /Find Peak Element.py | 557 | 3.5625 | 4 | # len < 3 -> None
# [1,2,3,1] -> 2
# [1,2,1,3,5,6,4] -> 1 or 5
# logarithmic complexity
class Solution:
def findPeakElement(self, nums):
if not nums:
return
l, r = 0, len(nums)-1
# breakpoint()
while l < r:
mid = (r+l)//2
if nums[mid] > nums[mid+1... |
c92cf5e7e2cc8916e1452309b136b8fd0b53f2ad | Windsooon/LeetCode | /Construct Binary Tree from Preorder and Inorder Traversal.py | 731 | 3.703125 | 4 | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def buildTree(self, preorder, inorder):
"""
:type preorder: List[int]
:type inorder: List[int]
:rtype: TreeNode
"""
if... |
558fc3a743f101864f8bc0f36b35b108fe6c74e2 | XieChen10983/python_cookbook | /第1章 数据结构和算法/1.16 筛选序列中的元素/filtrate.py | 1,258 | 3.609375 | 4 | # coding=gbk
"""
author(): Channing Xie(л)
time(ʱ): 2020/3/31 21:06
filename(ļ): filtrate.py
function description():
ͨбƵʽʽfilterбɸѡ
ͨitertoolsģеcompressɸѡ,compress(Ҫɸѡ, ͵б)
...
"""
# ################бƵʽнɸѡ##################### #
mylist = [1, 4, -5, 10, -7, 2, 3, -1]
plus_list = [n for n in mylist if n >= 0]
ab... |
b3e34ee861c0747cb2178f51aee3cbff2d1746b0 | kissann/lab3 | /ADVANCED_second.py | 247 | 3.9375 | 4 | #Обчислити факторіал числа.
import math
while True:
n = input("Введите число, для выхода нажмите ^: ")
if n=='^':
break
else:
n=int(n)
print (math.factorial(n)) |
f291ec60e6ebb82f0d6c2b4b7ebf525c1f0f153e | VISALI-220299/Visali | /pro33.py | 216 | 3.984375 | 4 | string=input()
flag3=0
for i in range(0,len(string)-1):
for j in range(i+1,len(string)):
if string[i]<string[j]:
flag3=1
print(string[j:])
break
if flag3==1:
break
else:
print(string)
|
a788c607b1f49b3948d243e10c0032c07c65825d | VISALI-220299/Visali | /evenno.py | 84 | 3.59375 | 4 | s=int(input())
e=int(input())
for i in range(s+1,e+1):
if((i%2)==0):
print(i)
|
f10d2b09c1799d197fe09c62b13b543b5839fdd8 | VISALI-220299/Visali | /alphabet.py | 96 | 3.953125 | 4 | v=input()
if((v>='A' and v<='Z') or (v>='a' and v<='z')):
print("Alphabet")
else:
print("No")
|
b3eca54dd413dbeb8134ea759d05f32a23f8433a | sequix/8digits | /priority_queue.py | 748 | 3.890625 | 4 | #!/usr/bin/env python3
# -*- coding: utf8 -*-
# 包装heapq,实现稳定的优先队列
import heapq
class PriorityQueue:
'''可实现稳定排序的优先队列'''
def __init__(self, initial=None, key=lambda x:x):
self.key = key
if initial:
self._data = [(key(item), i, item) for i, item in enumerate(initial)]
self... |
309217691b7ef23f75072662121f00dfdbd5f9db | pxl-th/aoc-2019 | /day5.py | 3,439 | 4.15625 | 4 | """
modes:
0 - position mode
1 - immediate mode
instruction:
XXXX|OP: OP - operation, XXXX modes
read from right to left
default mode = 0
operaitons:
1 - add
2 - multiply
3 - input from user and stores it at its value parameter
4 - output value of its parameter (4, 50) -- pri... |
1f75370c9e6645fb3aaff1557600f19361b18e2f | Kashyap-Nirmal/Python-practice | /Assignment 4/p2.py | 1,224 | 3.875 | 4 | findKey=int(input("Enter the element to search:\n"))
input_list=[10,9,6,5,3,1,2]
list1=[]
list1=list(input_list)
list1.sort()
i=0
j=len(input_list)
k=int((i+j)/2)
flag=0
def binary_search_rec():
global i,j,k,flag
if(j==i or j-i==1 and flag==0):
if(findKey==list1[i]):
flag=1
for l in range(len(list1)):
if... |
2fea8a1d5c31dda8a1259fe8d9387e8ec8aa36d4 | Kashyap-Nirmal/Python-practice | /Assignment 1/p3.py | 80 | 3.734375 | 4 | i=int(input("Input a number:"))
for j in range(1,11):
print i," x ",j," = ",i*j |
39d1a096704b845a3608bd86d8cb0973dbf0a93c | ProyectoII-IA/Connect4 | /model/genetics/game_genetics.py | 1,555 | 3.53125 | 4 | # Package: model.game
# Description: Class to define the structure of the game
# Artificial Intelligence, II Semester 2018
# Project: Connect 4
# Author : Mariana Rojas S.
# E-mail: mari.semeraro27@gmail.com
# Modified: Katerine Molina Sánchez
# Version: 0.0.1
# IMPORT SECTION
from model.game.board import Board
fro... |
529b4f55dc4c1af8b68ffc74fb079100c359e136 | SerChiffa/study_python | /НОД Алгоритм Евклида.py | 587 | 3.703125 | 4 | ##Алгоритм Евклида для нахождения НОД:
##a=int(input())
##b=int(input())
##while a!=b:
## if a>b:
## a=a-b
## else:
## b=b-a
##print(a)
##или написать так, что быстрее выведет результат
##a,b = map(int, input().split())
##while a!=b:
## if a>b:
## a=a-b
## else:
## b=b-a
##pr... |
e0e970a4239fc149f97fd55ba9b3ef7c0b978ca2 | shanberochka/MIPT_Python_Practice | /Практика: Черепаха/ex10.py | 384 | 4.0625 | 4 | import turtle
turtle.shape('turtle')
petals = int(turtle.textinput(u"Введите количество лепестков.", "Введите количество окружностей: "))
def flower(petals):
for i in range(1, petals+1):
turtle.circle(50)
turtle.setheading(0)
turtle.left(360/petals*(i))
flower(petals)
turtle.exito... |
7d256852534eeebbbf6c1769cbcefa563d54969e | kailash-manasarovar/A-Level-CS-code | /algorithms/linear_search.py | 2,551 | 4.09375 | 4 | # LINEAR SEARCH (SERIAL SEARCH):
# 2 inputs = list of elements, search value
# output = is it there? is the search value in the list of elements? yes or no, boolean (true or false)
# Big O (worst case scenario runtime)
# if the number of elements in the list = n, Big O of Linear Search = n
import time
import random a... |
f151db3ddc9efcecc4d3527fc1586d34b933df7f | kailash-manasarovar/A-Level-CS-code | /OCR_exam_questions/linked_order_list.py | 574 | 3.84375 | 4 | # 2017 Paper 2 June Q2
def linked_order_list(orders):
finished = False
print(finished)
count = 0
print(count)
while not finished:
if orders[1][count] is None:
finished = True
else:
output = orders[0][count]
print(output)
print(finished)... |
910958d6db415f9c7da42e65ed0b31a100dbae97 | kailash-manasarovar/A-Level-CS-code | /OCR_exam_questions/convert_to_ascii.py | 398 | 3.9375 | 4 | # Practice Papers Set 1 Paper 1 Q4
def convert_to_ascii(eb_value):
if eb_value >= 193 and eb_value <= 201:
return eb_value - 128
elif eb_value >= 209 and eb_value <= 217:
return eb_value - 135
elif eb_value >= 226 and eb_value <=233:
return eb_value - 143
else:
return... |
ef51ccdfec6a085f71391805d08e0049ce4c7fa7 | kailash-manasarovar/A-Level-CS-code | /libraries/numpy_tutorial.py | 843 | 3.921875 | 4 | # numpy = Numerical Python
# Mathematical and logical operations on arrays.
# Fourier transforms and routines for shape manipulation.
# Operations related to linear algebra.
# NumPy has in-built functions for linear algebra and random number generation.
# Replacing Matlab
import numpy as np
# a = np.array([1,2,3])
# ... |
b32e317eeba6e857c02bbab7e5fab01172e2ec1d | kailash-manasarovar/A-Level-CS-code | /challenges/mastermind.py | 917 | 3.71875 | 4 | '''
Created on 10 Jun 2018
@author: katharinemurphy
'''
import random
correctAnswer = ''
#generate number
for i in range (4):
tempChar = str(random.randint(0,9))
correctAnswer = correctAnswer + tempChar
guess = ''
attempts = 0
while guess != 'q':
guess = input('Please enter your 4 digit number or q to quit... |
05c3bc652c8efb1e2cbd6429a876e16778e3ab67 | kailash-manasarovar/A-Level-CS-code | /OCR_exam_questions/contains_string.py | 294 | 3.625 | 4 | # Practice Papers Set 2 Paper 2 Q4b
def contains(string1, string2):
if string1 == string2:
return True
elif len(string1) > len(string2):
return False
elif string1 in string2:
return True
else:
return False
print(contains("fox", "foghound"))
|
bec4400de442d424a2594b4b76e1a3c72a713bd8 | kailash-manasarovar/A-Level-CS-code | /algorithms/merge_sort.py | 1,069 | 4.15625 | 4 | def merge(a_list):
print("Splitting ", a_list)
if len(a_list)>1:
mid = len(a_list) // 2
left_half = a_list[:mid]
right_half = a_list[mid:]
merge(left_half)
merge(right_half)
i=j=k=0
# while all lists have more than one element
while i < len(left_h... |
f6e7b5f92ba34b8a815c08069488217d321f0f62 | kailash-manasarovar/A-Level-CS-code | /OCR_exam_questions/check_access.py | 1,073 | 4.0625 | 4 | # 2017 Paper 1 Question 7
def check_access(given_password, password_hash, locked):
# FIRST STEP : get the hash of the password the user entered
hashed_user_input = hash(given_password)
# SECOND STEP : set a variable that we will use as a result
allowed_in = False
# THIRD STEP : check to see if th... |
ac9a7f7dc8d38922d664e20b379d14109e0c7b0e | kailash-manasarovar/A-Level-CS-code | /challenges/number_table.py | 317 | 4.1875 | 4 | operator = input("Please input an operator, +,-,*,/ ")
number = int(input("Please input a number "))
list_of_numbers = [i for i in range(number+1)]
print(operator + " | " + str(list_of_numbers[:]))
print("- - - - - - - - - -")
for i in range(number+1):
print(str(i) + " | " + str(list_of_numbers[i:]))
pass |
3f564960b8c389753d55dab0f5926b281fce2be6 | seanbreckenridge/dotfiles | /.local/scripts/generic/rename-mpv-images | 1,221 | 3.5625 | 4 | #!/usr/bin/env python3
"""
Rename images from mpv screenshots, retaining the timestamp in the name, but removing the original filename
\b
My mpv config has the following line:
screenshot-template="%f-%wH.%wM.%wS.%wT"
\b
That creates images with names like:
some-long-filename-here-12.34.56.789.jpg
\b
This script ren... |
57a7414a2f42b7bb8ba99967266fee1105cb102e | seanbreckenridge/dotfiles | /.local/scripts/generic/dates-stdin | 1,132 | 3.5 | 4 | #!/usr/bin/env python3
"""
recieve dateparser dates, one per line from stdin, and print them
"""
from typing import Literal
from datetime import datetime
import click
import arrow
from dateparser import parse
import warnings
warnings.filterwarnings("ignore", "The localize method is no longer necessary")
@click.c... |
0eedfa0b12c8bfca67a674a74297d3f724efc1d0 | seanbreckenridge/dotfiles | /.local/scripts/generic/show-pickle | 461 | 3.84375 | 4 | #!/usr/bin/env python3
"""
Reads a pickled (python) object from a file
Accepts the file as the first argument
"""
import os
import sys
import pickle
import pprint
if len(sys.argv) < 2:
print(
"Error: Must provide a file to read a pickle from as the first argument.",
file=sys.stderr,
)
sys... |
7383f4b0fc8218c10996dfdeb38588bfdd92fe65 | Konstantin-Net/Test-development- | /Function.py | 4,636 | 3.671875 | 4 | documents = [
{"type": "passport", "number": "2207 876234", "name": "Василий Гупкин"},
{"type": "invoice", "number": "11-2", "name": "Геннадий Покемонов"},
{"type": "insurance", "number": "10006", "name": "Аристарх Павлов"}
]
directories = {
'1': ['2207 876234', '11-2'],
'2': ['10006'],
'3': ["... |
a982bef050d8990b7dc57ecef05320f2f75b9d8d | NIAEFEUP/slides | /python-workshop/text_based_game.py | 2,522 | 4.09375 | 4 | answer_A = ["A", "a"]
answer_B = ["B", "b"]
answer_C = ["C", "c"]
yes = ["Y", "y", "yes"]
no = ["N", "n", "no"]
sword = False
def intro():
print("After a drunken night out with friends, you awaken in a thick, dank forest. A slobbering orc is running towards you.")
print("A. Grab a nearby rock and throw it at the... |
4133a308835ccf877ac7b712aa5af68ce5be56da | FArekkusu/Gamedev | /Lab 1/human_controller.py | 505 | 3.625 | 4 | from ui import display_board
from exceptions import GiveUpException
def make_console_move(player, board):
moves = board.find_moves(player.symbol)
display_board(board, moves)
if not moves:
return
print(f"\n{player.color} possible moves: {', '.join(moves)}")
while True:
move = input("... |
7be9dd5a1808dcadb8cff0b78f7e7c51564dfad2 | osanseviero/Python-Notebook | /ex13.py | 354 | 3.59375 | 4 | #Program 13. Importing
#Run "python ex13.py first second third", you are sending the variable
from sys import argv #You import a module or library
script, first, second, third = argv #Unpacking
print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second
print... |
db7e8c945aaea087fb9f5afb38dbfc54d25cc473 | osanseviero/Python-Notebook | /ProblemSet1Questions.py | 793 | 4 | 4 | # Problem set 1.
# Exercise 1: Reverse a string
# Write a function that will take a string as input, and return a new
# string with the same letters in reverse order.
# Don't use String's reverse function; that would be too simple.
# Exercise 2: Factorial
# Have the function FirstFactorial(num) take the num paramete... |
1b25840045d4858f9eec3deeda08f2373376ee25 | osanseviero/Python-Notebook | /ex31.py | 626 | 4.375 | 4 | #Program 31. Using while loops
def create_list(size, increment):
"""Creates a list and prints it"""
i = 0
numbers = []
while i < size:
print "New run! "
print "At the top i is %d" % i
numbers.append(i)
i = i + increment
print "Numbers now: ", numbers
print "At the bottom i is %d\n \n" % i
prin... |
8e5d360f2ce4542e4cab33ec165a82f9ce7672e0 | osanseviero/Python-Notebook | /ex36.py | 555 | 3.90625 | 4 | # Program 36. More lists
ten_things = "Apples Oranges Crows Telephones Light Sugar"
print "We need more things to get 10 things"
#Converting string to list
stuff = ten_things.split(' ')
more_stuff= ["day", "night", "song", "frisbee", "icecream", "banana", "boy", "girl"]
while len(stuff) != 10:
next_item = more_stu... |
006a4070da536f4d42c65d93e0e5eb67db3b06b6 | mirgags/pear_shaped | /fruit_script.py | 1,896 | 4.21875 | 4 | # An interactive script that prompts the user to accept or reject fruit
# offerings and then asks if they want any other fruit that wasn't offered.
# Responses are stored in the fruitlist.txt file for later reading.
yeses = ['YES', 'OK', 'SURE', 'YEAH', 'OKAY', 'SI']
nos = ['NO', 'NOPE', 'NAH', 'UH-UH']
fruits = []
... |
c6e2ecfc2bea93f5d0fcfac6298a3f02ae0211f8 | mirgags/pear_shaped | /ex15.py | 387 | 3.890625 | 4 | from sys import argv
script, filename = argv
txt = open(filename)
print "Here's the file %r:" % filename
print txt.read()
print "Now replace that text: "
new_txt = raw_input('> ')
txt.close()
txt = open(filename, 'a')
txt.write("\n%s\n" % new_txt)
print "Now let's add one more line:"
new_txt = raw_input('> ')
txt... |
d4993c0f7cf62309ec65b47a630cddc003023c88 | surajkumar4aug/kec | /countmax.py | 461 | 4 | 4 |
def countoccur(x, i):
count = 0
while (x):
if (x % 10 == i):
count += 1;
x = int(x / 10)
return count
def maxoccur(x):
if (x < 0):
x = -x
result = 0
max_count=1
for i in range(10):
count = countoccur(x, i)
if (count >= max_count):
max_count = count
result = i... |
df79d738305821d8bf2e58b0bbe4e31a852a2027 | andrewdaoust/project-euler | /problem023.py | 2,313 | 3.9375 | 4 | """
A perfect number is a number for which the sum of its proper divisors
is exactly equal to the number. For example, the sum of the proper
divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28
is a perfect number.
A number n is called deficient if the sum of its proper divisors is
less than n and ... |
1864a160dec53b2c9585bf05928daeafc23ff066 | andrewdaoust/project-euler | /problem004.py | 825 | 4.1875 | 4 | """
A palindromic number reads the same both ways. The largest palindrome made
from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
def palindrome_check(n):
s = str(n)
length = len(s)
for i in range(int(len(s)/2)):
... |
c6ecdc710116054197d6d8f14f50f7af44700829 | andrewdaoust/project-euler | /problem001.py | 487 | 4.3125 | 4 | """
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
import numpy as np
def run():
mult_3_5 = []
for i in range(1, 1000):
if i % 3 == 0:
mult_3_5.a... |
5de7e86f546985d7ea69172b8937f2b65bf00a8f | dltmdan92/pythonalgorithm | /level2/계단오르기1.py | 1,517 | 3.5625 | 4 | """
실습과제
100XP
영훈이는 출근할 때 계단을 통해 사무실로 가는데요. 급할 때는 두 계단씩 올라가고 여유 있을 때는 한 계단씩 올라 갑니다.
어느 날 문득, 호기심이 생겼습니다. 한 계단 또는 두 계단씩 올라가서 끝까지 올라가는 방법은 총 몇 가지가 있을까요?
계단 4개를 올라간다고 가정하면, 이런 방법들이 있습니다.
1, 1, 1, 1
2, 1, 1
1, 2, 1
1, 1, 2
2, 2
총 5개 방법이 있네요.
함수 staircase는 파라미터로 계단 수 n을 받고, 올라갈 수 있는 방법의 수를 효율적으로 찾아서 리턴합니다.
print(stairc... |
5d05df6cc9bbe9e80cb8803c565f79c050fce8a8 | dltmdan92/pythonalgorithm | /DivideAndConquer/UpgradeQuickSort.py | 1,692 | 3.734375 | 4 | # 두 요소의 위치를 바꿔주는 helper function
def swap_elements(my_list, index1, index2):
# 이전 과제에서 작성한 코드를 붙여 넣으세요!
temp = my_list[index1]
my_list[index1] = my_list[index2]
my_list[index2] = temp
# 퀵 정렬에서 사용되는 partition 함수
def partition(my_list, start, end):
# 이전 과제에서 작성한 코드를 붙여 넣으세요!
p_index = end
big... |
11f9e65c0e2895187f764af6829fd52349150eb5 | dltmdan92/pythonalgorithm | /DivideAndConquer/DivConqMergeSortAgain.py | 1,092 | 4.09375 | 4 | """
TODO Divide and Conquer 방식으로 merge_sort 함수를 써 보세요. merge_sort는 파라미터로 리스트 하나를 받고, 정렬된 새로운 리스트를 리턴합니다.
"""
def merge(list1, list2):
# 이전 과제에서 작성한 코드를 붙여 넣으세요!
result = []
list1_idx = 0
list2_idx = 0
while list1_idx < len(list1) and list2_idx < len(list2):
if list1[list1_idx] > list2[list... |
520fa61372d0db53769d2c20442cff6bbcdca91b | dltmdan92/pythonalgorithm | /DivideAndConquer/MergeSortAgain.py | 781 | 4.03125 | 4 | """
TODO 정렬된 두 리스트 list1, list2를 받아서, 하나의 정렬된 리스트를 리턴합니다.
"""
def merge(list1, list2):
# 코드를 작성하세요.
result = []
list1_idx = 0
list2_idx = 0
while list1_idx < len(list1) and list2_idx < len(list2):
if list1[list1_idx] > list2[list2_idx]:
result.append(list2[list2_idx])
... |
7017407694d1f63a96049a534428adc96d074374 | mohitgoel188/Python_Soup | /PassGen.py | 615 | 3.75 | 4 | import string,random
lchar="abcdefghijklmnopqrstuvwxyz"
uchar=lchar.upper()
spchar="#$%&*?@^"
#espchar="#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
num="1234567890"
#pas=raw_input("Enter anything: ")
#pas=list(pas)
#print(pas)
#paslen=len(pas)
password=[]
for i in range(0,10):
char=i%5
if(char==1):
password.append(... |
b616bccc0ab402808281a45ff1f3a766e938c411 | ernielikesapple/machineLearningExperiments | /kmeans.py | 1,593 | 3.671875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 24 20:59:59 2020
@author: ernie
"""
#kmeans algorithm: https://www.youtube.com/watch?v=4b5d3muPQmA&list=PLlcyUWQOcKAgDvemP5qJp0kcvWU5n-d7V&index=1
#code for this file : https://www.youtube.com/watch?v=v-SjKuFZV7A
import matplotlib.pyplot as plt
f... |
97488deeb0ccb7323e298abe85a8cc48a73cb54f | nickmallare/Leet-Code-Practice | /121-best-time-buy-sell-stock.py | 758 | 4.0625 | 4 | """
You are given an array prices where prices[i] is the price of a given stock on the ith day.
You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.
Return the maximum profit you can achieve from this transaction. If you cannot achi... |
688b44387560371c3262dd115f377c87f06eabb5 | nickmallare/Leet-Code-Practice | /35-search-insert-position.py | 851 | 4.1875 | 4 | """
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with O(log n) runtime complexity.
"""
class Solution(object):
def searchInsert(self, nums, target):
... |
e41c66c3592a63e447d9e504fd416a8d21d9ddb0 | AyeshaJahangir/Python | /binarySearch.py | 451 | 3.859375 | 4 | def search(nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
start=0
end=len(nums)
while start < end:
middle=start+((end-start)/2)
if target==nums[middle]:
return middle
... |
97a742f9dc75a0ac0061942537f44d3bdd622462 | JasurKdirbaev/python_Darslarim | /Qudrat_Integer.py | 2,478 | 3.5 | 4 | #Integer-3
"""bayt = int(input("Fayl hajmini baytlarda kiriting: "))
Kbayt = 1024
print("Fayl hajmi ", bayt / Kbayt, "Kbayt ga teng:")"""
#Integer-4+5
"""A = int(input("A > B shartni qanoatlantirsin\nA kesmani kiriting: "))
B = int(input("B kesmani kiriting: "))
print("A kesmada B kesma", int(A/B), "marta joyl... |
e3b543e15453733a394cfab2a6ccfb554ac146ac | Frank-LSY/Foundations-of-AI | /HW3/TSP/SA.py | 3,584 | 3.96875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 20 15:24:16 2019
Simulated annealingg Algorithm for the TSP
@author: Shuyu Lu (Frank)
"""
from TSP import TSP_Problem, Standard_Cities
import math
import random
import matplotlib.pyplot as plt
# the cooling strategy designed in part c
def cooling_... |
f911c2170e7dcb50d4d0eef0eebe550926af2c87 | Frank-LSY/Foundations-of-AI | /HW1/Puzzle8/bfs.py | 1,650 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 3 17:01:00 2019
vanilla breadth first search
- relies on Puzzle8.py module
@author: Milos Hauskrecht (milos)
"""
from Puzzle8 import *
#### ++++++++++++++++++++++++++++++++++++++++++++++++++++
#### breadth first search
def br... |
f2384d10499249649f89c288f03be44785bd782f | Frank-LSY/Foundations-of-AI | /HW2/Puzzle8-HW2/heuristic2.py | 993 | 3.984375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 18:32:46 2019
@author: Frank Lu
"""
# a heuristic function for the 'current' state and the target state
# currently manhattan distance heuristic
def h_function(state,target_state):
manhattan = {1:[0,1,2,1,2,3,2,3,4], ##the manhatan distanc... |
69ef46ec9c412126a75e78e286818c71c11c6a4b | karimmik/SAT_GA | /Solution.py | 1,993 | 3.796875 | 4 | import random
class Solution:
value = 0
def __init__(self, solution_length):
"""
generate a random unevaluated solution of given length
:param solution_length: length of new generated solution
"""
self.solution_vector = [random.randint(0, 1) for i in range(solution_le... |
68c2282cfa7fd0a566cc8a504afe122691631fde | rossybautista/Programacion-Visual | /EXAMEN_PROGRAMACION/descuento.py | 709 | 3.796875 | 4 | #Escribir una función llamada descuento.py que reciba como parámetros la cantidad y el descuento y aplicar, es valido recibir un diccionario de la sig. forma: datos = {"descuento": 15, "importe": 2500}.
desc = int(input("Ingresa el porcentaje de descuento: "))
importe = float(input("Ingresa el importe del producto: "... |
deee8b08ad6ef0b74677e1f05d31ebfc8de7b16f | rossybautista/Programacion-Visual | /funcionnumentreellos.py | 284 | 4.03125 | 4 | # Crea una función que dados dos números mostrara todos los números que hay entre ellos
def numerosEntre(num1, num2):
if (num1 > num2):
aux = num1
num1 = num2
num2 = aux
for i in range(num1+1, num2):
print(i)
numerosEntre(5,10) |
89ee692d77d86f7455cdd43b40958ab6eb5a3086 | HuichuanLI/Data-Analyse | /main.py | 1,322 | 3.515625 | 4 | import pandas as pd
import numpy as np
pd.set_option('display.max_columns', None)
df = pd.read_csv("./data/HR.csv")
# pandas
print(df.head(10))
print(type(df))
print(type(df["satisfaction_level"]))
# 求均值
print(df.mean())
print(df["satisfaction_level"].mean())
# 取中值
print(df["satisfaction_level"].median())
# 分位... |
af59591109e13bd3c93960a919f7d34cec607061 | picktsh/python | /code2/day09/demo04.py | 1,150 | 3.765625 | 4 | """
# 以下方法都可以从网页中提取出'你好,蜘蛛侠!'这段文字
find_element_by_tag_name:通过元素的名称选择
# 如<h1>你好,蜘蛛侠!</h1>
# 可以使用find_element_by_tag_name('h1')
find_element_by_class_name:通过元素的class属性选择
# 如<h1 class="title">你好,蜘蛛侠!</h1>
# 可以使用find_element_by_class_name('title')
find_element_by_id:通过元素的id选择
# 如<h1 id="title">你好,蜘蛛侠!</h1>
# 可以使用find_el... |
43ddf1236d31e2e9f6b3b166d6e15d68061b5434 | picktsh/python | /code/day12/类实现的人力计算器.py | 1,895 | 3.765625 | 4 | import math
class Project:
def __init__(self):
self.key = 1
def input(self):
choice = input('请选择计算类型:(1-工时计算,2-人力计算)')
if choice == '1':
self.size = float(input('请输入项目大小:(1代表标准大小,请输入小数)'))
self.number = int(input('请输入人力数量:(请输入整数)'))
self.time... |
a79c759c98e7431d1b0d9e8ceb6be957d68e892e | picktsh/python | /code2/day04/demo01.py | 2,040 | 3.59375 | 4 | """
根据前两关所学的知识,如果不出意外,我们的代码大概可以写成这幅模样:
"""
import requests
from bs4 import BeautifulSoup
# 请求html,得到response
res_music = requests.get(
'https://y.qq.com/portal/search.html#page=1&searchid=1&remoteplace=txt.yqq.top&t=song&w=%E5%91%A8%E6%9D%B0%E4%BC%A6')
# 解析html
bs_music = BeautifulSoup(res_music.text, 'html.parser... |
c7d5ca59b128642166558358199d9224b5c40b83 | picktsh/python | /code2/day02/demo04.py | 1,254 | 3.578125 | 4 | """
现在,三本书的全部信息都被我们提取出来了。它的数据类型是<class 'bs4.element.ResultSet>, 前面说过可以把它当做列表list来看待。
不过,列表并不是我们最终想要的东西,我们想要的是列表中的值,所以要想办法提取出列表中的每一个值。
用for循环遍历列表,就可以把这三个div元素取出来了。
"""
# 调用requests库
import requests
# 调用BeautifulSoup库
from bs4 import BeautifulSoup
# 返回一个Response对象,赋值给res
res = requests.get('https://localprod.pandateac... |
6fbe49bec6f20a8f76e1632dc6289418253a7efa | picktsh/python | /code/day16/learn_csv1.py | 250 | 3.53125 | 4 | import csv
with open("test1.csv", newline='') as f:
reader = csv.reader(f)
# 使用csv的reader()方法,创建一个reader对象
for row in reader:
# 遍历reader对象的每一行
print(row)
print("读取完毕!")
|
dc3a700487d7ec0d6a9a5e1341cd17c913611ddd | picktsh/python | /code/day13/进阶练习_学习时间记录.py | 3,282 | 4.21875 | 4 | """
1.练习目标:
这个练习,主要是训练你对“子类的继承”的理解和运用。
练习要求:
练习会先提供一个类,用以记录学生学习 Python 的投入时间和有效时间。
需要你创建一个子类,为某一类学生提供定制化的记录方案。
步骤讲解
明确目标很重要(所以重复三遍)。
做到后面的步骤,可再点开左侧的“练习介绍”查看。
练习目标:
这个练习,主要是训练你对“子类的继承”的理解和运用。
练习要求:
练习会先提供一个类,用以记录学生学习 Python 的投入时间和有效时间。
需要你创建一个子类,为某一类学生提供定制化的记录方案。
"""
"""
2.用代码记录时间
请看代码:
"""
"""
# 请先读懂代码,再运行。
class S... |
793ed3e3d275d68b144217d07002439de584d66b | picktsh/python | /code/day11/demo01.py | 901 | 3.828125 | 4 | # bug 1:粗心
# 有一处错误
# a = input('请输入密码:')
# if a == '123456'
# print('通过')
a = input('请输入密码:')
if a == '123456':
print('通过')
# 有三处错误
'''
for x in range(10):
print(x)
'''
for x in range(10):
print(x)
'''
while n<3:
username = input("请输入用户名:")
password = input("请输入密码:")
if username = 'abc' ... |
d07b6d05cc3a9d4db06fa21117765cd3410918cb | picktsh/python | /code2/day02/demo03.py | 1,049 | 3.734375 | 4 | """
在网页的HTML代码中,有三个div元素(<div></div>),用find()可以提取出首个元素(只有一个),而find_all()可以全部取出(三个)。
"""
import requests
from bs4 import BeautifulSoup
url = 'https://localprod.pandateacher.com/python-manuscript/crawler-html/spder-men0.0.html'
res = requests.get(url)
print(res.status_code)
soup = BeautifulSoup(res.text, 'html.parser')
... |
01c9ec1e829a5734587413355ba3fef83204ab67 | JaggedDevelopment/DAT119_Final_Text_Based_RPG | /Final_Project_ShelleyNicolas.py | 25,060 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 27 13:51:48 2021
@author: Nicolas Shelley
Last Edited: 5/14/2021
Simple Text Based RPG with Saving and Reload System
This program is just a simple RPG game that uses all varaible types and allows the player to level,
accrue gold and defeat bosses. It uses a .txt... |
50b71388941dd0a65a19e46072420fe9b44fff28 | Nihila/python_programs | /hunter/natural.py | 127 | 4.09375 | 4 | a=int(input("enter the number :"))
sum = 0
while(a>0):
sum=sum+a
a=a-1
print("the sum value is :",sum)
|
4ad120e7f53162c10541c354acd1a30bc30cbeae | Nihila/python_programs | /begginer/positiveornegative.py | 797 | 4.25 | 4 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Administrator
#
# Created: 04/02/2018
# Copyright: (c) Administrator 2018
# Licence: <your licence>
#--------------------------------------------------------------------... |
f1f1125d16341d77e88b7bd2128ebaae38822a3d | Nihila/python_programs | /hunter/digit.py | 104 | 3.9375 | 4 | a=int(input("enter the value: "))
n=0
while(a>0):
a=a//10
n=n+1
print("the digit is :",n)
|
322f76cea04b72cbfe45a6a3caa6f8262dc3ce96 | essenceD/Python_algorythmes | /Lesson_3(Lists)/task_6.py | 1,082 | 3.828125 | 4 | # 6. В одномерном массиве найти сумму элементов, находящихся между минимальным и максимальным элементами.
# Сами минимальный и максимальный элементы в сумму не включать.
from random import randint as rd
base = [rd(1, 20) for j in range(10)]
mx = base[0]
mn = base[0]
res = 0
for i in base:
if i > mx:
... |
3cb7608386af892df8d2a09000e5461ff7abed11 | essenceD/Python_algorythmes | /Lesson_2(Cycles, recursion, functions)/task_2.py | 628 | 4.15625 | 4 | # 2.
# Посчитать четные и нечетные цифры введенного натурального числа.
# Например, если введено число 34560, в нем 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5).
num = input('Enter number to check its digits on parity: ')
even = ''
n_even = 0
odd = ''
n_odd = 0
for i in num:
if int(i) % 2 == 0:
... |
0e0b2a636417c19d1c9f728b727e48ce7aeab4bb | essenceD/Python_algorythmes | /Lesson_2(Cycles, recursion, functions)/task_8.py | 876 | 4.25 | 4 | # 8.
# Посчитать, сколько раз встречается определенная цифра в введенной последовательности чисел.
# Количество вводимых чисел и цифра, которую необходимо посчитать, задаются вводом с клавиатуры.
match, line = 0, ''
print('This program will count the digit you\'ll enter in numbers yo\'ll enter.')
tries = int(inp... |
8a904578a428c18c5b88eb18d2fb2a0118fe8479 | essenceD/Python_algorythmes | /Lesson_3(Lists)/Lesson_.py | 475 | 3.671875 | 4 | from random import randint as rd
def bin_search(arr, val):
left = 0
right = len(arr) - 1
pos = len(arr) // 2
while arr[pos] != val and left <= right:
if val > arr[pos]:
left = pos + 1
else:
right = pos - 1
pos = (left + right) // 2
ret... |
14d51aa002ae049a9324bbe508092973edb6316a | essenceD/Python_algorythmes | /Lesson_3(Lists)/Lesson.py | 1,180 | 3.875 | 4 | # 1
# list_1 = [1, 2, 3, 4]
# list_2 = [1, 2, 3, 4]
# list_3 = [1, 2, 3, 4]
# list_4 = [1, 2, 3, 4]
#
# for i, item in enumerate(list_1):
# del item
# print(list_1)
#
# for i, item in enumerate(list_2):
# list_2.remove(item)
# print(list_2)
#
# for i, item in enumerate(list_3):
# list_3.pop(i... |
00dc772499356c80b40fffda95ba8b74cc852be9 | essenceD/Python_algorythmes | /Lesson_3(Lists)/task_1.py | 450 | 3.703125 | 4 | # 1. В диапазоне натуральных чисел от 2 до 99 определить,
# сколько из них кратны каждому из чисел в диапазоне от 2 до 9.
# Примечание: 8 разных ответов.
ans = {f'Numbers are even {i + 2}':
[j for j in range(2, 100) if j % (i + 2) == 0] for i in range(8)}
for i in ans.keys():
print(f'Total {len(ans[i... |
432edf8a40dbe2304b82cd550e3f289ad8cc3ea5 | essenceD/Python_algorythmes | /Lesson_9(Trees. Hash function)/lesson_task_2.py | 730 | 3.71875 | 4 | # поиск подстроки в строке через хэш
import hashlib
def rabin_karp(s: str, subs: str) -> int:
assert len(s) > 0 and len(subs) > 0, 'Strings should not be empty!'
assert len(s) >= len(subs), 'Substring should be longer than string!'
len_sub = len(subs)
h_subs = hashlib.sha1(subs.encode('utf-8... |
245b7db8f6e03b71f5b8363444364f59e45dde53 | essenceD/Python_algorythmes | /Lesson_1(Simple algorithms)/task_5.py | 337 | 4.09375 | 4 | # 5. Пользователь вводит номер буквы в алфавите. Определить, какая это буква.
num = int(input('Enter id of letter: '))
if 0 < num < 27:
letter = chr(ord('a') + num - 1)
print(f'It is letter "{letter}"')
else:
print(f'There is no letter with id = {num}')
|
b2728782dbb97945597f0372286b414da0e97a75 | pandey-ankur-au17/Python | /coding-challenges/week13/day05/ccQ3.py | 1,048 | 3.71875 | 4 | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def zigzagLevelOrder(self, root: TreeNode):
l_to_r = True
if not root: return
queue = []
queue.append(root)
resu... |
327720b380ef7d2fa891f67c916ba51f91c74769 | pandey-ankur-au17/Python | /coding-challenges/week03/Assignment/AssignmentQ2while.py | 540 | 4.125 | 4 | def by_while_loop():
print("by using while loop ")
n = int(input("Enter the number of lines : "))
line = 1
while (line <= n):
print(" " * (n - line), end="")
digit = 1
while digit <= line:
print(digit, end="")
if line == digit:
rev_digi... |
158bdd6828bc4a720f962b5d329b5b8f8f5a045f | pandey-ankur-au17/Python | /coding-challenges/week04/day01/ccQ2.py | 366 | 4.46875 | 4 | # Write a function fibonacci(n) which returns the nth fibonacci number. This
# should be calcuated using the while loop. The default value of n should be 10.
def fibonacci(n=10):
n1=0
n2=1
count=0
while count<n:
print(n1)
nth=n1+n2
n1=n2
n2=nth
count=count+1
#n=... |
80e9a9380a9df748e2300252836493f124d99142 | pandey-ankur-au17/Python | /coding-challenges/week02/day03/ccQ1.py | 141 | 3.859375 | 4 | name=input("What is your Name:")
age=int(input("What is your age:"))
tel_no=int(input("What is your telephon number:"))
print("Welcome",name) |
3e5131e554e6ea50392e6354b631b87ce24e04c7 | pandey-ankur-au17/Python | /coding-challenges/week13/day03/ccQ1.py | 621 | 3.53125 | 4 | def findMaxPath(mat):
res = -1
for i in range(M):
res = max(res, mat[0][i])
for i in range(1, N):
res = -1
for j in range(M):
if (j > 0 and j < M - 1):
mat[i][j] += max(mat[i - 1][j],
max(mat[i - 1][j - 1],
mat[i - 1][j + 1]))
elif (j > 0):
mat[i][j] += max(mat[i - 1][j]... |
813b8234922e66f1eee8a46ae26b0fc5e2b10ea0 | pandey-ankur-au17/Python | /coding-challenges/week13/day02/ccQ3.py | 523 | 3.671875 | 4 | class Solution:
def longestCommonSubsequence(text1: str, text2: str):
n,m=len(text1),len(text2)
dp=[[0]*(m+1) for _ in range(n+1)]
for i in range(n):
for j in range(m):
if text1[i]==text2[j]:
dp[i+1][j+1]=dp[i][j]+1
else:
... |
3dfcc3a05e15387be8f99da60341585fc548bd68 | pandey-ankur-au17/Python | /coding-challenges/week08/day03/ccQ2.py | 850 | 3.953125 | 4 | # Given a non-empty array of decimal digits representing a non-negative integer, increment one
# to the integer.
# The digits are stored such that the most significant digit is at the head of the list, and each
# element in the array contains a single digit.
# You may assume the integer does not contain any leading zer... |
c830897d5aa2bd691af45ccb59f3bcaa22307d75 | pandey-ankur-au17/Python | /coding-challenges/week07/AssignmentQ1.py | 991 | 4.15625 | 4 | # Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).
# Note:
# Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementati... |
de03cb68fa6097826c52173187bcf3e14b197547 | pandey-ankur-au17/Python | /coding-challenges/week12/day03/heapifyMax_heap.py | 651 | 3.625 | 4 | heap = [1,2,3,4,5,6,7,8,9]
def heapify(i):
global heap
left_idx = 2*i+1
right_idx = 2*i+2
if left_idx >len(heap)-1 and right_idx > len(heap)-1: ## leaf node
return
max_idx = i
if left_idx < len(heap) and heap[i] < heap[left_idx]:
max_idx = left_idx
if rig... |
58bfff25bede8b43e9e236d83d9326a8f0b4b125 | pandey-ankur-au17/Python | /coding-challenges/week07/day04/ccQ3.py | 591 | 4.25 | 4 | # Given an array with NO Duplicates . Write a program to find PEAK
# ELEMENT
# Return value corresponding to the element of the peak element.
# Example :
# Input : - arr = [2,5,3,7,9,13,8]
# Output : - 5 or 13 (anyone)
# HINT : - Peak element is the element which is greater than both
# neighhbours.
def Peak_value(arr)... |
59702581c6dd1ad4e5996da1e570986b67578b6f | pandey-ankur-au17/Python | /coding-challenges/week08/AssignmentQ5.py | 343 | 3.78125 | 4 | def findAppear(nums1, nums2):
repeetNum = []
for i in nums1:
if i in nums2:
repeetNum.append(i)
nums2.remove(i)
return repeetNum
if __name__=="__main__":
nums1 = [1,2]
nums2 = [1,1]
# nums1 = [4,9,5]
# nums2 = [9,4,9,8,4]
result = findAppear(nums1, n... |
d727b7c08eab9667089f1dd1fb10f31cf694e880 | pandey-ankur-au17/Python | /coding-challenges/week08/day04/ccQ2.py | 724 | 4.125 | 4 | # 2) Write a program to print sum of border elements of a square Matrix
# (5 marks)
# Border elements:
# 1 2 3 4
# 4 5 6 5
# 7 8 9 6
# 4 9 8 7
# Sum of border elements = 1+2+3+4+5+6+7+8+9+4+7+4 = 60
def Border_element(a, m, n):
sum = 0
for i in range(m):
for j in range(n):
if (i == 0):
... |
c8f731f882a926f2884002eb386d7720df3f8043 | pandey-ankur-au17/Python | /coding-challenges/week07/AssignmentQ5.py | 661 | 3.765625 | 4 | # Given an array nums of size n, return the majority element.
# The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.
# Example 1:
# Input: nums = [3,2,3]
# Output: 3
# Example 2:
# Input: nums = [2,2,1,1,1,2,2]
# Output: 2... |
51e11b60b256667295f1ec556c61054c4c261e22 | pandey-ankur-au17/Python | /code17_rangoli.py | 828 | 4.09375 | 4 | # You are given an integer, n. Your task is to print an alphabet rangoli of size .
# (Rangoli is a form of Indian folk art based on creation of patterns.)
# Different sizes of alphabet rangoli are shown below:
# #size 3
# ----c----
# --c-b-c--
# c-b-a-b-c
# --c-b-c--
# ----c----
# #size 5
# --------e--------
# ------e-... |
96d8bf84c6a47091bfc968241d223211b83ae745 | pandey-ankur-au17/Python | /coding-challenges/week09/day01/ccQ4.py | 296 | 4.0625 | 4 | def productNum( num , n ):
if num < n:
return productNum(n, num)
elif n != 0:
return (num + productNum(num, n - 1))
else:
return 0
if __name__ == "__main__":
num = 5
n = 2
result = productNum(num, n)
print("Product of", n, "x", num,"is", result) |
726054327ba1e1f2dc981688d88991a9f11b6a9c | pandey-ankur-au17/Python | /coding-challenges/week11/day03/ccQ3.py | 683 | 3.875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeInBetween(self, list1, a, b, list2):
start = None
end = list1
for i in range(b):
if i == a - 1:
... |
caf53aeecb129c7cc935b04ec9615a9b911c681e | pandey-ankur-au17/Python | /coding-challenges/week07/day02/ccQ3.py | 623 | 4.03125 | 4 | # Given an sorted integer array . Write a program to find UPPER Bound of
# target number , return the index of the element .
# Input : - [1,2,2,2,3,3,5,5,5,6,6,8,9] , target = 7
# Output: - 12
def Upper_bound(arr,target):
upper=-1
for i in range(0,len(arr)):
if(arr[i]==target):
upper=i
... |
5866a1e92c62a930e4f727ed1cc4075f808779dd | pandey-ankur-au17/Python | /day02/apartments/bedroom.py | 1,433 | 3.84375 | 4 | class Bedrooms:
def __init__(self):
self.length=30
self.breadth=25
self.height=15
self.beds=None
self.closet=None
self.has_balcony=True
self.has_window=True
self.num_lights=13
self.has_ac=True
self.has_fan=True
self.charging_poi... |
189a80392c829e9b2aa406cd75339df000849a18 | pandey-ankur-au17/Python | /coding-challenges/week03/Assignment/AssignmentQ1.py | 586 | 4.0625 | 4 | # 1. Write code for the following sequence by taking line number as user input:
# n = 5
# **
# **
# **
# **
# **
# n=3
# **
# **
# **
def pattern_1(n):
for i in range(1,n+1):
if i<=n//2+1:
for k in range(1,i):
print(" ",end="")
for l in range(2):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.