blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d6192566a5778e4c5ec9536c5f30db470bca7439 | WeeJang/basic_algorithm | /ShuffleanArray.py | 1,260 | 4.28125 | 4 | #!/usr/bin/env python2
#-*- coding:utf-8 -*-
"""
Shuffle a set of numbers without duplicates.
Example:
// Init an array with set 1, 2, and 3.
int[] nums = {1,2,3};
Solution solution = new Solution(nums);
// Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must equally likely to be returne... | true |
023e609eb767a6e0ec588b79fd38567e82c84225 | JakeJaeHyongKim/I211 | /lab 3-4(list comp, combined number in list).py | 549 | 4.15625 | 4 | #lab practical example
#appeal only what I need as output, #1= sort it
nums = ["123", "321", "435", "2468"]
num_order = [num for num in nums if [digit for digit in num] == \
sorted([digit for digit in num])]
print(num_order)
lst1 = [1,2,3]
lst2 = sorted([1,2,3])
#2= only odd numbers as ... | true |
5bf0db55a5bc7ca89f4e02cc1d0bbf195629bf45 | JakeJaeHyongKim/I211 | /lab 3-3(list comprehension, word to upper case).py | 378 | 4.1875 | 4 | #word list comprehension
#if word contains less than 4 letters, append as upper case
#if not, leave it as it is
words= ["apple", "ball", "candle", "dog", "egg", "frog"]
word = [i.upper() if len(i) < 4 else i for i in words]
#not proper: word = [word.upper() if len(words) < 4 else word for word in words]
#learn ... | true |
6168e7579f4d014b666e617f5ff9869cea0d68b4 | mayanksh/practicePython | /largestarray.py | 521 | 4.34375 | 4 | #def largest(array, n):
# max = array[0] #initialize array
# for i in range (1, n):
# if array[i] > max:
# max = array[i]
# return max
#array = [1,2,3,4,5]
#n = len(array)
#answer = largest(array, n)
#print("largest element is: " , answer)
arr=int(input('Enter the element of an array:')... | true |
970d5bee4acfe240e4891e348336df5486d9b6a5 | gabrslen/estudos | /EntrevistaEmprego/DataModule.py | 769 | 4.25 | 4 | class Entrevista():
nome = ""
ano_informado = 0
idade = 0
def pergunta_nome(self):
self.nome = input("Nome do candidato: ")
print("O nome é '" + self.nome + "'")
return self.nome
def pergunta_idade(self, ano_atual=2021):
self.ano_informado = int(input("Ano de nasci... | false |
d663b392d048396983b8e8ed825b1cd8c7ae013b | apktool/LearnPython | /1.12.01.py | 587 | 4.28125 | 4 | #--coding:utf-8---
#元组
tuple1=(1,2,3,4,5,6,7,8)
print(tuple1)
tuple2=(1)
print(tuple2)
tuple3=(1,)
print(tuple3)
tuple4=1
print(tuple4)
tuple5=1,
print(tuple5)
'''
应该注意tuple2和tuple3的区别:tuple2创建的是一个整数,tuple3创建的是一个元祖
tuple4创建的是一个整数,tuple5创建的是一个元组
'''
a=8*(8)
print(a)
a=8*(8,)
print(a)
'''
第一次打印出的a是64
第二次打印出的a是(... | false |
4a967e2285d09f08261e92df7f719abb0e7d4cf4 | apktool/LearnPython | /3.14.03.py | 1,635 | 4.15625 | 4 | # 命名空间的生命周期
x=1
def fun1():
x=x+1
fun1()
def fun2():
y=123
del y
print(y)
fun2()
'''
UnboundLocalError: local variable 'x' referenced before assignment
UnboundLocalError: local variable 'y' referenced before assignment
'''
'''
不同的命名空间在不同的时刻创建,有不同的生存期。
1、内置命名空间在 Python 解释器启动时创建,会一直保留,不被删除。
2、模块的全局命名空... | false |
617e98aa40ff5d01a7c2e83228c011705de0b928 | timlindenasell/unbeatable-tictactoe | /game_ai.py | 2,347 | 4.3125 | 4 | import numpy as np
def minimax(board, player, check_win, **kwargs):
""" Minimax algorithm to get the optimal Tic-Tac-Toe move on any board setup.
This recursive function uses the minimax algorithm to look over each possible move
and minimize the possible loss for a worst case scenario. For a deeper under... | true |
167b3a56792d0be21f40e0e8d2208fd7943ccddc | Vibhutisavaliya123/DSpractice | /DS practicel 6.py | 1,624 | 4.4375 | 4 | P6#WAP to sort a list of elements. Give user the
option to perform sorting using Insertion sort,
Bubble sort or Selection sort.#
Code:Insertion sort
def insertionSort(arr):
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]
# Move elements of arr[0..... | true |
5d7d4bc98ca3fc5b18b7206343bc8da663b29543 | sergady/Eulers-Problems | /Ej1.py | 354 | 4.15625 | 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.
listNums = []
for i in range(1000):
if(i%3 == 0 or i%5 == 0):
listNums.append(i)
sum = 0
for s in (listNums... | true |
a6b5afea50bfb95264937b9a79cb2cd4677d0d45 | aofrigerio/ordenacoes | /heapsort.py | 821 | 4.21875 | 4 | def heapify(A, n, i):
print(A)
largest = i # Initialize largest as root
l = 2 * i + 1 # left = 2*i + 1
r = 2 * i + 2 # right = 2*i + 2
# See if left child of root exists and is
# greater than root
if l < n and A[i] < A[l]:
largest = l
# See if right child of root exists ... | false |
076a1ff1556bf140d838529270121ebd99ecc86f | halljm/murach_python | /exercises/ch02/test_scores.py | 660 | 4.375 | 4 | #!/usr/bin/env python3
# display a welcome message
print("The Test Scores program")
print()
print("Enter 3 test scores")
print("======================")
# get scores from the user
score1 = int(input("Enter test score: "))
score2 = int(input("Enter test score: "))
score3 = int(input("Enter test score: "))
total_score ... | true |
c2c2bf4bcf47b7a4bc15bbf0b333ff6fe52eda3b | jhertzberg1/bmi_calculator | /bmi_calculator.py | 1,364 | 4.375 | 4 | '''
TODO
Greeting
Create commandline prompt for height
Create commandline prompt for weight
Run calculation
Look up BMI chart
Print results
'''
def welcome():
print('Hi welcome to the BMI calculator.')
def request_height():
height = 0
return height
def request_weight():
'''Commandline user input fo... | true |
a45dc8e608aa095066e98b405fdc4c1719da823a | nealebanagale/python-training | /08_Structured_Data/lists.py | 948 | 4.15625 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
# [] - list are imutable
# () - tuple are not mutable
def main():
game = ['Rock', 'Paper', 'Scissors', 'Lizard', 'Spock']
print(game[1]) # access list elements
print(game[1:5:2]) # same with range's start,stop,step\
i = game.index('Paper... | false |
7df861ce3467cb871fce042f17a4b839f2193379 | Liam-Hearty/ICS3U-Unit5-05-Python | /mailing_address.py | 1,981 | 4.21875 | 4 | #!/usr/bin/env python3
# Created by: Liam Hearty
# Created on: October 2019
# This program finds your mailing address.
def find_mailing_address(street, city, province, postal_code, apt=None):
# returns mailing_address
# process
mailing_address = street
if apt is not None:
mailing_address = ... | true |
cb7e966781a96121035c9489b410fcc1ace84537 | yashaswid/Programs | /LinkedList/MoveLastToFirst.py | 1,325 | 4.28125 | 4 | # Write a function that moves the last element to the front in a given Singly Linked List.
# For example, if the given Linked List is 1->2->3->4->5, then the function should change the list to 5->1->2->3->4
class Node:
def __init__(self,val):
self.data=val
self.next=None
class Linkedli... | true |
4e35112282fbaccdf62d4aea0ae67bd9446e6117 | Viole-Grace/Python_Sem_IV | /3a.py | 1,688 | 4.28125 | 4 | phones=dict()
def addentry():
global phones
name=raw_input("Enter name of the phone:")
price=raw_input("Enter price:")
phones.update({name:price})
def namesearch(name1):
global phones
for key,value in phones.items():
if name1==key:
print "Found, its price is ",value
def price... | true |
571c1db047fd45cf9a73414eb1b246f15ce3f3e3 | hickmanjv/hickmanjv | /CS_4085 Python/Book Examples/coin_toss_demo.py | 401 | 4.25 | 4 | import coin
def main():
# create an object of the Coin class
my_coin = coin.Coin()
# Display the side of the coin that is facing up
print('This side is up: ', my_coin.get_sideup())
# Toss the coin 10 times:
print('I am going to toss the coin 10 times:')
for count in range(10):
my_... | true |
94b508503ea89642213964b07b0980ca81e354e2 | lucaslb767/pythonWorkOut | /pythonCrashCourse/chapter6/favorite_languages.py | 567 | 4.375 | 4 | favorite_languages = {
'jen':'python',
'sarah':'C',
'jon':'ruby'
}
print('Jon favorite language is ', favorite_languages['jon'])
friends = ['sarah']
#using a list to sort a dictionary's value
for name in favorite_languages:
print(name.title())
if name in friends:
print('Hi', name.title()... | true |
6c543e8cfcb156f3265e3bbd01b287af45c318f3 | MariaBT/IS105 | /ex3.py | 961 | 4.34375 | 4 | # Only text describing what will be done
print "I will count my chickens:"
# Print the result of the number of hens
print "Hens", 25 + 30 / 6
# Print the result of the number of roosters
print "Roosters", 100 - 25 * 3 % 4
# Plain text explaining what will be done next
print "Now I will count the eggs:"
# The resu... | true |
879c5858fa8ab9debf0c78559777687fbd2e2d6f | saikrishna-ch/five_languages | /pyhton/NpowerN.py | 252 | 4.28125 | 4 | Number = int(input("Enter a number to multilply to itself by it's number of times:"))
print("{} power {} is".format(Number, Number), end = "")
Product = 1
for Counter in range(Number):
Product = Product * Number
print(" {}.".format(Product))
| true |
83d64472efeab83b8b86036ebfd02cdb26aa79ea | pinstinct/wps-basic | /day6/practice/p2.py | 612 | 4.21875 | 4 | def what_fruits(color):
'''
문자열 color 값을 매개변수로 받아
문자열이 red면 apple,
yellow면 banana,
green이면 melon을 반환한다.
어떤 경우도 아니라면 I don't know 반환
'''
if color == 'red':
return 'apple'
elif color == 'yellow':
return 'banana'
elif color == 'green':
return 'melon'
else... | false |
eff66e25423e884613d98d1093088ec9a4ae084c | thebishaldeb/ClassAssignments | /Algorithms/Assign7/main.py | 1,710 | 4.25 | 4 | #=============== FUNCTIONS START ===============
# merge function for merge sort algorithm to sort an array
def merge(arr, l, m, r ):
n1 = m - l + 1
n2 = r - m
L = [0] * (n1)
R = [0] * (n2)
for i in range(0 , n1):
L[i] = arr[l + i]
for j in range(0 , n2):
R[j] = arr[m + ... | false |
baf1307dfe88b63e00bebd58aff86921d017e331 | acronoo/lesson1 | /homework1.1.py | 737 | 4.28125 | 4 | # 1. Поработайте с переменными, создайте несколько, выведите на экран,
# запросите у пользователя несколько чисел и строк и сохраните в переменные, выведите на экран.
a = 5
print("a = ", a)
b = 20
print("b = ", b)
value = a + b
print(f"a + b = {a} + {b} = {value}")
user_input1 = input("Что бы получить результат умножен... | false |
90cb2d16b1457623097c5c0edbe7170b3756e767 | MahadiRahman262523/Python_Code_Part-1 | /practice_problem-28.py | 485 | 4.40625 | 4 | #write a program to print multiplication table of a given number
#using for loop
# num = int(input("Enter any number : "))
# for i in range(1,11):
# # print(str(num) + " X " + str(i) + " = " + str(i*num))
# print(f"{num} X {i} = {i*num}")
#write a program to print multiplication table of a given... | false |
b4e26837cb1813bb939df3c6f783aea9f0d7eb88 | MahadiRahman262523/Python_Code_Part-1 | /operators.py | 883 | 4.53125 | 5 | # Operators in Python
# Arithmetic Operators
# Assignment Operators
# Comparison Operators
# Logical Operators
# Identity Operators
# Membership Operators
# Bitwise Operators
# Assignment Operator
# print("5+6 is ",5+6)
# print("5-6 is ",5-6)
# print("5*6 is ",5*6)
# print("5/6 is ",5/6)
# print("16//6... | true |
377f7632417faaed3d23bd456f29ec516b5c024c | MahadiRahman262523/Python_Code_Part-1 | /practice_problem-39.py | 231 | 4.25 | 4 | # Write a python function to print first n lines of
# the following pattern :
# * * *
# * * for n = 3
# *
n = int(input("Enter any number to print pattern : "))
for i in range(n):
print("*" * (n-i))
| false |
d5075d4831f900cb4f12665365babefb4ecd098e | MahadiRahman262523/Python_Code_Part-1 | /practice_problem-18.py | 488 | 4.1875 | 4 | # Write a program to input eight numbers from the user and display
# all the unique numbers
num1 = int(input("Enter number 1 : "))
num2 = int(input("Enter number 2 : "))
num3 = int(input("Enter number 3 : "))
num4 = int(input("Enter number 4 : "))
num5 = int(input("Enter number 5 : "))
num6 = int(input("Ente... | false |
6141032532599c2a7f307170c680abff29c6e526 | MahadiRahman262523/Python_Code_Part-1 | /practice_problem-25.py | 340 | 4.34375 | 4 | # Write a program to find whether a given username contaoins less than 10
# characters or not
name = input("Enter your name : ")
length = len(name)
print("Your Name Length is : ",length)
if(length < 10):
print("Your Name Contains Less Than 10 Characters")
else:
print("Your Name Contains greater ... | true |
e948c889e9443b2d4ded69459a273ad43f72b0c0 | xuelang201201/FluentPython | /03_字典和集合/fp_10_集合论.py | 1,047 | 4.1875 | 4 | # 集合的本质是许多唯一对象的聚集。因此,集合可以用于去重。
my_list = ['spam', 'spam', 'eggs', 'spam']
print(set(my_list))
print(list(set(my_list)))
"""
例如,我们有一个电子邮件地址的集合(haystack),还要维护一个较小
的电子邮件地址集合(needles),然后求出 needles 中有多少地址同时
也出现在了 haystack 里。借助集合操作,我们只需要一行代码就可以了。
"""
# needles 的元素在 haystack 里出现的次数,两个变量都是 set 类型
# found = len(need... | false |
b282ba54703d292c9d9a30aebdcf88913905b2a5 | xuelang201201/FluentPython | /02_数据结构/fp_13_一个包含3个列表的列表,嵌套的3个列表各自有3个元素来代表井字游戏的一行方块.py | 589 | 4.125 | 4 | # 建立一个包含3个列表的列表,被包含的3个列表各自有3个元素。打印出这个嵌套列表。
board = [['_'] * 3 for i in range(3)]
print(board)
# 把第1行第2列的元素标记为 X,再打印出这个列表。
board[1][2] = 'X'
print(board)
# 等同于
board = []
for i in range(3):
# 每次迭代中都新建了一个列表,作为新的一行(row)追加到游戏板(board)。
row = ['_'] * 3
board.append(row)
print(board)
board[2][0] = '... | false |
9ef906ae918956dbdb2f48ea660293284b719a94 | asselapathirana/pythonbootcamp | /2023/day3/es_1.py | 2,425 | 4.34375 | 4 | import numpy as np
"""Fitness function to be minimized.
Example: minimize the sum of squares of the variables.
x - a numpy array of values for the variables
returns a single floating point value representing the fitness of the solution"""
def fitness_function(x):
return np.sum(x**2) # Example: minimiz... | true |
6c375d41e8430694404a45b04819ef9e725db959 | asselapathirana/pythonbootcamp | /archives/2022/day1/quad.py | 781 | 4.15625 | 4 | # first ask the user to enter three numbers a,b,c
# user input is taken as string(text) in python
# so we need to convert them to decimal number using float
a = float(input('Insert a value for variable a'))
b = float(input('Insert a value for variable b'))
c = float(input('Insert a value for variable c'))
# now print ... | true |
cddcfc2c1a2d3177bcf784c7a09fd3fb1f2a69ec | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 1/Problem/Mathematics/Exactly 3 Divisors.py | 1,438 | 4.25 | 4 | Exactly 3 Divisors
Given a positive integer value N. The task is to find how many numbers less than or equal to N have numbers of divisors exactly equal to 3.
Example 1:
Input:
N = 6
Output: 1
Explanation: The only number with
3 divisor is 4.
Example 2:
Input:
N = 10
Output: 2
Explanation... | true |
519a1790c47049f2f6a47a6362d45a6821c3252b | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 3/Strings/Problems/Convert to Roman No.py | 1,354 | 4.3125 | 4 | Convert to Roman No
Given an integer n, your task is to complete the function convertToRoman which prints the corresponding roman number of n. Various symbols and their values are given below.
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
Example 1:
Input:
n = 5
Output: V
Example 2:
Input:
n =... | true |
dab1464351b112f48570a5bf6f23c42912163925 | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 9/Heap/Problems/Nearly sorted.py | 2,018 | 4.1875 | 4 | Nearly sorted
Given an array of n elements, where each element is at most k away from its target position, you need to sort the array optimally.
Example 1:
Input:
n = 7, k = 3
arr[] = {6,5,3,2,8,10,9}
Output: 2 3 5 6 8 9 10
Explanation: The sorted array will be
2 3 5 6 8 9 10
Example 2:
Input:
n = 5... | true |
741480f8b2500ef939b9951b4567f5b16172379a | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 1/Problem/Arrays/Find Transition Point.py | 1,237 | 4.1875 | 4 | Find Transition Point
Given a sorted array containing only 0s and 1s, find the transition point.
Example 1:
Input:
N = 5
arr[] = {0,0,0,1,1}
Output: 3
Explanation: index 3 is the transition
point where 1 begins.
Example 2:
Input:
N = 4
arr[] = {0,0,0,0}
Output: -1
Explanation: Since, there i... | true |
0e9e0bab41e6810a4b6c41d69ae01df699977570 | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 3/Matrix/Transpose of Matrix.py | 1,798 | 4.59375 | 5 | Transpose of Matrix
Write a program to find the transpose of a square matrix of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows.
Example 1:
Input:
N = 4
mat[][] = {{1, 1, 1, 1},
{2, 2, 2, 2}
{3, 3, 3, 3}
{4, 4, 4, 4}}
Output:
... | true |
48c9c87ca2976207c5f379fd9b42df86faa877b5 | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 4/Linked LIst/Reverse a Linked List in groups of given size.py | 2,725 | 4.25 | 4 | Reverse a Linked List in groups of given size.
Given a linked list of size N. The task is to reverse every k nodes (where k is an input to the function) in the linked list.
Example 1:
Input:
LinkedList: 1->2->2->4->5->6->7->8
K = 4
Output: 4 2 2 1 8 7 6 5
Explanation:
The first 4 elements 1,2,2,4 are r... | true |
b1acad41a07b4a5a1b38fdad15619ebeec5dd70d | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 3/Bit Magic/Rightmost different bit.py | 1,708 | 4.15625 | 4 | Rightmost different bit
Given two numbers M and N. The task is to find the position of the rightmost different bit in the binary representation of numbers.
Example 1:
Input: M = 11, N = 9
Output: 2
Explanation: Binary representation of the given
numbers are: 1011 and 1001,
2nd bit from right is differen... | true |
27f267d66c25e89ed823ddd1f003b33fe09cc3cc | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 1/Problem/Arrays/Remove duplicate elements from sorted Array.py | 1,554 | 4.1875 | 4 | Remove duplicate elements from sorted Array
Given a sorted array A of size N, delete all the duplicates elements from A.
Example 1:
Input:
N = 5
Array = {2, 2, 2, 2, 2}
Output: 2
Explanation: After removing all the duplicates
only one instance of 2 will remain.
Example 2:
Input:
N = 3
Array = ... | true |
4a44a1c4851060d4114ea4ae3d509800781378e0 | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 3/Strings/Problems/Longest Substring Without Repeating Characters.py | 2,507 | 4.125 | 4 | Longest Substring Without Repeating Characters
Given a string S, find the length of its longest substring that does not have any repeating characters.
Example 1:
Input:
S = geeksforgeeks
Output: 7
Explanation: The longest substring
without repeated characters is "ksforge".
Example 2:
Input:
S = abbcd... | true |
d3d0dabc882f6021df69bebe4a00e4b97c6878bf | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 9/Heap/Problems/Heap Sort.py | 2,223 | 4.3125 | 4 | Heap Sort
Given an array of size N. The task is to sort the array elements by completing functions heapify() and buildHeap() which are used to implement Heap Sort.
Example 1:
Input:
N = 5
arr[] = {4,1,3,9,7}
Output:
1 3 4 7 9
Explanation:
After sorting elements
using heap sort, elements will be
in order as 1,3,4,7,... | true |
0bb5128f7e3bbd1ee480e189c182cb7933143ae1 | Harini-Pavithra/GFG-11-Week-DSA-Workshop | /Week 3/Strings/Problems/Isomorphic Strings.py | 2,802 | 4.4375 | 4 | Isomorphic Strings
Given two strings 'str1' and 'str2', check if these two strings are isomorphic to each other.
Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2 while preserving the order.
Note: All occurrences of eve... | true |
261cfa1feb28124e9113c400707c5dedf9e30249 | Technicoryx/python_strings_inbuilt_functions | /string_08.py | 609 | 4.40625 | 4 | """Below Python Programme demonstrate expandtabs
functions in a string"""
#Case1 : With no Argument
str = 'xyz\t12345\tabc'
# no argument is passed
# default tabsize is 8
result = str.expandtabs()
print(result)
#Case 2:Different Argument
str = "xyz\t12345\tabc"
print('Original String:', str)
# tabsize is set to 2
p... | true |
cf11c056ca6697454d3c585e6fa6eea6a153deae | Technicoryx/python_strings_inbuilt_functions | /string_06.py | 204 | 4.125 | 4 | """Below Python Programme demonstrate count
functions in a string"""
string = "Python is awesome, isn't it?"
substring = "is"
count = string.count(substring)
# print count
print("The count is:", count)
| true |
da915e308927c3e5ed8eb0f96937f10fd320c8ab | Technicoryx/python_strings_inbuilt_functions | /string_23.py | 360 | 4.46875 | 4 | """Below Python Programme demonstrate ljust
functions in a string"""
#Example:
# example string
string = 'cat'
width = 5
# print right justified string
print(string.rjust(width))
#Right justify string and fill the remaining spaces
# example string
string = 'cat'
width = 5
fillchar = '*'
# print right justified stri... | true |
68285e9fdf5413e817851744d716596c0ff2c926 | anton515/Stack-ADT-and-Trees | /queueStackADT.py | 2,893 | 4.25 | 4 |
from dataStructures import Queue
import check
# Implementation of the Stack ADT using a single Queue.
class Stack:
'''
Stack ADT
'''
## Stack () produces an empty stack.
## __init__: None -> Stack
def __init__(self):
self.stack = Queue ()
## isEmpty(self) returns True if the... | true |
ce6d86586bb5d7030312ade00c8fc3ca7a0d2273 | vamsi-kavuru/AWS-CF1 | /Atari-2.py | 1,182 | 4.28125 | 4 | from __future__ import print_function
print ("welcome to my atari adventure game! the directions to move in are defined as left, right, up, and down. Enjoy.")
x = 6
y = -2
#move = str(input('Make your move! Type in either "Left", "Right", "Up", "Down" or type "Exit" to exit the game:')).lower()
def game():
globa... | true |
562c78526d055d1ca782cc39096decf79a585bb6 | AmbyMbayi/CODE_py | /Pandas/Pandas_PivotTable/Question1.py | 310 | 4.125 | 4 | """write a pandas program to create a pivot table with multiple indexes from a given excel sheet
"""
import pandas as pd
import numpy as np
df = pd.read_excel('SaleData.xlsx')
print(df)
print("the pivot table is shown as: ")
pivot_result = pd.pivot_table(df, index=["Region", "SalesMan"])
print(pivot_result) | true |
16e1a288f8866c3c82b6bba997753cab5ff085c2 | harshitmanek/savc | /index.py | 1,083 | 4.1875 | 4 |
def main():
print "**************MENU*******************"
print "1]VOLUME OF CUBE"
print "2]SURFACE AREA OF CUBE"
print "3]VOLUME OF CUBOID"
print "4]SURFACE AREA OF CUBOID"
e=int(raw_input("\n\t\tenter your choice:"))
if(e==1):
cube_volume()
elif(e==2):
cube_surface_ar... | false |
8b0716fd554604776390c6f6ab40619d19fc5e12 | KWinston/PythonMazeSolver | /main.py | 2,559 | 4.5 | 4 | # CMPT 200 Lab 2 Maze Solver
#
# Author: Winston Kouch
#
#
# Date: September 30, 2014
#
# Description: Asks user for file with maze data. Stores maze in list of lists
# Runs backtracking recursive function to find path to goal.
# Saves the output to file, mazeSol.txt. If no file given, it wil... | true |
7505b339bb908d006e9d2b7ee8eb8dbc43140bdc | baidongbin/python | /疯狂Python讲义/codes/05/5.2/default_param_test2.py | 448 | 4.25 | 4 | # 定义一个打印三角形的函数,有默认值的参数必须放在后面
def printTriangle(char, height=5):
for i in range(1, height + 1):
# 先打印一排空格
for j in range(height - 1):
print(' ', end='')
# 再打印一排特殊字符
for j in range(2 * i - 1):
print(char, end='')
print()
printTriangle('@', 6)
printTria... | false |
b37a727c6653dafcfa480283e68badbd87c408f2 | skynette/Solved-Problems | /Collatz.py | 1,737 | 4.3125 | 4 | question = """The Collatz Sequence
Write a function named collatz() that has one parameter named number. If
number is even, then collatz() should print number // 2 and return this value.
If number is odd, then collatz() should print and return 3 * number + 1. Then write a program that
lets the user type in an inte... | true |
0081eac284bb86e948aeef7e933796385df12000 | ddbs/Accelerating_Dual_Momentum | /functions.py | 374 | 4.15625 | 4 | from datetime import datetime, date
def start_of_year(my_date):
"""
Gives the starting date of a year given any date
:param my_date: date, str
:return: str
"""
my_date = datetime.strptime(my_date, '%Y-%m-%d')
starting_date = date(my_date.year, my_date.month, 1)
starting_date = starti... | true |
d545e90149dfca91045aed7666b8456644c8f9a8 | jyotisahu08/PythonPrograms | /StringRev.py | 530 | 4.3125 | 4 | from builtins import print
str = 'High Time'
# Printing length of given string
a = len(str)
print('Length of the given string is :',a)
# Printing reverse of the given string
str1 = ""
for i in str:
str1 = i + str1
print("Reverse of given string is :",str1)
# Checking a given string is palindrome or not
str2 = 'abb... | true |
d5e49df7f61a6e15cf1357aa09e33a81e186627b | Botany-Downs-Secondary-College/password_manager-bunda | /eason_loginV1.py | 2,002 | 4.4375 | 4 | #password_manager
#store and display password for others
#E.Xuan, February 22
name = ""
age = ""
login_user = ["bdsc"]
login_password = ["pass1234"]
password_list = []
def menu(name, age):
if age < 13:
print("Sorry, you do not meet the age requirement for this app")
exit()
else... | true |
baa45a884596594e89c2ca311973bf378c756e77 | SinCatGit/leetcode | /00122/best_time_to_buy_and_sell_stock_ii.py | 1,574 | 4.125 | 4 | from typing import List
class Solution:
def maxProfit(self, prices: List[int]) -> int:
"""
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maxim... | true |
c5eadaf692c43bc0ad5acf88104403ca6b7266dc | HarryVines/Assignment | /Garden cost.py | 323 | 4.21875 | 4 | length = float(input("Please enter the length of the garden in metres: "))
width = float(input("Please enter the width of the garden in metres: "))
area = (length-1)*(width-1)
cost = area*10
print("The area of your garden is: {0}".format(area))
print("The cost to lay grass on your garden is : £{0}".format(cost))
... | true |
c9dadcd37ac16013e6a9c23aa3afe411bacd400e | jhuang09/GWC-2018 | /Data Science/attack.py | 2,488 | 4.34375 | 4 | # This project checks to see if your password is a strong one
# It works with longer passwords, but not really short ones.
# That's because since each letter is considered a word in the dictionary.txt file,
# any password that contains just letters will be considered as a word/not a strong password.
# To alleviate ... | true |
32c4a398d4cc157611fb6827fce531ecbb82f431 | GeraldShin/PythonSandbox | /OnlineCode.py | 1,851 | 4.28125 | 4 | #This will be snippets of useful code you find online that you can copy+paste when needed.
#Emoji Package
#I don't know when this will ever be helpful, but there is an Emoji package in Python.
$ pip install emoji
from emoji import emojize
print(emojize(":thumbs_up:")) #thumbs up emoji, check notes for more.
#List ... | true |
9e304793cd98bac00cc967be51c1c3da49dd8639 | Isaac-D-Dawson/Homework-Uploads | /PyCheckIO/ReverseEveryAscending.py | 2,396 | 4.46875 | 4 | # Create and return a new iterable that contains the same elements as the argument iterable items, but with the reversed order of the elements inside every maximal strictly ascending sublist. This function should not modify the contents of the original iterable.
# Input: Iterable
# Output: Iterable
# Precondition: I... | true |
b440d0252e9ed8a9bc3f84b569a31f819225302a | Isaac-D-Dawson/Homework-Uploads | /PyCheckIO/DateTimeConverter.py | 1,685 | 4.5 | 4 | # Computer date and time format consists only of numbers, for example: 21.05.2018 16:30
# Humans prefer to see something like this: 21 May 2018 year, 16 hours 30 minutes
# Your task is simple - convert the input date and time from computer format into a "human" format.
# example
# Input: Date and time as a string
# ... | true |
239f81592f5c85411d53ced66e13b7ec94218b97 | Isaac-D-Dawson/Homework-Uploads | /PyCheckIO/MedianOfThree.py | 1,536 | 4.375 | 4 | # Given an iterable of ints , create and return a new iterable whose first two elements are the same as in items, after which each element equals the median of the three elements in the original list ending in that position.
# Wait...You don't know what the "median" is? Go check out the separate "Median" mission on Ch... | true |
f4fc59d24310afd8a4fb778ad743d194cc0c1e2a | Isaac-D-Dawson/Homework-Uploads | /PyCheckIO/MorseDecoder.py | 2,122 | 4.125 | 4 | # Your task is to decrypt the secret message using the Morse code.
# The message will consist of words with 3 spaces between them and 1 space between each letter of each word.
# If the decrypted text starts with a letter then you'll have to print this letter in uppercase.
# example
# Input: The secret message.
# Out... | true |
50deb4603696cf2de54543fdc813df491944525c | BerkeleyPlatte/competitiveCode | /weird_string_case.py | 958 | 4.4375 | 4 | #Write a function toWeirdCase (weirdcase in Ruby) that accepts a string, and returns the same string with all even indexed characters in each word upper cased, and all odd
#indexed characters in each word lower cased. The indexing just explained is zero based, so the zero-ith index is even, therefore that character sh... | true |
89708757e3ec29b31feef559b24ff8b3a336c6e5 | gab-umich/24pts | /fraction.py | 1,979 | 4.1875 | 4 | from math import gcd
# START OF CLASS DEFINITION
# EVERYTHING IS PUBLIC
class Fraction:
"""A simple class that supports integers and four operations."""
numerator = 1
denominator = 1
# Do not modify the __init__ function at all!
def __init__(self, nu, de):
"""Assign numerator and denominat... | true |
1fb18bf77b33d4e911364ff771b8ea1bb11c20cc | Luoxsh6/CMEECourseWork | /Week2/code/tuple.py | 980 | 4.5625 | 5 | #!/usr/bin/env python
"""Practical of tuple with list comprehension"""
__author__ = 'Xiaosheng Luo (xiaosheng.luo18@imperial.ac.uk)'
__version__ = '0.0.1'
birds = (('Passerculus sandwichensis', 'Savannah sparrow', 18.7),
('Delichon urbica', 'House martin', 19),
('Junco phaeonotus', 'Yellow-eyed junc... | true |
9b6ec7f52421503518ec981ff9b61145fbe03e6b | Ishani2627/PythonAssignment11 | /Class11.py | 555 | 4.15625 | 4 | #Que1
print("1. find valid email address")
import re
email = input("enter an email address : ")
if re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$', email):
print("valid email address")
else:
print("invalid email address")
print("\n")
#Que2
print("2. find valid indian phone numbe... | false |
8e11531642b2dfb6460f5240499eba2c1fd7e8d9 | YuvalSK/curexc | /cod.py | 1,872 | 4.3125 | 4 | import exrates
import datetime
import sys
def inputdate(date_text):
'''function that inputs a date, and verified if the date is in a vaild format, else return False
'''
try:
datetime.datetime.strptime(date_text, '%Y-%m-%d')
return True
except ValueError:
... | true |
1114c211c01850695d172cab82d0d544640e2f91 | AdarshRise/Python-Nil-to-Hill | /1. Nil/6. Function.py | 1,618 | 4.53125 | 5 | # Creating Function
# function are created using def
def fun():
print(" function got created ")
def fun2(x):
print("value of x is :",x)
# a bit complex use of function
def fun3(x):
x=x*x
print("value of x*x is ",x)
# above code will execute from here
x=2
fun()
fun2(x)
fun3(x)
print(x) # the valu... | true |
a9917be09fdd70e78780145231214f1bc833ef95 | mpwesthuizen/eng57_python | /dictionairies/dictionairies.py | 1,292 | 4.46875 | 4 | # Dictionairies
# definitions
# a dictionary is a data structure, like a list, but organised with a key and not indexes
# They are organised with key: 'value' pairs
# for example 'zebra': "an african wild animal that looks like a horse but has stripes on its body."
# this means you can search data using keys, rather ... | true |
89f05b07503462748e7cf512d7132e6dcd901390 | yingchuanfu/Python | /com/python7/FunctionClass.py | 856 | 4.28125 | 4 | # -*- coding: UTF-8 -*-
#抽象函数:类(在Python中,类具有封装,继承,多态,但是没有重载)
#self参数
class Person:
#定义类的数据成员:姓名,年龄
name = ''
age = 0
#定义构造函数,用于创建一个类实例,也就是类的具体对象
#通过参数传递,可以赋予对象初始状态
def __init__(self, name, age):
self.name = name
self.age = age
#定义一个函数:打印类实例的基本信息
def printPersionInfo(self... | false |
c0901965ca658c1eb3a7c93624513527f4559564 | Mayank-Chandra/LinkedList | /LinkedLIst.py | 1,135 | 4.28125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
def push(self,new_data):
new_node=Node(new_data)
new_node.next=self.head
self.head=new_node
def insertAfter(self,prev_node,new_data):
... | true |
fc78e85199164a95411cfb14411be9128603366e | JeweL645/restart | /slicing.py | 473 | 4.125 | 4 |
fav_food = ["pizza","pasta","bbq_rice","nachos","milk_shakes","ice_cream"]
#print(fav_food)
for food in fav_food:
print(food.title()+"!!")
print("First three items in the list are:\n")
for food in fav_food[:3]:
print(food.title())
print("The three item in the middle of the list are :")
for foo... | false |
461085bffe23b8dd9873de328d4a859beb12e3ab | jcjc2019/edX-MIT6.00.1x-IntroToComputerScience-ProgrammingUsingPython | /Program2-ndigits.py | 405 | 4.125 | 4 | # below is the function to count the number of digits in a number
def ndigits(x):
# when x is more than 0
if x > 0:
#change type to string, count the length of the string
return len(str(int(x)))
# when x is less than 0
elif x < 0:
#get the absolute value, change type to string, a... | true |
04623021d338f1b390d12cb951a37b86a828ab30 | SouzaCadu/guppe | /Secao_12_Modulos/12_80_Oq_sao_modulos_Random.py | 1,413 | 4.34375 | 4 | """
Módulos e módulo Random
Em Python módulos são outros arquivos Python com funções. Devem ser instalados e/ou importados.
O módulo Random possui diversas funções para gerar números pseudo aleatórios.
Existem duas formas de utilizar um módulo:
Importando todo o módulo todas as funções, atributos, classes e proprie... | false |
f7abd2c7092c7e148e47391dc2b9e78d7cb2fc72 | SouzaCadu/guppe | /Secao_08_Funcoes/08_47_funcoes_com_parâmetro_padrão.py | 1,916 | 4.65625 | 5 | """
Funções com parâmetro padrão
- funções onde a passagem de parâmetro seja opcional, ou seja, quando eu
estabeleço um valor padrão para o parâmetro, se o usuário informar um valor
como argumento será usado o valor do argumento passado pelo usuário
- ao usar valores padrão eles DEVEM estar no final da declaração ... | false |
c9db169a66d3166f20fc1aed6fa32b144b941990 | SouzaCadu/guppe | /Secao_11_Debugando_tratando_erros/11_76_Try_except_else_finally.py | 1,367 | 4.1875 | 4 | """
Try / Except / Else / Finally
Toda a entrada de dados, principalmente do usuário, deve ser tratada!
Else: É executado apenas se não acontecer o erro
try:
num = int(input("Informe um número: "))
except ValueError:
print("Valor incorreto.")
else:
print(f"Você digitou {num}.")
Finally: É sempre execut... | false |
b51cf9502c680d0c5f6c42c71cff8e8611151c84 | SouzaCadu/guppe | /Secao_13_Lista_Ex_29e/ex_22.py | 2,572 | 4.3125 | 4 | """
22) Faça um programa que recebe como entrada o nome de um arquivo de entrada e o nome de um arquivo saída.
O arquivo de entrada contém o nome de um aluno ocupando 40 caracteres e três inteiros que indicam suas notas.
O programa deverá ler o arquivo de entrada e gerar um arquivo de saída onde aparece o nome ... | false |
a91cf7747fcd974eae0a0ea95261d82b8aaac1d7 | SouzaCadu/guppe | /Secao_08_Lista_Ex_73e/ex_23.py | 346 | 4.25 | 4 | """
escreva uma função que gere um triângulo lateral de
altura 2*n-1 e n de largura
"""
def triangulo_lateral(num):
linha = ""
for i in range (2 * num - 1):
if i < num:
linha += "*" * (i + 1) + "\n"
else:
linha += (2 * num - (i + 1)) * "*" + "\n"
return linha
print... | false |
1c5fb28c1c667af22fc2c1737d1113856a7b1b5c | SouzaCadu/guppe | /Secao_07_Lista_Ex_25e/ex_25.py | 2,415 | 4.15625 | 4 | """
faça um programa para determinar a próxima jogada em jogo da velha
o tabuleiro é uma matriz 3 x 3
"""
from collections import Counter
print('Jogo da velha')
def linha_check(matriz, i):
"""Função para conferir o número de X/O na linha i de matriz.
Retorna 1 se há 3 X's, -1 se há 3 O's, e 0 caso contrá... | false |
54d1eb3bad846f3eeb01994f308b6f732456b15a | SouzaCadu/guppe | /Secao_13_Lista_Ex_29e/ex_11.py | 1,204 | 4.15625 | 4 | """
11) Faça um programa no qual o usuário informa o nome do arquivo e uma palavra, e retorne o número de vezes que aquela
palavra aparece no arquivo.
"""
from collections import Counter
def cont_palavra(texto, palavra):
"""
Conta quantas vezes uma palavra aparece em um texto extamente como o usuário inf... | false |
4a256bfa77951822529589070833c54141adafc5 | SouzaCadu/guppe | /Secao_10_Expressoes_Lambdas_Funcoes_Integradas/10_64_Any_All.py | 999 | 4.125 | 4 | """
Any e All
all(): retorna True se todos os elementos do iterável são verdadeiros ou ainda se o iterável está vazio
Exemplos
print(all([0, 1, 2, 3, 4]), all([1, 2, 3, 4]), all({}),
all("Geek University"))
nomes = ["carlos", "cristiano", "castro", "cassiano", "carina", "camilla"]
print(all([nome[0] == "c" f... | false |
77bf5f64defe7712ddaff8000265bd881a7240bb | SouzaCadu/guppe | /Secao_06_Lista_Ex_62e/ex_40.py | 604 | 4.125 | 4 | """
Faça um programa que leia vários números inteiros positivos
se um número negativo for digitado o programa deve ser encerrado
e exibir o maior e o menor valor
"""
i = 1
menor = maior = 0
print("Digite quantos números inteiros positivos desejar\n"
"ao digitar um inteiro negativo serão exibidos\n"
"o mai... | false |
3601cd2ab4dbfcb4671215627f24a815381a9db2 | SouzaCadu/guppe | /Secao_19_Manipulando_data_hora/19_136_Manipulando_data_hora.py | 891 | 4.125 | 4 | """
Manipulando data e hora
import datetime
print(dir(datetime))
print(datetime.MINYEAR, datetime.MAXYEAR)
print(datetime.datetime, datetime.datetime.now()) # <class 'datetime.datetime'>, 2021-02-12 19:12:35.202509
print(repr(datetime.datetime.now())) # datetime.datetime(2021, 2, 12, 19, 13, 56, 852411)
inicio ... | false |
ae2be8154746d3a5a62fb76e92f6e1d1b6e7932a | SouzaCadu/guppe | /Secao_06_Lista_Ex_62e/ex_32.py | 735 | 4.21875 | 4 | """
faça um programa que simula o lançamento de dois dados n
vezes e tenha como saída:
- o número de cada dado
- a relação entre eles (>, <, =) de cada lançamento
"""
from random import randint
n = int(input("Digite 1 para girar os dados ou 2 para sair: "))
while n != 2:
d1 = randint(1, 6)
d2 = randint(1, 6)... | false |
265ce887362d8f699b0bc7a41d508d03c699689d | SouzaCadu/guppe | /Secao_07_Colecoes/07_40_module_collections_named_tuple.py | 627 | 4.21875 | 4 | """
Módulo Collections - Named Tuple
São tuplas para as quais especificamos um nome, para a tupla e para os parametros
facilitando o acesso a informação.
Aceita os mesmo métodos usados em tuplas
"""
from collections import namedtuple
cachorro1 = namedtuple("cachorro", "raça idade origem")
cachorro2 = namedtuple("ca... | false |
f3adc9411761ca5836799f1ae448c4e80f5ab983 | SouzaCadu/guppe | /Secao_06_Lista_Ex_62e/ex_47.py | 1,779 | 4.375 | 4 | """
Dadas as operações fundamentais da matemática,
faça um programa que permita ao usuário escolher
a operação obter o resultado e voltar ao menu
"""
print("Selecione uma das opções para o cálculo das operações\n"
"entre 2 números:\n"
"1 - adição\n"
"2 - subtração\n"
"3 - multiplicação\n"
... | false |
2a95d388f5dfde00a6d5f6c7eeb3c04ee54954ae | SouzaCadu/guppe | /Secao_08_Lista_Ex_73e/ex_14.py | 921 | 4.15625 | 4 | """
faça uma função que receba a distância em KM e a quantidade de litros
de gasolina consumidos por um carro e calcule o consumo em
KM / L e escreva a mensagem de acordo com a tabela
- se menor que 8: venda o carro
- entre 8 e 14 econômico
- maior que 14 super econômico
"""
def avalia_consumo(km, litros):
"""
... | false |
8952a219e349498121e00fc45c06c53b19e92b65 | earl-grey-cucumber/Algorithm | /353-Design-Snake-Game/solution.py | 1,815 | 4.1875 | 4 | class SnakeGame(object):
def __init__(self, width,height,food):
"""
Initialize your data structure here.
@param width - screen width
@param height - screen height
@param food - A list of food positions
E.g food = [[1,1], [1,0]] means the first food is positioned at ... | true |
934d86b9bb48d249c79c5a85d053c62a2b6b5775 | prokarius/hello-world | /Python/BellRinging.py | 714 | 4.125 | 4 | # n = 2: [(1, 2), (2, 1)]
# n = 3:
# ( 1 , 2 ,*3*)
# ( 1 ,*3*, 2 )
# (*3*, 1 , 2 )
# (*3*, 2 , 1 )
# ( 2 ,*3*, 1 )
# ( 2 , 1 ,*3*)
# Solution to recurse
def recurse(n):
if n == 1:
return [["1"]]
out = []
flag = False
for i in recurse(n-1):
if flag:
for j in range(n):
... | false |
0b4692180343e2d59f6eecc315b8886072b07dd9 | Laxaria/LearningPyth3 | /PracticePython/Fibonacci.py | 987 | 4.5625 | 5 | # Write a program that asks the user how many Fibonnaci numbers to generate and then generates them.
# Take this opportunity to think about how you can use functions. Make sure to ask the user to enter the number
# of numbers in the sequence to generate.
# (Hint: The Fibonnaci seqence is a sequence of numbers where t... | true |
6d288b804d2b5cc07008fd53cf4ff7352052e458 | MelindaD589/Programming-Foundations-Fundamentals | /practice.py | 448 | 4.125 | 4 | # Chapter 1
print("Hello world!")
# Chapter 2
# Exercise 1
name = input("Hi, what's your name? ")
age = int(input("How old are you? "))
if (age < 13):
print("You're too young to register", name)
else:
print("Feel free to join", name)
# Exercise 2
print("Hello world!")
print("Goodbye world!")
# Exer... | true |
fc7376086c6c59f67ab1009af30a49a5491079f1 | debdutgoswami/python-beginners-makaut | /day-6/ascendingdescending.py | 344 | 4.34375 | 4 | dictionary = {"Name": "Debdut","Roll": "114", "Dept.": "CSE"}
ascending = dict(sorted(dictionary.items(), key=lambda x: x[1]))
descending = dict(sorted(dictionary.items(), key=lambda x: x[1], reverse=True))
print("the dictionary in ascending order of values is",ascending)
print("the dictionary in descending order o... | true |
9b2e6ada5318d7eecc9797368fa73b53fef11943 | MikeWooster/reformat-money | /reformat_money/arguments.py | 1,405 | 4.125 | 4 |
class Argument:
"""Parses a python argument as string.
All whitespace before and after the argument text itself
is stripped off and saved for later reformatting.
"""
def __init__(self, original: str):
original.lstrip()
start = 0
end = len(original) - 1
while orig... | true |
6efeb3345f8eb779f5dbc797ba6d5ed195966330 | dyhmzall/geekbrains_python | /lesson3/task3.py | 1,276 | 4.21875 | 4 | # 3. Реализовать функцию my_func(), которая принимает три позиционных аргумента,
# и возвращает сумму наибольших двух аргументов.
def my_func(*args):
"""
Принимает любое количество аргументов (в том числе три)
и возвращает сумму наибольших двух из них
:param args: list любое количество аргументов
:... | false |
490ecf5f4f7847afa1bbb5cebecc47843b3d541a | florian-corby/Pylearn | /hangman/hangman.py | 2,469 | 4.21875 | 4 | #!/usr/bin/env python3
import word_manipulations
import get_random_word
import hangman_ascii
import sys
import os
def print_ends(hangman_end, guess_word):
if hangman_end == "defeat":
print("")
print("You lost! Hangman is now dead...")
print("Guess word was: " + "".join(guess_word))
... | false |
3adffc3289a2bbc46051b618b644bce205bd3624 | sdamico23/sort-methods | /mergeSort.py | 923 | 4.125 | 4 | #LAB 13
#Due Date: 11/18/2018, 11:59PM
########################################
#
# Name:Collin Michaels
# Collaboration Statement:
#
########################################
def merge(list1, list2):
#write your code here
newList = []
z = 0
y... | false |
2d75c379c24fc87753ab6d92fd84c1ba0518eec2 | edu-athensoft/ceit4101python | /stem1400_modules/module_6_datatype/m6_4_string/string_demo/string_21_strip.py | 620 | 4.5 | 4 | """
string method - strip()
returns a copy of the string by removing both the leading and the trailing characters
"""
# case 1.
s = ' xoxo python xoxo '
print(f"|{s}|")
print(f"|{s.strip()}|")
# case 2.
s = ' xoxo python xoxo '
print(f"|{s}|")
print(f"|{s.strip('xo')}|")
print(f"|{s.strip(' xo')}|")
s = ' oxo... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.