How to allow both integers and strings in input?

I just started learning Python about a week ago, and for one of my first projects I built a really simple random number guessing game as part of the course I'm in. However, I tried to add an extension to my code that would print something different i...
more »

2017-11-12 20:11 (2) Answers

Python data type validation integer

Hello I am creating a registration program and need to ask the user to input their age . However I want to make sure its not a letter by just consisting of numbers. How do I limit the user to only getting a number and if they input other character a ...
more »

2017-11-12 14:11 (1) Answers

How do smallint, integer, word and byte save data?

I got this thing for an exam where I have to choose which applies The decimal number 146 is saved in the computer as "10010010" The decimal number 38,069 is saved in the computer as "1001010010110101" The decimal number -95 is saved in the compute...
more »

2017-11-09 20:11 (3) Answers

Check if an integer is even or odd in a for loop

I am trying to write program that lists all numbers from 0-15 add whether the number is even odd (i.e. "0 is even, 1 is odd", etc.). I'm doing for my AP Computer Science Principles class and need to use a for loop in order to get full credit. I typed...
more »

2017-11-07 22:11 (1) Answers

Saving mutiple integer in mysql database laravel

when I try to save my data into the database, for some reason I can only save 1 integer and not multiple integer inside. Can anyone tell me why? I was thinking it might be because I am using FamilyAge as an integer in the database instead of a string...
more »

2017-11-07 01:11 (1) Answers

Bit shifting to print bits changing an int in C?

I'm just trying to print out the bits of an integer, and it looks like the int is somehow getting changed in the process, but it also appears to be changing in-between calls, not in the middle of the function. My function is: void printBits(int bits...
more »

2017-11-06 21:11 (1) Answers

Undertanding ints and longs

I was intetviewed for a Software Developer and was asked the following question: I have an addition operation on signed 2's-complenent 32-bits integers. How to implement signed 2's-complement 64-bit addition via 32-bits addition? In Java I need to ...
more »

2017-11-06 10:11 (0) Answers

how to make 2 = .01 and .01 = 2?

Okay so the title may not make the most sense but I will explain it better here.. what i'm trying to do is take the value of 2 and make it equal to .01 and make .01 = 2, well I tried to hardcode it like this if (Value = 2) Value = 0; else if (V...
more »

2017-11-05 05:11 (1) Answers

IfThenElse Pattern matching function in Haskell

Am trying to do a function called IfThenElse in Haskell which which gives its second argument if the condition (the first argument) is True, and the third argument if the condition is False (for example, ifThenElse (3 > 5) 7 12 gives 12) But I h...
more »

2017-11-04 13:11 (0) Answers

Reverting an hash code "sum"

So, rather than calculating the hash code every time, I thought I could keep an integer updated with all the changes. Imagine a setter for a property that contributes to the hash code: public void setFoo(Foo newFoo){ this.hashCalculator.remove(t...
more »

2017-11-04 10:11 (2) Answers

Haskell: Module for polynomials over integers

I have an assignment for one of my classes and am just really unsure as to how to move on. The assignment asks that I create a module for polynomials over the integers. So far I have (these were specified in the instructions for the assignment) da...
more »

2017-11-03 02:11 (0) Answers