Programming › Re: Common good python programming practices you should know by Predstan: 8:05pm On May 18, 2020 |
iCode2: Thanks but it didn't give the right output. Oh Sorry, I hope I haven't confused you |
Programming › Re: Common good python programming practices you should know by Predstan: 5:40pm On May 18, 2020 |
gbolly1151: That code for recursion doesn't look like one and even the first method will still end up looping and wont end. Am thinking should look like this
def collatz(number): if number % 2 == 0: return number // 2 elif number % 2 == 1: return 3 * number + 1
number =int(input("Enter Number" )) Num = number while Num != 1: Num=collatz(Num) print(Num)
Ok, But on the other hand, look at this bolded part of the question. I was thinking, we should be checking that return value is not equal to 1 and not our input value iCode2: Hey guys, so, I'm trying my hands on this exercise:
The Collatz Sequence Write a function named collatz() that has one parameter named number. If number is even, then collatz() should print number // 2 and return this value. If number is odd, then collatz() should print and return 3 * number + 1. Then write a program that lets the user type in an integer and that keeps calling collatz() on that number until the function returns the value 1. (Amazingly enough, this sequence actually works for any integer—sooner or later, using this sequence, you’ll arrive at 1! Even mathematicians aren’t sure why. Your program is exploring what’s called the Collatz sequence, sometimes called “the simplest impossible math problem.”) Remember to convert the return value from input() to an integer with the int() function; otherwise, it will be a string value. Hint: An integer number is even if number % 2 == 0, and it’s odd if number % 2 == 1. |
Programming › Re: Common good python programming practices you should know by Predstan: 12:33pm On May 18, 2020*. Modified: 1:06pm On May 18, 2020 |
iCode2: Hey guys, so, I'm trying my hands on this exercise:
The Collatz Sequence Write a function named collatz() that has one parameter named number. If number is even, then collatz() should print number // 2 and return this value. If number is odd, then collatz() should print and return 3 * number + 1. Then write a program that lets the user type in an integer and that keeps calling collatz() on that number until the function returns the value 1. (Amazingly enough, this sequence actually works for any integer—sooner or later, using this sequence, you’ll arrive at 1! Even mathematicians aren’t sure why. Your program is exploring what’s called the Collatz sequence, sometimes called “the simplest impossible math problem.”) Remember to convert the return value from input() to an integer with the int() function; otherwise, it will be a string value. Hint: An integer number is even if number % 2 == 0, and it’s odd if number % 2 == 1.
Here's my code:
def collatz(number): if number % 2 == 0: return print(number // 2) elif number % 2 == 1: return print(3 * number + 1)
number =int(input()) while number != 1: collatz(number)
What am I not doing right? First you need to return the number from the Collatz function as an integer not a print function... use: return number//2. Then you have to check that the return value from the Collatz is not equal to 1 if not, user keeps inputting number and the Collatz function is called on the number from user. def collatz(number): if number % 2 == 0: return number // 2 elif number % 2 == 1: return 3 * number + 1
number =int(input("Enter Number" )) Num = collatz(number) while Num != 1: continue
Using Recursion:
def collatz(number): if number % 2 == 0: return number // 2 elif number % 2 == 1: return 3 * number + 1 def main(): number =int(input("Enter Number" )) Num = collatz(number) while Num != 1: main() return print ("Callatz on", number, "is", Num) main()
|
Programming › Re: Common good python programming practices you should know by Predstan: 12:42pm On May 16, 2020 |
gbolly1151: WHAT IS if __name__=='__main__'?
#short explanation
if __name__=='__main__': print('hello')
then, you are telling the computer that if this python file is run by user or robot then print('hello')
#full explanation Anytime you open python file,you are actually loading the file into the memory of the computer (i.e RAM). The name that will be given to that file at that point wont be the name of the file but a new name that is called '__main__' (i.e __name__='__main__') and it is stored together with other data in memory.
To check that, open any python file and print global data using global keyword
print(globals())
output ... {'__builtins__': <module 'builtins' (built-in)>, '__file__': '/storage/sdcard0/qpython/scripts3/.last_tmp.py', '__package__': None, '__cached__': None, '__name__': '__main__', '__doc__': None}
from that output above we can see that __name__= '__main__'
so at runtime the name of any python file is '__main__'.
This name is often use proffessionally in python for testing or running the functionality of a script at runtime.
you might be wondering why we have underscore,This is because we dont want it to be in conflict when we use 'name' as variable name in our program
now,if you use
if __name__=='__main__': print('hello')
then, you are telling the computer that if this python file is run by user or robot then print('hello')
you can acqually change the variable of __name__
e.g
__name__='changed'
#now let see the changed name of the file at runtime print(globals())
#output {'__builtins__': <module 'builtins' (built-in)>, '__file__': '/storage/sdcard0/qpython/scripts3/.last_tmp.py', '__package__': None, '__cached__': None, '__name__': 'changed', '__doc__': None}
we can see that our __name__ has been assign another variable
I finally learnt OOP. I have completed a project. Its coordinate of a line with slope, distance and to determine if a line is vertical or horizontal and if it is perpendicular or parallel to another. I also completed a Time project to display the julian day, the day of the week, of that date and gregorian date. Its interesting so far. I couldn't display the calendar without the normal calendar module. I am trying to create my own calendar module but I didnt get that. I'm also currently working on Polygon. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 4:33pm On May 15, 2020 |
Geewin69: You only had to read the info on the link yourself bro.
Did they say that TB Vaccine is effective against covid? Did they say that they have evidence that IT PROTECTS against covid?
What evidence did they give? Assumptions!
If it were to be effective, why are people still going down with it in places where routine immunization is followed religiously?
Vaccines boost the immune system against specific pathogens. May I also remind you that covid is novel?
Why are you doing this bros?
Please can we just go back to the subject of this thread? Thanks. You really need to learn how to make your point and to convince people to accept your perspective. Rather than resorting to this. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 8:55am On May 15, 2020 |
|
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 8:32am On May 15, 2020 |
rkarang: Insightful! A different perspective, I love your analysis.
CoVid 19 is a brand new strain virus... we are still learning
In all, is the travel rate to Africa as high as the rate to Europe or America? There are still many factors that may account for the discrepancies...
There’s a reason why New York is worst hit in US... That's another thing. But again, the recovery rate in Africa is around 35% and that of America as a continent is around 23%. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 8:03am On May 15, 2020 |
rkarang: Sir, many factors may account for this relatively low confirmed cases and death toll.
First off, how quick were they to respond to this outbreak? In answer to this question, South Africa responded quickly. How aggressive is their testing and other containment measures? South Africa responded with even a mobile testing kit, in less than 3 weeks or so they already had 67 testing centres (sincerely speaking Nigeria was having less than 11 testing centres then-Africa most populous nation). In terms of lockdown, South Africa was extremely strict in this regard.
And what’s the impact of all these? Is that you don’t allow people who have contracted the virus to keep spreading it. That’s being proactive
Time will come Nigeria Government might just be overwhelmed with the control of a horrible major outbreak that might be looming ahead...
President Trump has been bragging lately that America has the largest testing capacity than any other country in the world, a critical analyst asks at what time did you achieve this? South Korea achieve theirs at the beginning of the outbreak-that’s being proactive
There’s no magic anywhere, if you respond late you’re giving people the chance to spread the virus...
He has successfully turned himself a physician overnight. Prescribing drugs such as the hydroxide chlorine to suggesting of injection of disinfectant into human body. This is not the great United States we know... United States we know set the pace for others to follow... the whole world look up to United States... They have highly intelligent experts
Some countries are handling it much more better than others, some are lying with figures, etc.
If you ask me, this is the time world needs to unite to fight the invincible enemy. 100% correct boss. I know the USA is not doing good but still, they have the highest number of tests in the world. I was at the testing centre a week ago and i can tell you, its a drive through centre. Anyone can go in and do the test. Currently, America has close to 7 million tested samples with close to 1.5million cases. If any country tests as much as the USA, they will have as many cases as the USA. Radical testing will unveil more cases of the virus. Taking the Uk as an example, The Uk hits 100k daily testing on the first of May, what happened to the cases, an increased number of confirmed patients, and an increased number of death tolls. I implore you to go check out France. Now going back to Africa, Senegal, Ghana and South Africa including Rwanda were able to carry out radical testing that is relative to their population, yet the confirmed cases haven't so increased compared to the rates it has in the European countries. I will implore you to base your analysis on the number of tests and repeated tests carried out in these countries, you will realize what I'm trying to say. Europe as a continent with only 700million people have the highest number of deaths officially recorded than any other continent. Trump is a case but we can't underrate the efforts they have put against this virus because of one Clown. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 7:38am On May 15, 2020 |
sonofakin: Well, Canada is immigration friendly so it understandable that they are making such modifications. I'm not expecting any real change from Trump tbh. However, I know a lot of schools are already offering online classes. I'm sure even funded students would have to pay for such online classes since their funding wouldn't have been activated yet. I don't think one should consider it anyway, deferal should be the option. Imagine power outages that happen for days and one not being able to power phones and computers and then finding it difficult to meet deadlines, quality and cost of internet is another thing to consider. Overall, one can't even get the whole graduate school experience, especially research students that have laboratory works too A friend was trying to do DET online as a replacement to the TOEFL test as requested by the school. Even with 3 attempts, internet bleeped him up. Its either he couldn't submit and upload after completion or that while taking the test, the speed runs as low as 500kb per sec. If anyone tries that with graduate school, Na OYO ooo. Lol. Even with my 190mb per sec internet, zoom still buffers. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 5:18am On May 15, 2020 |
rkarang: Nigeria for example has only tested less than 35000 people with confirmed cases just above 5000
This implies one out of seven being tested has the virus.
In Nigeria there have been record of mysterious death ... that tells you the virus has a foothold here too.
As regard underreporting, that might be true. Even China, UK and Russia underrepoted their cases.
It’s not in our best interest to lockdown our economy for too long neither is it healthwise to reopen the economy rematurely. A dilemma that governments, business leaders and medical experts are struggling to deal with. Nigeria is actually not the only African Country. I was very careful to mention Nigeria because we are not taking the Virus serious in any way. I have been trying to upload a jpg picture to show something but keeps bouncing back. Not sure what's wrong. Take Hungary for instance, they have only tested about 123k samples with 3300 cases and 436 deaths. Compare it with South Africa with over 350k tests and 238 deaths. I wish i could upload the picture. It's what i found out after a little analysis. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 12:27am On May 15, 2020 |
DreManuel: I agree with you. I’d be interested to see what data you find.
As per underreporting in Africa, I don’t think there are any incentives to do so. My guess would be that we’re not testing enough. It’s possible the weather is helping a bit to limit the spread. I think one advantage Africa has is the young demography. It’s interesting that Lagos with population that’s 3x the size of New York still has an extremely low Mortality and Morbidity from Covid. This could really mean that something is in Nigeria’s favor but I don’t know for sure what it is. South Africa have tested over 350k samples with only less than 15k cases and 238 death. I'm not sure this is about testing capacity. There is something alien going on in Africa that even WHO does not understand. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 12:21am On May 15, 2020 |
pompeiimagnus: Although about 247k recoveries have been recorded in the US, it has still killed over 85k people in the US in the space of just 2 months! If that's not deadly, I wonder what is. Also know that many people in the US both young and elderly, have several underlying health conditions such as obesity, diabetes, STDs, and so many chain smokers. All these conditions weaken the body's immunity to the virus. So it's surprising when y'all keep saying like DT, that only the vulnerable elderly people should self isolate.
No doubt, we have to get back to our normal lives as soon as possible. But it should be with a phased and careful approach. I'm in TX and with what I've seen, I'm not in a hurry to have my haircut at a salon anytime soon. Do you not think it's not as deadly as it is being painted in the media. There are alot of people who have recovered without any medications. The 247k is the official record. Looking into the deaths recorded in America and Europe. Majority of them are old and children. We can isolate these people and open in phases as you have suggested. I'm sure this is what the USA is working to implement. Testing capacity must increase drastically so that everyone can be tested anytime and isolated if necessary |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 6:46pm On May 14, 2020*. Modified: 7:02pm On May 14, 2020 |
DreManuel: Honestly, I don’t think it’s sustainable to continue the lockdown in the developed world. Developing countries like Nigeria shouldn’t have been locked down to begin with but borders be should partially closed.
Most of the cases are mild. The person whom I share an apartment had the disease and recovered without any real medication. I might have had it too without knowing but tested -ve when they eventually tested me.
Covid19 is deadly but it’s overrated in my opinion. They should let us go back to our classrooms in the Fall and let businesses open. Those that are high risk should self-isolate. I’m tired of the liberal media that won’t stop stoking fears. I had the same opinion and people argue this with me. I believe the Covid-19 is not deadly as painted by the media. We have to learn to live with it because its not going soon or anytime. We cant continue to close down countries for months. People will die of hunger than of the virus. Self-isolation and Quarantine should be for the vulnerables. I am currently scrapping some datas online. I want to see the age range of the majority of people that died of the virus. On the other hand, Look at the cases in Africa, do you think that's normal? Under-reporting or the virus cant survive? |
Politics › Re: Bala Lau Demands ₦100 Million From Sahara Reporters For Reporting His Death by Predstan: 6:58am On May 13, 2020 |
|
Politics › Re: Bala Lau Demands ₦100 Million From Sahara Reporters For Reporting His Death by Predstan: 6:57am On May 13, 2020 |
|
Politics › Re: Bala Lau Demands ₦100 Million From Sahara Reporters For Reporting His Death by Predstan: 6:54am On May 13, 2020 |
. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 7:30pm On May 12, 2020 |
sheke01: If you've been paying attention to anything I've ever said you will see my chain of reasoning. The US is still arguing about reopening. Some little states are beginning to see spikes in cases and deaths. Schools are planning on reopening but are still saying "we will do so if it's safe"
US evacuated it's citizens from different countries of the world. Who will reopen the embassies? US citizens. Where are thus US citizens? They all ran back to the comfort of their homeland. When will the embassy reopen? Undefined. How likely will DHS believe other countries are safe to send their citizens to reopen the embassies? No one knows when
How will international students gets visa to resume by fall? No one knows except some nairaland e-warriors that also doubles as DHS officials.
lol Yeah DHS officials. There are so many of them here who knows exactly what the US will do and not do. However, there is nothing wrong with being optimistic and pushing whatever plan one have towards Fall 2020. But I still stand to say, you shouldn't pay SEVIS fee even if you have recieved your i-20. SEVIS can be paid anytime when Embassy reopens. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 12:23am On May 12, 2020 |
Eniolakiite: Lol not that
Most services are extending their expiration date. Canada that you must use a period to do some things if you’re processing your PR have extended the time and made things easier this period. It would be wrong to allow millions of students pay sevis fee again when it was the pandemic that didn’t make them use it. So they would adjust it.
That’s what I’m saying. You still talking like an American Lawmaker. I would assume you are. So its okay |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 12:19am On May 12, 2020 |
Eniolakiite: That won’t apply in this covid-19 period. If the pandemic situation is worse by spring next year, they will extend the expiration of the sevis fee as the virus and closed borders is a just reason and a global one. Oh! I forgot you work in the Whitehouse with Homeland Security. Its okay |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 12:12am On May 12, 2020 |
Eniolakiite: I get your point but even if you pay or have paid and can’t come because of covid-19, they will use it for whenever you can come. The whole world knows the pandemic and its effects. Most services are extending the expiration time of their services. You have one year to use the Sevis. Paying Sevis now would mean that you can only use in the next spring. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 11:41pm On May 11, 2020 |
Eniolakiite: Yes pls  But international students coming in by fall 2020 is not feasible especially the way Nigeria is handling Covid-19. People can only be hopeful but I do not advise anyone to pay for Sevis until there is an order for consulars to resume activities |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 11:30pm On May 11, 2020 |
sheke01: New York will gradually reopen by June. I wake up everyday to watch Gov. Cuomo press conference on CNN 11:30 EST. You think I just come here to say anything I like?
New York will reopen because the hospitalization and deaths are declining. Yesterday was about 200 deaths. What will happen when they reopen and the rate goes up again?
I won't believe your school have already sent out emails saying fall semester will be on campus. My school and the general consensus I see online still haven't decided on how fall semester will be. In order not to misinform the public, please provide a screenshot of such email
Yes, people must adapt and adapt protective measures but how will the world as a global village adapt? Will international borders open for non essential stuff like schooling without a vaccine? The US and Canada border is still closed, I can't go for my planned trip to Toronto.
Borders will likely be opened eventually but will the embassy open quick enough for students to process visa for fall semester which is barely 3 months away? I don't expect you or anyone to process stuff the way I process, it's what I do everyday so I understand.
P/S: Am a very positive person but I like to call a spade a spade Well, we are going back on-campus by Fall. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 5:02pm On May 10, 2020 |
Micholo5: .
Yes, Its either of the two not both, so you can take the SAT, that way, you won't be needing WES Evaluation.
(please confirm this from other sources, I am not 100% sure) It doesnt matter if you have WAEC or not, if the school requirements includes SAT, you must write SAT. The only exam that can replace the high school qualification are HIset and GED. SAT is also one important test if you want funding. So I advise you to go sit for SAT and break into your choice of program |
Programming › Re: Common good python programming practices you should know by Predstan: 9:51am On May 10, 2020 |
gbolly1151: IF YOU ARE CONFUSED ABOUT WHILE LOOP CHECK THIS OUT
n=True while n==True: print('hello')
it means you are telling the computer that as long as n value isTrue(n=True) continue printing 'hello' for me
Hope you can take it from there Finally learnt OOP on LinkedIn learning (lynda) I got some Covid-19 data for every countries and I will be visualizing some stuffs. |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 8:27am On May 10, 2020 |
Lanreamoye: Thanks a lot sir. Should i proceed with International office per I-20. Please do u school there or u know someone sir? I just need someone to explain next step of action and who will be guiding me step by step I do not school there and I dont know anyone. You may have to wait until Corona virus is suppressed. However, the next step after admission and funding is to send in financial documents and in this case, your GA letter to the International office for I-20. How much is your deficits after your funding? |
Travel › Re: General USA Student Visa Enquiries-part 15 by Predstan: 12:58am On May 10, 2020 |
Lanreamoye: Please, who knows about Loyola Marymount University very well. Please i need advise per below
I have been given admission into Electrical and computer department and I eventually got GA position with $4,124 per semester. But i have to work 7.64 hours per week. Please how can i get Transfer work that can cover for remaining 14 working hours in the school? In which other departments are transfer works possible just to cover up the deficit to some extent before issuing I-20
Kindly advise pls School library, restaurants in school, research laboratories. You wont get those until you are in school |
Programming › Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by Predstan: 10:47am On May 07, 2020 |
. |
Politics › Re: NDDC Denies Fraud Rumors, Says Documents Circulating Are Fake by Predstan: 2:37pm On Apr 26, 2020 |
iretemide: Just heard from a friend from Kano that it is meningitis that is killing people in kano. Please concerned authorities do the needful. Because hes the doctor who tested the dead for meningitis. Even the authorities said they have to make their own investigations. But your friend who collected the samples and tested them knows better |
Programming › Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by Predstan: 12:38pm On Apr 21, 2020 |
gbolly1151: Before we move to inheritance, let implement this in python
class Animal: def __init__(self,legs,Tail=True,Body): self.legs=legs self.Tail = Tail Sel.Body = Body
def bark(self): return 'barking'
def bite(self): return 'biting'
def run(self): return 'running'
#let create our object
Dog=Animal (4,Tail=True,'fat')
#you can leave out tail if true and create like this Dog=Animal(4,'fat') print(Dog.legs) print(Dog.Tail) print(Dog.Body) print(Dog.bark()) print(Dog.run()) print(Dog.bit())
Output: 4 True fat barking running biting
Making sense. Thanks Boss |
Programming › Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by Predstan: 4:47am On Apr 20, 2020 |
gbolly1151: Well done boss.... but let me comment on your answer
head is the attribute name while rounded and short are the values same as other attribute name
attribute - head = [short,rounded] <== value neck=reduce <== value ears= round <== value tuff = hairy <==value
You can practice more,just pick up objects around you and describe them
I will start inheritance in next update Ok Thanks. |
Programming › Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by Predstan: 1:07am On Apr 20, 2020 |
gbolly1151: A lion is a species with a short,rounded head, a reduced neck,round ears, and a hairy tuft at the end of its tail. It has prominent mane,which is the most recognisable feature of the species. They can run,jump and do hunt prey.
Who is following? Object - Lion Class: Name - Animal Attributes - short, rounded head, , reduced neck, round ears, hairy tufts at the ending of its tail Method - run(), jump(), hunt prey() |
Programming › Re: Common good python programming practices you should know by Predstan: 10:55pm On Apr 19, 2020 |
gbolly1151: I have started another thread,you can follow
Tutorial: Object Oriented Programming Paradigm For Beginners Link |