numbers

How much RAM do I need to execute x=10**10**10 in Python?

How much RAM do I need to execute x=10**10**10 in Python? Question: By timing the execution of x=10**10**n for n up to 8, I estimate that about 4.3 days would be needed to execute x=10**10**10 on my system. What I need to know, however, is whether I would have enough RAM. (My 64-bit Windows system …

Total answers: 1

I want to pop selected items on a number list

I want to pop selected items on a number list Question: Whatever number the user types, I want this number to be deleted from the list my_list = [] for i in range(1,21): my_list.append(i) delete_numb= int(raw_input("Delete a number: ") ## in here code for delete delete_numb in my_list I’m sure about this code. But I …

Total answers: 4

Python if elif not getting expected results

Python if elif not getting expected results Question: In Python 3. It reads correctly the 1st and the 2nd variable when they have the highest value. But the 3rd is not. n1 = int(input("1st Number:n")) n2 = int(input("2nd Number:n")) n3 = int(input("3rd Number:n")) if n1 > n2 and n3: print(f’33[1;31m{n1}33[m’) elif n2 > n1 and …

Total answers: 1

I wrote a little code but something might be wrong

I wrote a little code but something might be wrong Question: The goal of this code is to generate a little list of 6 random numbers from 1 to 60, erase any repeated item and sort it, but I think something may be wrong because sometimes I execute this code and nothing happens, probably when …

Total answers: 1

Create 3 digit numbers that is even and count them

Create 3 digit numbers that are even and count them Question: I need to make a program in Python that do this: Write a program that, for a given sequence of digits, prints the number of different three-digit even numbers that can be formed from the given digits. When forming each three-digit even number, each …

Total answers: 2

Rounding a float number in python

Rounding a float number in python Question: I have a float numer a = 1.263597 I hope get b = 1.2635 But when I try round (a,4) then result is 1.2636 What should I do? Asked By: duy dang || Source Answers: Try math.floor with this small modification – import math def floor_rounded(n,d): return math.floor(n*10**d)/10**d …

Total answers: 3

How do I convert numbers with e to digits only?

How do I convert numbers with e to digits only? Question: I want to convert numbers like 1.28e+21 to a long digits only number but the following code doesn’t make a difference. n = 1.28e+21 b = 1.28*10**21 print(b) b still has an e. How do I get rid of e? Asked By: diviserbyzero || …

Total answers: 2

File reading only first digit of a number rather than the whole number

File reading only first digit of a number rather than the whole number Question: The problem is that i have a text file with each line being PlayerName wins with x points with each player name and number being different and obviously with them being different are different number if digits long Problem is as …

Total answers: 2

Count Odd Numbers in an Interval Range. Leetcode problem №1523. Python

Count Odd Numbers in an Interval Range. Leetcode problem №1523. Python Question: I tried to solve this problem from leetcode and I came up with the following code but the testcase where low = 3 and high = 7 gives 2 as an output and 3 is expected by leetcode. I will be grateful if …

Total answers: 2

Python list with type strings

Python list with type strings Question: I have got a python list Year= [‘1997JAN’, ‘1997FEB’, ‘1997MAR’‘1997APR’………………………’2021SEP’’2021OCT’] I would like to extract only years from the above list but not the months How can I extract only years? Year = [1997,1997,1997,…………………2021,2021] Asked By: swin cine || Source Answers: If you have these dates: dates = [‘1997JAN’, …

Total answers: 3