numbers

How can trim only (10) numbers in Python

How can trim only (10) numbers in Python Question: hashCode = 0x39505b04f1c2e5c03ea3 I want to see only 10 characters, How ? Asked By: HaMo || Source Answers: If you want to see the first 10 characters: hashCode = ‘0x39505b04f1c2e5c03ea3’ print(hashCode[:10]) outputs: ‘0x39505b04’ If you want to instead see the last 10 characters: hashCode = ‘0x39505b04f1c2e5c03ea3’ …

Total answers: 1

Printing a star instead of a number

How to print a star instead of a number? Question: I need to write a function numbers_around(n, k) that prints the numbers smaller and larger than n in order. Instead of the number n, it should print an asterisk. What I’ve done: def numbers_around(n, k): for n in range((n-k),(n+k+1)): print(n, end=’ ‘) print() numbers_around(15, 3) …

Total answers: 1

random float numbers and their mean and standart deviation

random float numbers and their mean and standart deviation Question: how to get a list of 1000 random float numbers without dublicates and find their mean value in python? import random rnd_number=random.random() def a(): l=[] m=1 for i in range(1000): l.append(rnd_number) return l for i in l: m=m+i return m//b print (a()) i am probably …

Total answers: 3

Printing the number of different numbers in python

Printing the number of different numbers in python Question: I would like to ask a question please regarding printing the number of different numbers in python. for example: Let us say that I have the following list: X = [5, 5, 5] Since here we have only one number, I want to build a code …

Total answers: 3

How to delete lines which contains only numbers in python?

How to delete lines which contains only numbers in python? Question: I have a large text file in Python. Firstly, I want to read the text then, delete lines which have only numbers. Then, I open a new text file and write with my changes. If the line contains numbers and strings, I want to …

Total answers: 2

Word Conversion to Numbers in Dynamic way

Word Conversion to Numbers in Dynamic way Question: Dears, I’m converting words to numbers than removing vowels, it’s working fine except when word are starting with vowel the program stops working …sounds logic since the tool is removing vowel each time it encouter one of the letters from this list: {‘a’,’e’,’i’,’o’,’u’} , can we get …

Total answers: 1

For a given number of horseshoes p and number of horses k

How to count horseshoes in python? Question: I’ve completely stuck with this task and I really dunno how to make this program work properly, because I think I’ve already tried many possible options, but it still unfortunately didn’t work properly. The task is: "The blacksmith has to shoe several horses and needs to see if …

Total answers: 3

How to print without a newline without using end=" "?

How to print without a newline without using end=" "? Question: I need to design a function named firstN that, given a positive integer n, displays on the screen the first n integers on the same line, separated by white space. An example of using the function could be: >>> firstN(10) 0 1 2 3 …

Total answers: 2

2 minimum in Python

2 minimum in Python Question: I have a program that asks me for 5 numbers and then prints the minimum. But now, I need a program that writes the minimum and the second minimum. train=[] min=100 for i in range(5): train.append(int(input("Enter a number"))) for carriage in train: if min>carriage: min=carriage print("Minimum is ",min) Can somebody …

Total answers: 1

How to convert a number to its correlating day of the week?

How to convert a number to its correlating day of the week? Question: How do I convert a number to its correlating day of the week? For example: def string(hour_of_day, day_of_week, date) : print(f'{day_of_week} {date} at hour {hour_of_day}’) how can I re-write the ‘day_of_week’ part in print so that when I use the function: string(12, …

Total answers: 3