Python Programming Tutorial – 21 – Modules

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Comments

Christopher Sullivan says:

Love all the videos and I use them to learn a lot thank you very much! But, I have to ask what’s with using tuna all the time? lol

Dark Seid says:

Is random a library file? I see its directory is lib. Why is it a module instead?

Illuminati242 says:

Ok got my program to work great in Python 2.7.12 but not on 3.5.2.

here is my program.

#lottery number generator for pick 4!!
#First we import sample from the random library
import random
from random import sample

#Now we create our group/list on numbers to draw from!

numbers = (1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,)

#Create and input for users to request number of draws they need.

x = input(‘How many numbers would you like today? : ‘)

#Now we define how many balls to draw by creating our defination generate_draw

def generate_draw(balls=4,population=numbers):
return (sample(population,k=balls))

#now we create a defination for multiple draws and call it.

def multiple_draws(count=x):
results = []
for i in range(count):
results.append(generate_draw())
return results

#now we simply print the desired results!
print multiple_draws()

can you please lend some insight on what is suposed to be done? I know print is now a function but i can not get the result to print! please help if you can.

Paweł Brysch says:

import skrypt
skrypt.funkcja()
//
random.randrange(a1,a2) – losowa liczba z przedziału

Vaarunay Kaushal says:

bucky’s gotta be obsessed with tuna or something

Vishal Vashistha says:

How to share my code with you, if I am facing some problem while loading .mat file and using it for loop.

candylantis says:

I have a problem, my configurations are all messed up and everytime I want to use something, I have to make a configuration for it, and then switch to it, and I think its affecting my modules because they never work.

Ashish Kumar says:

Reached to 21. 😀
Cant wait to complete it as soon as possible :)

harsh soni says:

whenever i use specific function from another file it also takes all print functions from that file i don’t know why this things happen!!

Hazem gamal says:

5 min untill pycharm starts

anand pandya says:

Do the modules have to be under the same project file (in the directory) to import them?

miyaclaire says:

great tutorial,and he really likes tuna!:)

Dorio Gee says:

i wrote:
import random
x = random.randrange(1, 1000)
print(x)

and it shows error like
“C:Program FilesPython 3.5python.exe” C:/Users/User/PycharmProjects/untitled3/mainn.py
Traceback (most recent call last):
File “C:/Users/User/PycharmProjects/untitled3/mainn.py”, line 1, in
import random
File “C:Program FilesPython 3.5librandom.py”, line 40, in

from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType
File “C:Program FilesPython 3.5libtypes.py”, line 166, in

import functools as _functools
File “C:Program FilesPython 3.5libfunctools.py”, line 21, in

from collections import namedtuple
File “C:Program FilesPython 3.5libcollections__init__.py”, line 11, in

from keyword import iskeyword as _iskeyword
ImportError: cannot import name ‘iskeyword’

Process finished with exit code 1

Younes PhD Henni says:

can anyone write a code to check how many tuna is there is these tutorials ?!

Michael Wang says:

what if the file name has spaces and nuumbers in iT?

vinay vanteddu says:

cant wait to know how tuna fish tastes like

robert aspelin says:

figured out the tuna.fish before bucky said it. feeling so smart!

Batman says:

I created two file level2 and level3 when I import the function level2 file in level3

like this:

import Level2

Level2.printo()

it says ImportError: No module named ‘Level2’

Raptr3x says:

He forgot to say that if import filename doesn’t work you can use module os so just say import os and when you want to import file just say os.system(“python filename.py”) and it will import the file just as he show

Nick Pangburn says:

Just wondering, if you did random.randrange(1,100)… Out of those numbers, are there any you would never see? Like how unity 3d’s random function will never select the last number, (e.g. Random.Range(0,2); it would never select 0)

Thuy Vuong says:

I typed this code but I didn’t get a random number, it asked me for a number and then I enter one, and then it ends? What am I doing wrong?

import tuna
import random

tuna.fish()
x= random.randrange(1,1000)
print(x)

Akhil Reghunath says:

Hey bucky i reached #21 but am having the following error for this same module lesseon

Traceback (most recent call last):
File “C:/MyPycharm/Files/main.py”, line 3, in
tuna.fish()
AttributeError: module ‘tuna’ has no attribute ‘fish’

pls help me out to figure it out

Ruben S says:

hero

maheema gajaraj says:

Could someone please explain the difference between randrange and randint?

mladen knezovic says:

your screen is very big, right? bad for us it seems….

ak47adultswim says:

poop :3

Yarden Altmann says:

someone must check how meny times bucky use the word tuna in all this videos lol

Abhi Patel says:

I named new python file as ‘try’ and it shows error in importing the file, Is there any specific reason for this?
Other names are working as normal.

Mahfoudh Abdu says:

Hi sir , i have problem with my code it run correctly without any errors but i do not get an image as appears with you!!

Nitin Sharma says:

Can you recommend me some Econometrics packages and libraries

Satya Prakash says:

hey bucky please increase the font size …

Russian Retard says:

You must really like tuna.

Andrei Florea says:

list = array
module = library

deal with it.

Soufiane Kre says:

do you like tuna this much?

Fernando Maxwell says:

Is there anyone here know, how to import another module from different folder in python?

crownkiwifactoryNZ says:

Bucky is Awesome!

Amha Aygoda says:

i tried importing the file but its not working on my mac. i did exactly the same thing that you did but it’s not working for me. yellp

Samuel Kariuki says:

The font is too small! its difficult to see.

Raptr3x says:

Did he just wrote “feesh”? :”D

Mark van Brummelen says:

This is so much fun! So tempting to do another one ahhh!!! I need to sleep 2!

Andy Kim says:

1. Do files that you import need to be in the same directory as main?

2. Can main be called anything else without messing up the program?

Mister D says:

Please help. Why am I getting this?

C:UsersDanielAppDataLocalProgramsPythonPython36-32python.exe C:/Users/Daniel/PycharmProjects/test2/main.py
Traceback (most recent call last):
File “C:/Users/Daniel/PycharmProjects/test2/main.py”, line 1, in
import tuna
ModuleNotFoundError: No module named ‘tuna’

Process finished with exit code 1

Darryl Mann says:

Not very random. Gets the same number 236 every time I watch this video,.

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours