• Breaking News

    Friday, October 5, 2018

    Simple Python While Loop Will Not Exit Ask Programming

    Simple Python While Loop Will Not Exit Ask Programming


    Simple Python While Loop Will Not Exit

    Posted: 05 Oct 2018 07:22 PM PDT

    This should be easy, but this while loop just keeps going. The only way it works as intended is to use a break, but I can't use those for my class.

    option = 0

    loop = True

    while loop == True:

    #show list of operation choices print("1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exit program") print('\t') #ask which operation they need option = int(input('Choose one of the operations above that you need (to quit enter 5): ')) if option == 1: operation = 'addition' elif option == 2: operation = 'subratction' elif option == 3: operation = 'multiplication' elif option == 4: operation = 'division' elif option > 5 and option < 1: print('That is not an option (try using 1-5): ') else: print('Thanks for using Math Tutor!') print('\t') loop = False; 'break' 

    Below would be the rest of the program which it begins to still process even though all the below parts are still in the original while loop

    #print what operation they chose print('You chose to use',operation) print('\t') 

    ect..

    submitted by /u/Bentler
    [link] [comments]

    My simple Java program accepts and displays user input the first run, but if I try it again it does nothing. Why does it do this?

    Posted: 05 Oct 2018 08:33 PM PDT

     String name; int age; System.out.println("Please enter your name and age"); Scanner ac = new Scanner (System.in); Scanner sc = new Scanner(System.in); name = sc.next(); age = ac.nextInt(); System.out.printf("Welcome %s/n" , name); System.out.printf("You are %d/n", age); 

    Heres the code, and yes the scanner is imported

    submitted by /u/4trevor4
    [link] [comments]

    What makes MATLAB coding different from regular coding?

    Posted: 05 Oct 2018 10:44 AM PDT

    Hi I am stupid, and a true imposter(I suck at programming).

    What's the difference?

    I am probably going to have a gap in my employment but oh well. Maybe if I know the difference I can fake my way into a job

    submitted by /u/Chrisl008
    [link] [comments]

    Non programmer with a reach of a question

    Posted: 05 Oct 2018 05:35 PM PDT

    I don't know if anyone can effectively answer this, but thanks to all who read! I'm technologically proficient but don't know what thing about programming. I downloaded a botting service for an Android video game. I'm running an Android emulator called NOX, and the bot runs on Ankulua, the software that enables it, I guess. (I downloaded these things because the bot said it's the best way to do it.) Anyways, when I run the bot service through Ankulua, I get this exact error message-

    Runtimeerror: Android.accounts.networkerrorexception: com.a.a.p Stack traceback: [C]: in function 'httpGet' ?: In function 'httpGet' [String "release.luae2"]:410: in function 'getRegStatus' [String "release.luae2"]:5222: in main chunk

    I understand this might not be able to be answered, and I don't even know if this is the right sub to ask this.. that's why I labeled it as a reach. I'm putting this out here because their forums were completely unuseful and unresponsive, and I was hoping someone here might be able to give me some sort of insight as to what the problem might be.

    Thanks for any and all help!!

    submitted by /u/Gagedemoss
    [link] [comments]

    I’m having trouble running my first C program on the Windows Command Line.

    Posted: 05 Oct 2018 05:06 PM PDT

    It compiles fine, but there's no output. The directory with the compiler is C:\MinGW, and that's were the hello.c file is. The code of the hello.c file is as follows:

    #include <stdio.h> int main() { printf("Hello World!"); return 0; } 

    Any ideas?

    submitted by /u/Not_Reverse_Flash_
    [link] [comments]

    Putting value of Pipe into variable -Bash Script

    Posted: 05 Oct 2018 04:21 PM PDT

    Hey guys, I need help placing the value of a pipe into my variable (fsize) (line 25) so I can keep track of it / add on to it.

    The problem I seem to be facing is when I'm getting the size of the file fsize isn't getting set to that number, its getting set to the entire expression of 'ls -l $FILE | cut -d" " -f 5'

    Code:

    #!/bin/bash ORX=0 #Start counter for Ordinary, Readable, eXecutable NEO=0 #Start counter for Non-Existent or Other DIR=0 #Start counter for the DIRectory OR=0 #Start counter for Ordinary and Readable BYTES=0 #Start counter for the number of BYTES in ordinary files if [ $# -eq 0 ] then flist=* else flist=$* fi for FILE in $flist do if [ -r $FILE -a -x $FILE -a -w $FILE -a -f $FILE ] then ORX=$[$ORX+1] elif [ -d $FILE ] then DIR=$[$DIR+1] elif [ -r $FILE -a -w $FILE ] then OR=$[$OR+1] fsize='ls -l $FILE | cut -d" " -f 5' BYTES=$[$BYTES+$fsize] else if [ $# -ne 0 ] then NEO=$[$NEO+1] fi fi done echo "======================File Data=======================" echo "ordinary, readable, executable files: $ORX" echo "non-existent or other types of files: $NEO" echo "directory files: $DIR" echo "ordinary and readable files: $OR" echo "total bytes in ordinary files: $BYTES" echo "$fsize" echo "$FILE" 

    submitted by /u/fadithedog
    [link] [comments]

    How do you write Fizzbuzz in x86 ASM?

    Posted: 05 Oct 2018 07:29 PM PDT

    The IDIV instruction takes too many clock cycles. Is there a way to find the remainder faster?

    submitted by /u/nanoman1
    [link] [comments]

    Question about database

    Posted: 05 Oct 2018 07:17 PM PDT

    I'm wanting to create an app that has a lot of pictures. I'm assuming the app needs a database with a server so it does not take up so much space on someone's phone? Can someone point me in the right direction? Thanks

    submitted by /u/SpaceRiptide
    [link] [comments]

    Help in Python!

    Posted: 05 Oct 2018 06:23 PM PDT

    So I'm a relatively new programmer taking a beginner course in college and my experience to python is very limited. Recently we've been asked to create a very basic "monthly budget" program using variables and print statements. The problem that I am having at the moment is that I can't seem to limit my floats to 2 decimals and instead I get a large stream of numbers. I know that traditionally if you were looking to display floats by only 2 decimals you would typeout {:.2f} or something like that, but I can't seem to find a way to make it work with the code I am using right now. I was wondering if anyone might be able to look at a line of my code and tell me what I'd want to change in order to fix this problem!

    print('{:>8}'.format(item1), '{:>4}'.format('|'), '{:>0}'.format('$'), '{:>4}'.format(monthly1), '{:>2}'.format('|'), '{:>1}'.format('$'), '{:>5}'.format(yearly1))

    If needed, the variables I used are listed below

    item1 = Clothes

    yearly = 200

    monthly = 200 / 12

    Thank you all in advance for your help!

    submitted by /u/GooRakMeung
    [link] [comments]

    Help with bubble sort in C

    Posted: 05 Oct 2018 01:42 PM PDT

    I can't seem to figure out why my bubble sort is subtracting values? I am very confused as I don't have any subtraction to the array. #include <stdio.h> #include <stdlib.h> #include <math.h> #define SIZE 7 //function prototype void examScores(float scores[]); float standardDeviation(float scores[]); float adjustedScores(float b[], float result); float bubbleSort(float scores[]); void printArray(float scores[]); int main (void){ // use initializer list to initialize array scores float scores[SIZE]= {80, 82, 90, 95, 90, 87, 92}; int i=0; float result; printf("Exam Scores: "); printArray(scores); printf("\n\nStandard Deviation: "); result = standardDeviation(scores); printf("%0.4f", result); printf("\n\nAdjusted Scores: "); adjustedScores(scores, result); bubbleSort(scores); } // end main //function to print Array void printArray(float scores[]){ int i; for (i=0; i < SIZE; i++) printf("%.0f ", scores[i]); }// end print Array Function //function to calculate the standard deviation float standardDeviation(float scores[]){ float sum, mean, standardDeviation; int i =0; for (i = 0; i < SIZE; ++i){ sum += scores[i]; for (i = 1; i < SIZE; ++i){ sum += scores[i]; mean = (sum / SIZE); } for (i=0; i < SIZE; ++i){ standardDeviation += pow(scores[i]-mean, 2); } // end for standardDeviation = sqrt(standardDeviation/SIZE); return (standardDeviation); } // end for }// end function float adjustedScores(float b[], float result){ int i=0; for (i = 0; i < SIZE; ++i){ b[i] += result; printf("%.0f ", b[i]); } } // end function adjustedScores float bubbleSort(float a[]){ size_t i=0, j=0; unsigned int pass=0; int hold, temp, step; printf("\n\nArray before sorting: "); for(i=0;i<SIZE;++i) printf("%0.f ",a[i]); for(i=1;i<SIZE;++i){ for(j=0;j<(SIZE-i);++j){ if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("\n\nArray after sorting: "); for(i=0;i<SIZE;++i) printf("%0.f ",a[i]); } // end function 
    submitted by /u/glutany
    [link] [comments]

    Having trouble creating a delete method for my hashtable data structure

    Posted: 05 Oct 2018 03:44 PM PDT

    Hey guys, I'm a new poster here. Ff any of you could be kind enough and point me in the right direction that would be great! I've been working on the delete method of this for 3 hours and have gotten nowhere. I've tried a while loop and a for loop to search for the key to no success.

    class HashTable {
    constructor(size) {
    this.size = Array(size);
    this.numBuckets = this.size.length;
    }
    hash(key) {
    let total = 0;
    for (let i = 0; i < key.length; i++) {
    total += key.charCodeAt(i);
    }
    let bucket = total % this.numBuckets;
    return bucket;
    }
    insert(key, value) {
    let index = this.hash(key);
    if (!this.size[index]) {
    this.size[index] = new HashNode(key, value);
    } else if (this.size[index].key === key) {
    this.size[index].value = value;
    } else {
    let currentNode = this.size[index];
    while (currentNode.next) {
    if (currentNode.next.key === key) {
    currentNode.next.value = value;
    return;
    }
    currentNode = currentNode.next;
    }
    currentNode.next = new HashNode(key, value);
    }
    }
    get(key) {
    let index = this.hash(key);
    if (!this.size[index]) return null;
    let currentNode = this.size[index];
    while (currentNode) {
    if (currentNode.key === key) {
    return currentNode.value;
    }
    currentNode = currentNode.next;
    }
    return null;
    }
    getKeys() {
    // console.log(this.size);
    // for (let i = 0; i < this.size.length; i++) {
    // console.log(this.size[i]);
    // }
    return Object.keys(this.size);
    }
    delete(key) {
    let index = this.hash(key);
    if (!this.size[index]) return null;
    for(let i = 0; i < this.size.length; i++) {
    console.log(this.size[i].key)
    }
    }
    }
    }
    function HashNode(key,value,next) {
    this.key = key;
    this.value = value;
    this.next = next || null;
    }
    let hh = new HashTable(10);
    hh.insert("Steven", "Steven.jackson@hotmail.com");
    hh.insert("Blitzen", "Blitzen.glassman@hotmail.com");
    hh.insert("Greyson", "Greyson.bennett@hotmail.com");

    submitted by /u/SpectrumMetric
    [link] [comments]

    I tend to start working on a project without knowing a language-is this bad programming practice?

    Posted: 05 Oct 2018 03:22 AM PDT

    When I started to learn to code, I learnt the basics of C++ initially, and started doing competitive programming questions because I really liked it. After that I studied a bit of java(just the OOP concepts and stuff nothing too deep) because I had to work on an android project.

    Here's the deal-I had always wanted to get into game development, so I got Unity, and just...started working on it, without learning C# AT ALL. I'm pushing myself on the basis of what I had learnt earlier and I've never picked up a C# book ever. Things have been going okay, but I'm not sure if this is good? Is this going to hurt me in the long run? (Not specific to Unity, I didn't even study Java thoroughly and started working on android). It's a natural tendency, and anytime I run into issues, I google it(which happens a significant amount of times, but not enough to bother me).

    Also, I really want to stress on the fact that when I say basics, I mean just enough to get you started, because I know no one learns any language completely, but I really skip a LOT. What do you all suggest?

    submitted by /u/Schmosby123
    [link] [comments]

    Adding a file to the root folder of a third party app

    Posted: 05 Oct 2018 01:52 PM PDT

    I'm in the process of downloading and installing an open source Android app from GitHub. I downloaded the APK and use that to install it, however in the prerequisites section of the readme, it says that I need to download the latest version of node.js and place it in "root of the directory/some_folder/some_folder" After doing some research it seems that there isn't a waY to do this from the phone itself unless it is rooted. How would I go about doing this? Thank you in advance

    submitted by /u/BelieveMeImAWizard
    [link] [comments]

    Any social media site in which I could stream for account deletions?

    Posted: 05 Oct 2018 10:03 AM PDT

    I'd like to start working on a project that needs to create a database of deleted users, and a little information about that user such as time of deletion, ID number, ect. Ideally i would be able to stream whatever site, and add be able to tell in real time what user deletes their account and when.

    I've searched around on the reddit API, and twitter API, and there doesnt seem to be a easy way to go about this.

    Thanks!

    submitted by /u/runescapeguy
    [link] [comments]

    What is the best way to make a book database program in C#?

    Posted: 05 Oct 2018 12:24 PM PDT

    I want to make a database program for my school library in C#. It should keep track of what books are currently available and when books should be returned. Should I use SQL? Just a .csv file? Or something else entirely?

    submitted by /u/Scriptman777
    [link] [comments]

    Python code that creates semi-random lists based on set restrictions?

    Posted: 05 Oct 2018 12:15 PM PDT

    I'm considering learning python if it can do what I'm hoping it can, only reason I chose python is because apparently it's beginner friendly, but please recommed other languages if you think they can do the job better. Essentially, how feasible is it to create a programme that generates a random list of items that together fulfil a set critera (this criteria changes each time, something a user determines, but would simply be a number) and repeats until it finds a set that actually works. But also, each item within the list has multiple possible values depending on which separate database it draws values from for its own. Here's an example if it helps:

    So I'd want the program to randomly select 5 of 26 possible options (a-z). Let's say it got a-e, each with their own value but their sum is <50 (or whatever the user inputs). However, the value of 'a' is determined by x1, y1 and z1, whose own value is determined by whether they take their data from database 1, 2 or 3; so 'a' could equal 5, 6 or 7.

    Also, if this is something elementary, feel free to point out my dumb question xD

    submitted by /u/Vinnicombe
    [link] [comments]

    Any moderately successful indie developers/entrepreneurs I can interview for a college essay?

    Posted: 05 Oct 2018 04:37 AM PDT

    Why cannot browsers display cluttered webpages faster? Can't they optimize pages with a lot of html/css in it?

    Posted: 05 Oct 2018 06:10 AM PDT

    I've read blog posts about cluttered, large webpages being slow on fast computers. It's also not a secret smartphones will have some trouble displaying large websites.

    I've heard from https://www.youtube.com/watch?v=Q4dYwEyjZcY that HTML has ambiguous cases, which means browser must work hard to display it.

    What to think?

    submitted by /u/PenisShapedSilencer
    [link] [comments]

    Help understanding high-level design of an app I want to make?

    Posted: 05 Oct 2018 12:45 AM PDT

    Hi r/AskProgramming!

    I'm always coming up with new side project ideas, but I'm always running into the issue of trying to understand how I would map all the components out at a high level, so I wanted to get some opinions.

    I'm wanting to create an application for people to "post" a sentence or two to a live message feed with a voting system for people to "like" or "dislike" posts.

    It seems to me that the closest possible analogy would be a shoutbox with a voting functionality for shouts. I want this application to function both as a website and mobile app (both reactive (?) and a stand-alone app). Desktop users should be able to open it up, check out the feed, vote, and contribute. Mobile users should be able to open the website on their mobile browser, and sometime down the line I want to create a mobile app to mirror it.

    Simply put - I want to emulate a live feed of anonymous posts (no need for user login/registration) along with a voting system.

    Could someone help me understand how to map this out from a high-level? Should I go with an SPA application, or something like .NET Core MVC? I can only assume that posts would be stored in a simple, one table database. What would be the bare minimum requirements for the table schema? (I was thinking just a post ID, time-stamp, and vote count?).

    I'm assuming that SPA would be the best solution - however my experience is limited to .NET MVC applications, which seems like it would be too "bloated" for such a relatively simple application. In .NET, I know that I can interact with the database using something like Entity Framework - what would be the equivalent way to interact with a DB using a SPA (assumingly some JS framework like Vue?).

    Thanks!

    submitted by /u/emachinez32
    [link] [comments]

    No comments:

    Post a Comment