Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,312 members, 7,954,249 topics. Date: Friday, 20 September 2024 at 03:22 PM |
Nairaland Forum / Science/Technology / Programming / Simple Programming Codes (681 Views)
Short Project: Arduino Uno Project (programming Codes) / Review My Programming Language - SIMPLE PROGRAMMING Language / Simple Programming Assignment. (2) (3) (4)
Simple Programming Codes by ABCthingx: 8:22pm On Jun 03, 2022 |
1. Reverse A String python #Reverse a String – Enter a string and the program will reverse it and print it out' print ("____PROGRAM TO REVERSE A TEXT____ " print('_____type bye to quit the program_____') print ("____Write something then hit 'Enter'____" text = '' #just a declaration while text != "bye": text = input() x = len(text) for i in text: x -= 1 print(text[x], end='') print()
|
Re: Simple Programming Codes by airsaylongcome: 9:24pm On Jun 03, 2022 |
You have imported the std namespace so no need for std::cout again. cout, cin You code isn't checking for edge cases such as when user just hits enter without any input. In a case like this your C++ code will output noitaralceD. I would initialize text with a blank string and check to ensure that user actually types an input. 1 Like |
Re: Simple Programming Codes by ABCthingx: 10:20pm On Jun 03, 2022 |
Re: Simple Programming Codes by ABCthingx: 10:24pm On Jun 03, 2022 |
airsaylongcome:Thanks i've modified https://zerobin.net/?e396809972bf514e#tjf87uSWk7S0cTyGzhr72Qre1ofyLqb+sFpDJcoaGqk=
|
Re: Simple Programming Codes by airsaylongcome: 11:15pm On Jun 03, 2022 |
ABCthingx: Did you run the new code you entered? The if statement for "You must enter a text sir" If you run it without entering text, that If just displays your prompt but does not stop the rest of the program from running |
Re: Simple Programming Codes by Deicide: 9:08pm On Jun 04, 2022 |
Do not reinvent the wheel. Anyways write a programme that reverse ever word in the string. So "He is a boy" becomes "eH so a yob" |
Re: Simple Programming Codes by Emmyxclusive: 6:06am On Jun 07, 2022 |
ABCthingx:in the python code what happens if a user enter a text in upper case or even combination of both? I think using the lower method on the text input is good |
(1) (Reply)
Full Stack Web Developer / My Journey With A Pay After Study Bootcamp For Full Stack Development -follow Me / Spammers Are Back
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13 |