• Register

Recent questions tagged integer

0 votes
1 answer 3 views
Problem: The function checkMe accepts one parameter (a string), then uses the parseInt function and returns TRUE if the value really is an integer.What s the best way to check if a String... What s the best way to check if a String represents an integer in Java.
asked 2 hours ago Ali 4.4k points
0 votes
1 answer 1 view
Problem: How to Check if a given string is a valid number, we have discussed general approach to check whether a string is a valid number or not. In Java we can use Wrapper classes parse() methods along with try-catch blocks to check for a number.
asked 19 hours ago Ali 4.4k points
0 votes
1 answer 10 views
Problem: I've got some Python code that runs through a list of strings and converts them to integers or floating point numbers if possible. Doing this for integers is pretty easy if element.isdigit(): newelement = int(element) Floating point numbers are more difficult. Right now I'm using partition('.') to split the string and checking to make sure that one or both sides are digits.
asked 3 days ago Mashhoodch 9.1k points
0 votes
1 answer 7 views
Problem: I have this python program that adds strings to integers: a = raw_input("Enter a: ") b = raw_input("Enter b: ") print "a + b as strings: " + a + b a = int(a) b = int(b) c = a + b str(c) print "a + b as integers: " + c I get this error: Python: TypeError: cannot concatenate 'str' and 'int' objects How can I add strings to integers?
asked Feb 17 Mashhoodch 9.1k points
0 votes
1 answer 5 views
Problem: So, I'm not entirely sure what's going on here, but for whatever reason Python is throwing this at me. For reference, it's part of a small neural network I'm building for fun, but it uses a lot of np.array and such, so there's a lot of matrices ... type clash. Maybe somebody can help me figure this out, because I've been staring at this error for too long without being able to fix it.
asked Feb 16 Mashhoodch 9.1k points
0 votes
1 answer 6 views
Problem; how to read int from file c++
asked Feb 15 kaash_kashi 1.2k points
0 votes
1 answer 7 views
Problem: I'm playing with both learning python and trying to get github issues into a readable form. Using the advice on How can I convert JSON to CSV? I came up with this: import json import csv f=open('issues.json') data = json.load(f) f.close() f=open("issues.csv" ... item["labels"], item["state"]]) Where "issues.json" is the json file containing my github issues. When I try to run that, I get
asked Feb 15 Mashhoodch 9.1k points
0 votes
1 answer 13 views
Problem: How can I convert a String to an int in Java? My String contains only numbers, and I want to return the number it represents. For example, given the string "1234" the result should be the number 1234.
asked Feb 3 Ali 4.4k points
0 votes
1 answer 10 views
Problem: I am working on the knapsack problem, I am new to Java. I am able to add numbers manually like this in the main: // Fill the bag of weights. //myWeights.bagOfWeights.add(18); //myWeights.bagOfWeights.add(2); //System.out.println("Possible answers: "); // ... the weights. So I have tried to take the user input as a string and split it up with whitespace, and then convert it to an integer.
asked Feb 2 Ali 4.4k points
0 votes
1 answer 4 views
Problem
asked Jan 13 alexh 2.4k points
0 votes
1 answer 40 views
Problem: I have this python program that adds strings to integers: a = raw_input("Enter a: ") b = raw_input("Enter b: ") print "a + b as strings: " + a + b a = int(a) b = int(b) c = a + b str(c) print "a + b as integers: " + c I get this error: Python: TypeError: cannot concatenate 'str' and 'int' objects How can I add strings to integers?
asked Jan 7 Mashhoodch 9.1k points
0 votes
1 answer 29 views
Problem: TypeError: ‘float’ object cannot be interpreted as an integer Floating-point numbers are values that can contain a decimal point. Integers are whole numbers. It is common in programming for these two data types to be distinct.How to solve this error
asked Jan 6 Mashhoodch 9.1k points
0 votes
1 answer 22 views
Problem: I have two networks that I need to merge for my full model. whereas, my initial model is maintained and I need to make it non-trainable when setting up the full model. How can I achieve this in PyTorch. class MyModelA(nn.Module): def __init__(self): ... .randn(1, 10) output = model(x) Usually now I need to load pretrained modelAand make it non-trainable when preparing an Ensemble model.
asked Dec 24, 2020 sasha 8.4k points
0 votes
1 answer 25 views
Problem Hey, i just started learning C++ and i was trying to generate random integers but i was getting wrong.because i don’t know how to generate random numbers. Somebody can help me to write a code for generating a random number between 1 and 3. Try to provide a simpler way to answer me..
asked Dec 23, 2020 chris jordan 2.4k points
0 votes
1 answer 65 views
Problem Hey, I was writing a program for a project of a pseudo assembler. because I have to read assembly instructions of the input file that I have, as per instructions I get the register number so i have to convert it into binary code or machine code. So my ... have to convert 5 into binary after conversion i am getting 101 and 00101 is needed. Somebody can help me to get this zero padding.
asked Dec 23, 2020 chris jordan 2.4k points
0 votes
1 answer 29 views
Problem Hey, I was writing a program that was too big then I realized. If I convert that string into double that will be great for me to write the program but I Am not familiar with this concept of conversion of string into double. Someone can help for accomplishment of this work.that will be great for me.
asked Dec 23, 2020 chris jordan 2.4k points
0 votes
1 answer 8 views
Problem: I wonder if there is a shortcut to create a simple list from a list of lists in Python. I can do it in a loop for, but maybe there is some cool one-liner? I tried this with reduce(), but I am getting the error. <Strong> Code l = [[1, 2, 3], [4, ... last): File "<stdin>", line 1, in <module> File "<stdin>", line 1, in <lambda> AttributeError: 'NoneType' object has no attribute 'extend'
asked Dec 23, 2020 sasha 8.4k points
0 votes
1 answer 50 views
Problem: Hi there! I am a noob and I have got an assignment in which I have to take two numbers as input from users and print the even numbers that lie between two numbers. I wrote the following program: starting = input("Enter the starting number: ") ending = ... : TypeError: 'str' object cannot be interpreted as an integer I have no idea what is wrong with my program. Can anybody here help me?
asked Dec 21, 2020 Code Learner 5.7k points
0 votes
1 answer 6 views
Problem Hey, what are pre and post conditions in C++.
asked Dec 20, 2020 chris jordan 2.4k points
0 votes
1 answer 15 views
Problem Key, I just want to know the what is upcasting and downcasting system in C++
asked Dec 19, 2020 chris jordan 2.4k points