Good evening, everybody. Welcome to the Private Property Farming Podcast. My name is Mbali Nwokor, your host every Tuesdays and Thursdays at 8pm, right here on the Private Property Channel. Thank you so much for watching yet another episode of the Farming Podcast and today we've got such a fantastic or an exciting topic at that chance. You know, you could just tell how excited I am. I can't even talk because the guest that we have today has 29 years experience within the cannabis industry and it seems like cannabis has just been around for about three or two years, you know. It's such a common buzzword of late and it's quite interesting to know that there's a person who's dedicated almost three decades of his life or his career in the cannabis industry and today we're talking about licensing cannabis in South Africa. So if you have an interest about cannabis farming or have heard about cannabis farming and just, you know, quite, didn't understand how do you start cannabis farming and how do you license it? How do you trade? Well, I think today's topic or episode is the right one for you. We are approaching episode 90 and I believe today's episode 89 and so, yeah, what a way to just move on to a next level within the Farming Podcast. As always, if you have any questions, comments for the guest, please feel free to ask a question and we're happy to respond live on to the show. So let's get right to it and we are joined by Gurnal Fandavat. Gurnal, thank you so much for joining us. How are you doing? Oh, good evening, Bali. Great, thanks. Are you doing? Yeah, good evening to all the listeners out there as well. I'm happy to be with you guys. Exciting talk. Likewise, I'm so excited.  Firstly, Gurnal, I think by means of introduction, kindly introduce yourself to our audience this evening and the work that you do within the cannabis industry in South Africa. Yeah, so I thought AKA the White Lion in the cannabis industry got stoked at through many years of experience and extensive work in community programs and on the international level as well. I have a deep footprint in the cannabis cultivation sector and yes, for me, it's been a long journey. Cannabis always been part of my life and I represent White Lion Holdings, also complete cannabis solutions, both startup companies of myself. We've moved on through the years and are well known in the sector. I would say we're the leading cultivation group in South Africa and we represent and we help the larger scale farmers, people that's on a commercial and industrial scale would like to get into the cannabis sector. We get approached across the board from people that's in the agricultural sector, maize, cattle, citrus, where I am in the Western Cape, we deal with a lot of the citrus farmers at the moment that we actually help them. We take their hands and we give them a full turnkey solution from the beginning to the end. So from genetics, from application through genetics to the market and we help them through the whole process. Right, so like I was saying in my intro, you know, Cornell Cannabis Farming seems to be the trend of late, you know, for the past three years or so and you've been in this industry for 29 years, you know. How did you start to be in the sector and why didn't we hear about Cannabis Farming 29 years ago? Yeah, so I'm not going to tell you my whole story yet. I'll try and put it in a nutshell. It's been a long path for me and a hard walk. And it's, you know, the scammer clothes speak for itself, my uniform. It's been a tough, I refer to it as World War Wheat and Potelix. You know, I've been in World War Wheat and Potelix for at least the last 10 years of my life. So yeah, we came from obviously an underground sector and more a recreational underground movement into a formal and agricultural sector. And it's where the underground had to take hands with regulations and also move on into a commercial and production sector, you know. So yeah, my history is extensive from early 90s in the United States. After I studied chemical engineering, I climbed into the industry, came back in 99, brought the industry with me and also the skill of glassblowing at that stage. I've been to scientific glassblowing and that gave me a cutting edge in experience, in extraction and so forth. Got diagnosed with cancer because of the glassblowing and really got into the health benefits from cannabis and the specific cannabis world healed my own cancer through injection and ingestion of the oil and so forth. And that was my ticket, you know, that was, that was just a switch in my brain, etc. This is my future. And I've never ever looked back, helped a lot of people since then on the health benefits of it and moved over into the more professional and corporate sector of the industry as well. So with cannabis farming, firstly, right, where can you farm cannabis in South Africa? And for a farmer who wants to go into cannabis farming, what comes first is this building the farm and the infrastructure to start cannabis farming or getting the license first to start cannabis farming? Yeah, so right, rightfully, like you say, there's no restrictions to where you allow to grow it like a specific province in South Africa or that it's open to the whole of South Africa. At this stage, it is under SAPRA, the South African regulatory authority that deals with cannabis applications of SAPRA. And yeah, it's a license application to cultivate, manufacture, import cannabis for medicinal purposes. And it's application process that you follow. There's a little bit, you can say, farm for all, so it's a situation that suits you as well so you can put a license and you can get going. In South Africa, you have to go through quite a tedious process of establishing your facility first and laying the capex out as well. So there's clear guidelines from SAPRA on how to comply with the compliance for getting a license and the compliance is exactly that. It's putting up a facility, having the land to do it on all the infrastructure. The application itself is quite a simple process. It's a form that you fill in and it's a $23,800 fee the last time I checked. But what really gets difficult then is after that you get queued for inspection to comply before you can get issued a license. And the compliance is tedious. It's the hard part of it. We helped the farmer or the client to actually choose the location. It's very important for me a location where to grow.  I can grow cannabis anywhere in the world for you but some areas there's a lot more capex intensive than other areas. So I like to from the word go inform the farmer where it'll suit his pocket the best to cultivate. So from site selection straight through to introducing the third parties you mentioned, Osman Fansal, we've paired ourselves with the best there is in the industry. I'm backed by international brands and international names that I've worked with for over 20 years. The Dutch guys, the Netherlands guys are known for their greenhouse capability and their technology and they definitely might go to when it comes to the greenhouse structures. Just like that, I also have a construction team that does the buildings. So even with the cultivation, just for information out there, the license is for cultivation under cover. That's what the license states. So you can literally put up a greenhouse or a shade net or so forth. It's not for open outdoor cultivation at this moment in time. It is still under cover and it's completely regulated. We put together a site masterfile after the application and the site masterfile includes everything that consists from the site layout to the processing facility with all the procedures, your equipment list of what's standing in that processing facility with the suppliers, all standard operating procedures with checklists for every aspect of the industry, service level agreements with third parties that we bring to the table as well. Conform work, traceability and tracking systems, genetic supplier agreements, offtake agreements, organograms, structure of your company, all of that. So as you can see out of this, it is a huge barrier to entry. If you look at all the capital you have to spend and also all the intellectual property that needs for you to comply. So the majority of our clients take comfort in us taking their hand and mitigating these risks for maybe not getting a license or mitigating the risk and failing in this industry because it's not an easy industry. A lot of people are out there with misinformation and get let by the nose because it's the green rush, like you say, it's the buzzword now. The green wave has hit South Africa now but the rest of the world that's been there. I was in Colorado when it happened, I was in California when it happened, I was in Canada when it happened, I was in Lesotho when it happened, the same as busy happening, yeah. It's a circle of events that's turned and everybody is heavily invested in this space at the moment. I gotta tell you the truth that everybody is looking at it, big farmers looking at it, the mining industry is looking at it, all the food and beverage companies are looking at it. It's a big business, it's a big business for the future for South Africa. Right, now you mentioned some critical points there. I heard you speak about Lesotho, however the connection broke a bit there, so basically just to understand is that, you know, SAPRA has the guidelines to get the license, you mentioned the price of the license, so if a farmer had to start a commercial production within cannabis farming and let's say they're reaching out to white line holdings, do they first look at the guidelines and build that their farm or the green houses in relation to the guidelines? So looking at the guidelines and you start building, you look and start building, so that by the time the building or the infrastructure is done, your infrastructure speaks towards the guidelines and then you can have other certifications like global gap, etc. Is that correct? Correct, you're hitting the nail right on the head there, so that's that service that we provide, so we literally take the hand and we guide them through those guidelines by putting up the facility for them and doing all the paperwork for them and the side masterful and then help them to get that license and we can talk about the timeframe as well and so forth on how long the process takes, so a lot of people, like I say, there's people that say that will run around and say, oh, you can put up a loop house, a vegetable loop house and you can put two by four poles and a shade net and you're ready to go, but it's not the fact and securities get scrutinized, you've got to have access control, you've got to have anti-climbing, fencing 2.4 meters high, you've got to have cameras, you've got to have biometrics on the doors, security is a big aspect of it, just because of the nativeness of cannabis. We're dealing with a formal sector and it falls under the health sector and it's about the compliance with the regulations. It's scheduled drug stall as it stands today, the regulations hasn't changed on cannabis, so all those things you've got to comply with, so if people try to cut corners so that it doesn't work, they fail. So you've got to put faith in SAPRA as well and in the licensing process. I know there's a lot of people that's against the licensing process and that, but it also gives a lot of faith in the process that there is actually a national health regulatory authority that's backing the process on product development and that because it doesn't just start cultivation. If the first person that has to die from a cannabis related, they take bad business, it's bad for the whole industry, it has to be regulated. It can't be a backyard mechanic situation where everybody can just make medicine and run it out to the market, it's got to be regulated, it's got to be registered, so I don't have any problem with the process. I've put my faith in the process to regulate it for us and we just comply with that process. Our time frames best scenario is we do a service level agreement for three months where we help you select a site, we introduce the third-party contractors, we build the process, we build, we put up the greenhouses, we do all the paperwork and application and we hand it in and we queue for the license. Normally the boltout would be a six to eight month process and then after the application is in, you get queued for an inspection date. That's your D.A. On that day, everything has got to be in place. So like I say, it's risky, it's a big risk to lay out the capital and not knowing if you're going to get a license or not, but you also, I can sit here and say directly to you that I've never failed in getting a license because we're familiar with the process and we work very closely in the process as well and we know what we're doing. So yeah, we're a professional output. Yeah, Colonel, this sounds so exciting and very, very technical as well. Also, it sounds like there's so much high barriers to entry. It reminds me of intensive vegetable farmers and the things that they have to go through via global gap and exporting documents, etc., talking about licenses and what you've just explained right now in the past two minutes. Are we on par within South Africa from a global perspective with our license? For example, what I'm trying to ask is that, you know, supper is the one that is creating these regulations, also guiding farmers that if you're producing on a commercial level, you have to have a specific license and you need to pass that. So now once I've passed this, I've put up my infrastructure as a farmer and now I want to trade globally. I want to export from a global perspective. Is our license on par with global standards? Yes, that's a very good question. So if you start to look at GMP and GAP and GACP and so forth, so we built according to GAP for me is good agricultural practices where it's in the field, it's in the greenhouse, it's what you apply to your plants and the cultivation cell. GACP is more good agricultural collection practices. So how are you harvesting? How are you tracking? How are you consolidating into a batch number? How are you testing? How are you storing? How are you drying? And so forth. And then after that, you're only getting GMP. So a lot of people get misguided on the GMP side because GMP is good manufacturing processes. So only once you start processing and everything I've mentioned so far is primary processing. This is a good part of the industry as well because we try and to pair now agricultural sector cultivation with the medical sector that's very medicinal, very clean and very strenuous and very regulated. So it's a difficult part. Where do you stop with GACP and where does GMP start? So that clarification is busy getting formulated and we are allowed to export and we have exported them. I was involved with exports out of Lesotho to Canada. I was involved with exports out of South Africa to Switzerland. So the first exports out of Lesotho, we helped with the first exports out of South Africa. We helped with and we managed those sites. So very possible and very on standard. I mean the GMP, if you look at GMP accreditation, we can get GMP accreditation in South Africa. It's a SAPRA GMP. Does that hold up with a EU GMP? No, it's not the same standard. So EU GMP, like everybody knows Germany is one of the hottest countries to actually get into and get product into. So when it comes to quality assurance and quality checks and that, it's very much up to the company itself to lead that aspect and have the professionalism and the right technicians in place to give that quality assurance and that quality and also to pair yourself with good tracking and be clear and transparent to SAPRA about it. So it's got to be a two-way street on communication. Right. We have a comment here, Gordinelle, from JB and they're saying there's so much blur information out there. So it's really great to hear this information from you, Gordinelle. And which is a great comment because it's nice to know that, you know, it brings so much comfort speaking to someone who's very experienced in the sector.  But as a regulatory body and as an industry, how do you then manage what people are growing in a commercial farm that has a license versus what people are growing in their own individual households? Because I think the law in South Africa is that you can grow cannabis or consume cannabis, but within your own, you know, private space. So how does one, as an industry or as a body, how does one regulate the two different cannabis production, especially where health is concerned? Sure. So like I said as well, I'm like I'm sitting here, I have background of working with communities and community upliftment and I am a rasta as well. So the dreadlocks here at the back speaks for itself. So I'm not against the people growing small scale or growing for themselves at home. There's nothing wrong with that. And I suggest to everybody to be growing cannabis, it's a connection that you have with the plant and I've got a deep connection with it. It's a spiritual plant and it helps you in many aspects in your life. To tell you the truth, when it's an unregulated environment, like it's somebody growing just at home, it's seeds that's purchased locally. That's locally been bred or that's been through generations passed on. I mean, we in Africa have a history of thousands of years of growing cannabis. You don't have to teach the people how to grow cannabis, but it's not the same thing. Growing three plants or 300 plants is not the same thing growing 30,000 to 110,000 per hectare on a commercial scale. It's a completely different ball game. And that's where the misinformation comes in as well. Of course, there's a lot of consultants running out there and everybody, you kick over a rock now and master grow pops up. It's like a dime a dozen. So it's that scenario. Everybody is making out like the experts in the industry. And I'm not blowing my own horn or sitting a chip on my shoulder, but it's been a hard work for the last 30 years to be where I am. And it comes with respect and knowledge. And I mean, you learn through hard knocks. Farmers will tell you that as well. It's not easy to farm. Anybody that says it's easy to farm. And it's very similar to citrus, just like you suggested as well. So moving on from home scale, growing or personal use to a commercial scale, you got to track everything.  And we bring in the genetics that's registered with the International Seed Bank. It comes in with a phytosanitary certificate into the country. And it's declared that customs that it came in. So it's inspected that you're not bringing any microbials or fungos or anything into the country. So that's where it starts. Then you multiply that genetics through cloning or through tissue filtering to get a homogeneous crop. The big part of this industry is to have a constant, large volume, clean, high end product supply. It's similar to citrus.  We don't see it on our shelves. We see the choice grade. That's on checkers and pick and pay. It's very similar to cannabis. That top end market is not young. It's a market that's international for medicinal purposes. And that's where the money lies as well. So for me, I want everybody to grow. It's going to open up. There'll be hemp permits that's being issued as well. And I know there's a bull that's at Parliament right now that's getting ready to be passed. We hope for the near future that there'll be cannabis clubs and cannabis dispensaries and it's open. And that's the local market. So that's that local production. That's not my field. Like I pointed out to you, I deal on the larger scale production for export specifically. But yes, I hope that answers your question. So it's genetics, it's phytosanitaries, it's traceability, straight back to the source, barcodes on every single plant with scanners on the software. If regulatory authority or even security walks in, you can give them a scanner gun. And it doesn't matter if it's a plant or a cutting or product in a fridge. If they scan that barcode, it'll be clear, transparent, the history of it, when it was planted, where it came from and where it's going, when it'll be harvested. So everything is tagged. Awesome. I want to get to one question and then I'll move on to a guest's question here. I think we've covered it earlier on, but we'll just repeat it for his sake, because he didn't apologize for joining late. But I just want to find out, speaking about multinationals or global companies, right? Are farmers able to compete in a fair standard or in a fair practice with multinationals who also want to invest in cannabis farming? Because in the beginning of our conversation, you mentioned that cannabis farming is such a huge buzzword in South Africa, everybody wants to farm it, it's a green gold, farmers are investing in cannabis farming, diversifying into cannabis farming. And also you mentioned mines and pharmaceuticals are also diverting to cannabis farming. So now does that create fair competition within the South African landscape where farmers don't have deep pockets and resources like the global or big corporates would have? So from exporting levels and also just regulating the industry, is it a fair field where farmers can compete equally with multinationals? Yes, I would say it is. For me, yes, there's a big barrier to entry and it's the deep pockets, it's the corporates that lead the industry. But at the end of the day, like I said, I've been in many areas internationally where this has taken place. And at the beginning, it's everybody jumping on the bandwagon. Like I say, it's Farmer, it's the breweries, it's the mining industry and so forth. But three to five years into the industry, it stabilizes. We're two years in now since first license has been issued in South Africa. So we're still sitting on the snake's head, so if I can put it that way, where everybody's jumping on a bandwagon. And at the end of the day, it's an overinflated situation where the bubble bursts. And the guys that really know what they're doing, they'll be 10 to maybe 15 largest scale producers that controls that area of production that I wouldn't say monopolizes, but that controls that. It's the same with the citrus industry. You have lots of many small scale farmers that produces for a packer, maybe, and that ties in with the shipping aspect of it as well. So when you see yourself in the industry, a lot of people, there's so much scope in this industry. I cannot start to tell you that cannabis touches every single industry that you can name. So it's so diverse. You know, you talk about the mining industry back in the gold rush. It was not the guys getting into gold mining and made so much money as the guys supplying all the axes and the picks and the sips and that, you know, so the supply chain for the cannabis industry is a big part of it as well. I mentioned earlier dispensaries as well. So that's all coming. So there's many add ons and filtration off from cannabis that's going to happen in South Africa. It's literally a green rush. So even if somebody controls or as a monopoly over that part of the industry, it's not the whole valley chain of the industry, products on the shelves, local products, logos, that's all going to happen. We're going to start seeing a lot of brands popping up on our local market and for international export as well. So when it comes to product formulation and product development and all of that, I can, like you can imagine about what I'm doing and I can go on about ever as well for, you know, but yeah, for me, it's, it's a massive industry that's here to stay. I would like to see a bigger conventional banking and so forth opening up for the sector as well. So the farmers are not struggling to have that big barrier to entry on the capital, maybe land bank up to all the farmers, you know, I would like to put that out there to help fund them on it and mitigate that risk, insurance on the crops, you know, we got to look at all these things in the future. We don't have it in place yet. It's coming. I'm glad you mentioned the topic about finance because we've got a question here from Bongani master Terence. He says, sorry, I'm late, but did you cover the cannabis license costs for a startup? And I believe you did. Did you say that about the license is about 23,000 or sorry, is that correct? Correct. 23,900, 800,000. Last time I checked with SAPRA, but that's only for your license application to go in. That doesn't mean you get a license. The compliance is the big part of it. Like I mentioned, that's the hard part of it. I'm not going to lie to you. You're talking big boxes. It's, yeah, people out there, there's all kinds of figures out there. I honestly, 35 million rents for me touches the bottom end of production. And you're not talking big scale production. You're talking about half a hectare of production because of the high tech greenhouse that we put up, but it gives you the capability to grow all year around. It doesn't matter what happens on the outside. So we control the whole environment. Conventionally, you would be planting in spring where we're sitting down in September and you'll be harvesting end of March, April. That's one crop for the year, but you open to contamination and to spray and to cross pollination and a lot of headaches, a lot of heartaches that comes with farming where in a greenhouse situation and controlled environment, you don't. You're controlling the photosensitivity on the light cycles.  So in that, we dictating to the plants when to flower and how to flower and by supercropping and so forth, we are in production as well. We're not growing massive plants. You're growing smaller plants in smaller cycles. So we do six to seven harvest a year compared to one harvest conventionally. So yes, you're spending the big bucks and the capex and there's that massive barrier to entry, but your production is up and your consistency is there and your quality as well because of the environment you're in. Yeah, I think we might have to have you back on now just to talk about the technicalities around production because I'm hearing 35 million just only for half a hectare. Wow. Like I mean, what could I do with just 35 million? There's so many farms I could build. And yet we're just talking about a half a hectare. So it sounds quite expensive, not sounds. It is very expensive. And then you must still go through all the loopholes or sorry, the high barriers to entry from a licensing perspective. But going back to licensing, how often does one have to keep up with a license?  Maybe just explain for how long do you have the certificate for to trade? Sure. The upkeep is a five year period, but there's unannounced inspections that gets conducted as well. So it's not just the upkeep on a license fee or that it's to comply, to comply with the regulatory authorities. They can walk onto your site any day. And like I say, you've got to be clear and transparent on every single little leaf on site. So we track everything. When we do de-stalk, we we track the stalks. When we de-leaf, we track the leaves. When we take moisture content out, when we de-humidify, we weigh wet weight. We weigh dry weight.  It's licensed and it's regulated. So that's a big aspect of it. So if you hear about all the tracking and the weighing and the de-humidification so forth, all this equipment is costly. So that 35 million goes towards, it's not like you think just buying a farm or that it's actually to set up the building, to control the environment, to have to access control on it and all the equipment that goes with it and the capability and the salaries and so forth. So yeah, we do a proper finance module as well in our consortium. So yeah, I'm the practical guy and I look like this, but we have CFOs and that runs proper finance modules and that and predictions for our clients as well. Wow, got enough on the bat. It has been such an awesome conversation that we've had this evening and hopefully you could join us again where we just unpack other topics around cannabis farming because it seems like we have a lot of engagement and a lot of interest from our audience regarding this and unfortunately we can't take all the questions because now we've run out of time and we just also don't want to take too much of your time this evening. But just as a final question in closing, is such an investment in cannabis farming justifiable when we need to farm food because people are growing hungry? Is it justifiable from an expense or capital outlay when we could be spending that money in growing more grains, more fruits and giving access to these healthy foods to low-income households? I hear your question and I'm going to answer in two-fold. So firstly, cannabis is a health supplement and it's necessary as well. It's maybe bad to say but COVID the cannabis industry good in a way because there's a bigger demand than it has ever been for cannabis. We saw that it's an essential product needed by people to alleviate circumstances and pain and depression and stress and so forth as well. We saw that across the globe. So for me it's not just about food, it's about having people's mental health just as good as their body health as well and cannabis plays a big role in that. And for the local market to open up for local production and to have a fair access for local people to it and not just that massive high-end product that's sitting on the shelves and high retail internationally is very important as well. So we're definitely going to have that way. There is smaller communities and co-ops and I've seen some of your previous podcasts about co-ops as well. I loved it where communities work together and they take it to a central hub. I would suggest for the future where we have central processing stations and it doesn't matter how people bring it there. If it's on a donkey or on a wheelbarrow or on a bucky or on a buck, it gets created like everything else that gets created and it falls into a category as it's for local consumption as it's for the export market and that feeds back to the people. So my second thing I'm going to say to you is that you must remember that cannabis touches everybody's life. So have you ever heard of an industry that we can create jobs that are needed in this country? Give the investment opportunity for foreigners that brings capital to our shores. Everybody is here. The Israelis are here, the Americans are here, the Germans are here. Everybody is here to grow cannabis in our country. So we're bringing capital for investment opportunities to the country and then we're helping people that badly needs it as a health supplement to have access to it at a fair price locally and then we're exporting or we're bringing forex back to the country. I mean we're talking a magical industry. I don't know too many industries that touches all of that. Yeah, thank you so much for your time this evening Gornel and yeah it's been a fantastic chatting to you and it's great to know that you know there's individuals like yourself locally that are so experienced in cannabis farming a topic that we still need to explore quite extensively and I like so many, I like the various opportunities that you've mentioned you know about creating investment for cannabis farming, more technical expertise for cannabis farming, looking at around the various ways around licensing and how can we create communities about around cannabis farming and also discussing the importance of what cannabis can do for you from a health perspective. So thank you so much for your insights this evening. I thoroughly enjoyed our chat and yeah I wish you a great weekend and a good Friday ahead. Thank you Mubali likewise it's been a pleasure. Absolutely we were just speaking to Cornell Fundavat. If you missed our conversation this evening please go straight on to YouTube and watch this farming podcast episode 89 where we discuss licensing around cannabis farming in South Africa. Cornell comes with a wealth of information and I'm sure you just don't want to miss this hopefully we could get getting back on to the farming podcast to discuss other elements and aspects around cannabis farming so that you at home are informed on the benefits, the pros and cons, why you should farm it from your own private space or from a commercial space and what type of investment you're looking at when starting cannabis farming in the type of support that exists in South Africa right here locally. I think the key benefits here is that he said that cannabis could be grown anywhere but a lot of time and patience is needed to understand how the production cycle works having a technical expert like Cornell to assist you in setting up a cannabis farm. He is the CEO of White Lion Holdings and what I heard is that he also provides consulting services on how to start a commercial cannabis production. We will leave these details on the farming podcast in the specific episode so reach out to him if you have any further questions and look out for all our social media platforms when we would have Cornell back onto the show. Hopefully he agrees but thank you so much for watching and supporting that episode this evening. Thank you to JB, to Balani and all the others that have asked questions and unfortunately we couldn't answer all of them tonight because of this limited time frame that we're working under but this is it for me. Have a fantastic Friday and a great weekend ahead and I will see you next Tuesday with another awesome guest at 8pm. Take care.


Like a soldier I lost God cause I told you I can't help but hurt her But last night was a blur I can't remember where I woke up Burning the castle in my car New girl in my bed But you're still up in my head Why do you take me in Another night and another sin Can't you still wait for me But you should just let me be I'll be puppy Please let me be Girls like all the time Never appreciating a dime I met down on a small shine Love please take me to the cloudline Maybe I'll meet another angel Goddess I be made me faithful Probably not no, aren't changeable Love to one, you're no less a fate But why do you take me in Another night and another sin Can't you still wait for me But you should just let me be I'll be puppy Please let me be


So, good morning everyone. So, we will start with basic python in earnest. Let us get started straight away. So, here is an outline of what I will be covering today. I hope to go through this and some additional material, but let us see how far we go because it depends on how much you are able to absorb in one day. It is a fair bit of material. So, we look first at the language itself very briefly. I do not want to spend too much time and then we will go over the basics. We look at the interpreter, basic data types and operators, strings, conditionals and once we start hitting loops and list IO files, functions, tuples, dictionaries and sets, I will slow down. But the initial parts I will try to keep a good pace. Hopefully by lunch time we should finish, it will say lists. I would be happy if we get that far. So, let us move on. Let us get to the language. So, why do we pick python? Python itself unlike say MATLAB or equivalent languages, python is a full fledged programming language. It is not just designed for numerical computing. So, as a result if you learn python or our belief is that if a student learns python, they are equipped to deal with a larger set of problems than is necessary, than is possible with something like MATLAB. The reason is if you look at most research and use of a computer, the use is not always restricted to numerical computing. You will need to use it to do a variety of tasks. So, the point is if you are to teach one language, we would rather teach one language that is capable of handling a variety of tasks rather than teach you five different languages that do different things in different fashions. So, python is an extremely powerful and high level language, which basically means it gives you a lot of powerful constructs that are at a much higher level than say a lower level language like FORTRAN or C, which means with a lot less code, you are able to do a lot more work. Python is also interpreted and some of you might initially think why I mean an interpreted language is going to be slow. Yes, however the advantages that an interpreted language bring are that it is much easier to develop and much much easier to do rapid prototyping of ideas. And now with computers being this as fast as they are, it is very important that the developer gets more feedback and it is much easier on the developer than absolute performance. Python also has a very elegant and very readable syntax. So, basically as you will go through this course, you will see that python programs are very easy to read and part of the reason is that indentation is forced. So, the block structure of a python program is determined completely by indentation. And therefore, it is a lot easier to read for everybody that the code looks pretty much the same. Unlike in C where you can use brackets and basically the appearance, visual appearance of the code is could be different for different programmers in this case it is not. It also provides a huge number of or a very large number of high level data structures that are extremely efficient and extremely powerful. In addition, as you will see over the course of today and maybe the future classes, Python is very easy to learn and as a result of all the above features, it allows you to concentrate on the problem instead of the language. So, if you look at more complicated languages like say C++, you will typically need to have a copy of the language reference or you will have a copy of some good book on the programming language with python that is not the case. I have been programming for many years and all I have been, all I learnt was from online documentation say the tutorial and the rest I do on the interpreter. So, if I have to learn and explore something, I will use the interpreter to do it. As a result of this python offers increased productivity which means you are able to do a lot more and a lot less time. The creator of the language is Vido van Rossum. He is a Dutchman. He is currently in the US and he works for Google. He is called the benevolent dictator for life.  In terms of the language he is, he basically makes most of the important decisions for the language. And it was python the language was created in 1989 and do not get confused about the origin of the name python. The name python does not come from the reptile python, but it comes from a comedy, 70s comedy called the multi python flying circle. So, continuing on in addition to being an extremely powerful programming language as I had mentioned before the language is very readable, but one very important and often neglected fact is the important fact that python is interactive. So, as I will go along in this course you will see that very often I will switch to an interactive interpreter the python shell and show you how you can actually write nice bit bits of python code there test your ideas and then develop your code. So, basically this offers you a very fast what is called the edit test debug cycle. So, if you run into a if you write code it becomes much easier for you to quickly test your code and debug the errors on that code. And as I mentioned in the last slide it does the language does not get in your way. So, you do not have to struggle with how do I do this in this programming language instead you are more concerned about how do I solve the problem which is really what you want from a good programming language. It also handles basic the memory management for you. So, you do not have to deal with pointers which are usually the most difficult part of any lower level programming language. In addition to this python has a huge standard library a very significant and large standard library. So, if you go to the python.org website and look at their documentation there is a document there called the library reference and repeat the library reference it has a listing of all of the standard library packages that python offers. And these packages are very varied. So, you can do things like access the internet send email parse HTML parse XML do system level commands access zip files create zip files or create tar files do shell like scripting all of that stuff is built in as part of the language as part of the support structure that comes with the language. And these are called the standard library. So, the standard library has a lot of functionality available by default inside it. Therefore, as a result of the combination of very good easy to learn elegant powerful programming language plus the standard library allows you to do a lot of things with python itself. Python is also object oriented. However, it does not force the object orientation on you like for example, java does. So, if you want to write a purely procedural program you can certainly do so. But if you want to write something you want to extend you want to create your own data types then you can also do it in python and there is no problem with that. So, it is kind of a flexible language that suits your needs rather than forces you to do anything that in a particular way that it desires. The other important point for many people who are doing engineering and science is that often they have their own codes they have C C plus plus and fortran codes. And python offers a lot of techniques and strategies in order to be able to access such codes and be able to in order to be able to use all of this code. So, one of you has asked me a question as to how it does handle memory management well it uses reference counting to handle memory management. And basically what you need to think about with respect to memory management is do not worry about it. You create objects and python will manage these objects for you you do not have to worry about it at all. Ultimately the point of this whole thing is that your time that is developer time is a lot more valuable than machine time. Because nowadays computers are much more powerful than they ever used to be and they are rather inexpensive. So, let us get started let us look at the interpreter. So, to get started the first thing you do is on your terminal I am sure all of you know how to start a terminal. You start the terminal and you will see text that looks like this. So, if I start the python interpreter on the shell you will get something that looks like this. Here we are running python 2.6.5 if you notice here ok. So, basically once you start python I am sure you must have all started python you can you will see this text that starts up which tells you about the python version that you are running and you will get a prompt with these three arrows which is the interpreter's prompt. And the interpreter is basically waiting for you to give it some command input. So, let us get started with the first. So, let us write our first little python program. Let us say print hello world typing here something else here and you hit return. So, type out this text hit return and the interpreter will print out hello world.  So, to repeat you start with typing python hit control D to get out of the interpreter. This standard python interpreter that we have we call it the vanilla python interpreter is not the most full featured and functional. And there is a special interpreter called I python which is again implemented fully in python and I python is what we call an enhanced python interpreter. And what I python lets you do is it gives you a lot of user conveniences that are extremely convenient for a programmer. So, what we will do is we will soon switch over to I python. But before we move there let us look at the versions. So, someone yesterday even asked me what is the difference between the live python that we have supplied and 3.x. In live python what we have by default provided is the 2.6 or 2.7 version of python and 3.x is basically not backward compatible with 2.x. So, there are some changes to the language that have been made in order to improve the language. The problem however 3.x is a lot of the scientific packages that are necessary for the purposes of this course and for the purposes of engineers and scientists are not yet converted to 3.0 3.x. Therefore, we are continuing to use 2.x for the purposes of this course. Now 3.x introduces some changes, but the changes are not too major. And therefore, what you are learning in this course for the most part will work well in 3.x once all of the packages are ported and you need not worry about it too much. Just continue to use 2.6 or 2.7 in the future and maybe in a year or so when things mature in the 3.x side we will move to 3.x. So, let us start with I python now. So, I python is an enhanced interpreter and to be able to use it you need to have it installed. So, it does not part of the standard python ecosystem. So, you have to install it, but to run it once you have it installed. So, you have installed the live DVD that we have given you it comes built in with I python. So, if you say I python it will start what is called the I python interpreter session. So, what you see here is again something similar to what we had before the string that tells you about python. In addition it says that you are at I python 0.10 and it says it is an enhanced in an interactive python. So, let us start with our first program in python print hello world and it does the same thing as python does. Notice the differences the differences are that instead of the original prompt of the 3 less or greater than arrows you have this in number 1 and notice that the prompts are numbered. So, you know in 1 in 2. So, each of them has a numbering in our slides we have we have ignored this number because it makes it little complicated. So, you will only see in open bracket close bracket colon. To exit I python again you do control D at this time python I python will prompt you it will say you want to exit really or not. So, if you hit return or you press Y and return it will exit if you press no obviously it will not exit. So, to repeat you start I python just like python you just spell I python and you hit return you will get the I python prompt and it is like the standard I python standard python printer except it has some additional features and to exit again you do control D. If you are running on windows you will have to do control Z followed by a return if you want to exit the I python session. So, let us get started we will start with some simple math to get comfortable you can use I python as a simple calculator and I do this very often. So, if I want to do some little calculation I will quickly open up an I python session and then start typing away to get the answer. So, let us try some simple tricks. So, please type the expressions that are given to you on the screen here. So, each time you run one of these lines say 1 plus 2 and you hit return you will get the answer. So, you will get 1 plus 2 the answer will be 3 same way if I say 5 minus 3 I get 2 7 minus 4 and note that if I keep hitting return the counter just keeps incrementing they just blank lines 6 into 5. So, notice one thing that every time there is something that is returned by an expression. So, if you look at 5 minus 3 it is an expression whose value evaluates to 2 all of these evaluations on the values that you get are stored in something called out. So, you look at it there is an input which is clearly marked by i n and there is an output that is clearly marked by 3. So, the third output is 2 the fourth output is 3 and so on. So, you can see that it is already doing something that is reasonably useful. One very powerful feature of I python is the fact that it lets you access the I python history. So, let us say if I do print 1 plus 2, notice by the way that when I made a mistake I said print 1 plus and I accidentally hit return it gave me a syntax error it did not bomb that is it did not die and the I python session did not kill me I just got an error telling me that there is an invalid syntax this is one of the nice advantages of an interactive interpreter or an interactive session. Anyway, so once I print 1 plus 2 and hit return note that it does not give me an output because the print basically prints it to screen it is not evaluating or returning any value. If I did 1 plus 2 just to recap it actually gave me an out on the other hand when I do print it does not give me any output. But what I am trying to illustrate here is the feature that I python offers.  So, I want you to do this exercise change the that line print 1 plus 2 by hitting up arrow go to the previous command and change it to print 10 into 2. Please do this on your sessions I will give you say 10 seconds to do it. So, if you have any questions now please raise your hands. What is the reason for not showing out is one of the questions any other questions to answer your question what do you think print does print return print something to screen it does not. So, it is not returning a value it is not evaluating an expression it is just printing some value to screen.  You are not actually evaluating while you are evaluating it and the evaluation is passed on to print and you are telling print to do something and print does not do anything apart from printing it to screen. So, there is no output that it actually produces apart from writing to the screen that you have already seen that is the reason why it does not show it. Since no one else has any questions let us move on quickly. The other very very powerful feature that I python has is what is called tab completion. Yes as I explained printing is after the evaluating an expression, but you are essentially telling python I want to print that expression you are not telling it to evaluate the expression and return it. Remember that you are composing functions you are saying that print you are saying print is a keyword. So, you are saying print something and you are explicitly saying you are giving the expression to print not to the not to the interpreter. So, if you want to see something on screen you are going to have to print it. I python is doing or python is doing a simple convenience for you that it is actually giving you the output of every expression that it evaluates and it caches and stores that somewhere. So, do not get too worried about it, but realize understand that print is not going to evaluate anything print print is going to show something on screen. So, you have evaluated an expression 1 plus 2 and it is going to be sent to print and print is going to display it that is it. And if you want to see it on screen say in a python script or something like that you have to print it if you do not print it nothing will happen. The python shell or the interpreter is conveniently showing you what has been evaluated that is all. So, one powerful feature that is the fact that python provides you tab completion. So, to check this out. So, let us type r o tab and you get round it automatically completes r o tab to round. So, try to type r tab and you will see that it will actually give you all of the possible completions that are available. So, if I say r a tab it will now give me 3 options say r a n becomes r a n g range. This is again very powerful. The other extremely useful functionality that I python provides is the question mark for help. So, let us say I have the function a b s. So, I do a tab a b s I get if I do a b s question mark and followed by a return it will show me the help built in help for the function. So, for example, if I do a b s of 19 what it is saying is it returns the absolute value of the argument. So, if I say a b s of say 9 it is going to be 9 a b s of minus 9 it is going to be 9. So, now, you can look at the documentation of built in functions and decide for yourself what you need to do. So, one note for all of you please ask questions relevant to the section we have 107 slides that are going to cover a lot of material. So, please do not jump ahead and start asking me questions I will not answer such questions. So, now, if you look at the round documentation. So, round documentation how would we look at that we will have to do question mark followed by return. When you do that it is going to say round give you a number and now it adds these funny looking brackets here again those of you who are already familiar with this please do not say there is nothing new in this or something like that I am trying to explain the language for the purposes of everyone who is attending and there is a lot of people who are attending round number followed by optional parenthesis in digits suggest that the end digits that you see here is an optional parameter which means I can do round 1.123 and that round number is it to 1 decimal place, but if I say round it I supply an additional argument which is optional to say 3 decimal places or 2 decimal places and notice that in all of these cases when I do when I wanted to change the line I hit up arrow and change.  So, is this clear any questions at this point for optional arguments. So, documentation strings will generally use these optional into denote optional arguments will use square brackets. So, the other thing that could happen is sometimes you are typing you say round 1.123 and you accidentally hit return like this. Now, you will see that the prompt has shifted to dot dot dot colon what this is suggesting is I Python is expecting additional input that it is not complete. So, now you have two options one is you hit you complete the bracket you get the result or you can hit control C which will basically interrupt it and not evaluate what you have typed. Generally, hitting control C is one mechanism by which you can interrupt. So, if you have say a loop that is going off it is going crazy you can basically hit control C to interrupt it. Someone is asking me a question we are getting different answer yes. So, someone has asked me this nice question it is a good question. So, you are saying round 2.626 comma 2 and notice that it is saying it is 2.62999999. So, what do you think the correct answer? So, in my case I would think the correct answer is it should be 2.63. So, if it is 2.63 2.629999 is the closest floating point representation that you can get. So, when we do numbers later on you will understand why this happens. So, we will do this in a little while. So, let us move on to basic data types and operators that are available in Python. So, the basic data types that are available are numbers which are integers, floating point numbers, complex numbers and all of these are built in. There is also the Boolean data type and there are sequences. Sequences most commonly are strings, lists and tuple. So, a string is a sequence of characters, a list is a sequence of objects and so is a tuple. We will look at these in greater detail as we move on. So, some of you are running into issues with different versions of Python that you are running. So, sometimes the results could be slightly different. For example, the way in which quantities are printed in 2.7 Python version is very slightly different from the way in which numbers are printed on screen. On screen for example, when you look at my interpreter I am getting 2.629999. So, if you are using a 2.7 interpreter it will probably give you 2.63. Now, there is nothing correct or wrong about it. In which case it depends the actual what you are seeing on screen depends really on the implementation of that particular version of Python. Now, I will get to floating point numbers in a little while and we will discuss all of this in a greater detail when we do floating point numbers. So, there is another question which says is Python not a typing language. I do not know what you mean, but if you mean that is Python strongly typed the answer is yes, Python is strongly typed. Every object in Python has a type, but it is not statically typed, it is dynamically typed. So, let us move on. We will look at little more. So, please bear with me for a little while. Please do not ask me too many questions for the first phase. Let us finish the basic data types and then we will then please I will stop you ask me a bunch of questions. So, take down a list of questions because I want to finish this segment and we will answer some of your basic questions initially. And once I do that we will get somewhere where we will have comfortable point where we can ask things. Yes, I will do that. I will take questions after some point, but people are asking me and sometimes I prefer an interactive class to a non-interactive class. So, what I will do is I am going to wait till I finish basic data types and operators and then I will pause for about 15 minutes to ask for questions. So, please till then I will not you can go ahead and type the questions here if you want to, but I would suggest you do not because I look at the chat session to know if someone is having a big problem because I see it show up for me. So, if someone has a question something urgent you please ask me till then I would suggest you either take it down write it in a separate terminal or something like that. Thank you. So, let us move on. So, if you want to create a variable so far we have not done that all you need to do is give it a variable name. There are certain restrictions on variable names which I am not going to discuss right now. So, if you want to create an integer say you just have to say a is say 13. Now the type of a can be determined by the command type of a and the type command if you want to find out what it does the type function basically returns the objects type. So, if you look at the documentation again it says type given any object will tell you the types objects type it will return the objects type. So, it is a built-in function. So, it is a python built-in function that is available for use. Now integers can actually be arbitrarily long. So, for example I can know it turns out that I am actually lying python has two forms of integers one is the integer which is a fixed size the other is what is called a long, but you do not have to worry about the difference. For example, so if I say type of a gives me a variant if I say type of b it will tell me it is a long. However, obviously I can say c is say a to the power a. So, what do you think the type of c will be? Remember what is a? a is 13, 13 to the power 13 is going to be a very large number. So, type of c is actually long. So, because what happens is automatically it overflows and python will convert that integer to a long internally. So, you do not have to worry about. So, effectively all you need to know is integers support or can be arbitrarily long. So, you can even do. So, if I want to do say c to the power 3 or c to the power 4, c to the power 5 as you can see the integer can keep growing in size. So, it is not to a fixed size. Same point numbers in python are again pretty straightforward. So, if I do 3.1415 type p it will tell me it is a float. Notice that on different interpreters you will get different numbers when I do p if I do just p here look at the fact that it shows me so many decimal places. However, if you are using 2.7 it will only show you 3.1415. So, decimal numbers are basically represented using the float data type and the float data type is a finite precision data type. So, basically it is a 64 bit I triple E 854 standard double precision number. So, float basically corresponds python float corresponds roughly to c is double. So, they have a fixed precision. In fact, they have a fixed amount of space for the mantissa a fixed amount for the exponent and they have a sign bit. Now, as a result of this it is obvious that you cannot express every number in the real line with floating point numbers. So, what happens is in my case if you look at p when I type p here it prints 3.14150002 the reason is there is no exact representation of 3.1415 on the computer. So, it is giving me the nearest possible expression that it is able to derive based on the binary representation that is stored inside. And this is just a natural issue with floating point numbers that you are going to have them regardless of what you do. So, basically it makes sense only to print out say the first 4 digits 4 or 5 digits in this particular example. So, to summarize floating point numbers have a fixed amount of precision floating point numbers correspond to c floats they are not arbitrary precision they are essentially 64 bit numbers 64 bit floating point numbers corresponding to the I triple E I think 754 or 854 standard. And as a result of the fact that it is a floating point number it cannot represent every real number exactly it is only going to be an approximation. However, the approximation can get as close as you would like given the limitations of the floating point number. I hope that answers some of the other questions people were having just before. So, floating point numbers are again built in into Python. So, to create one you simply do c is let us say 3 plus 4j type of c is complex to access the real part you do c dot real, c dot image and the absolute of c will give me 5 it is a square root of the sum of the squares of the real and imaginary part of the complex number. So, some of you might have the question. So, is j a keyword turns out that j is special syntax. So, when I do c is 3 plus 4j it does not mean that j is a variable that is available. For example, I could say j is 1 and c is 3 plus 4j will still give me 3 is a complex number and j is still that integer that has been created. So, j is simply special syntax that is used by the interpreter to allow you to create a complex number. Another way by which you can create a complex number is to say complex. So, you can do it either by this convenient syntax or you can do it by this. So, moving on you can perform operations on numbers. So, the first 3 examples you have already seen 23 plus 74, 23 plus 23 minus 56, 45 into 76 and here comes the first big surprise. So, if you do 8 by 3 you get 2. So, when you divide if you are doing division of two integers it will assume that you want an integer result. So, if you want explicitly a result that is a floating point you must cast one of the numbers into a floating point. You could either do that or if you have a variable say you have a is equal to 8 and b is equal to 3 and I say c is equal to a by b c is 2. However, if I wanted to make this such that I explicitly wanted to make this a floating point I can do this. So, there are different ways by which this can be achieved. The thing I wanted to note bring to your attention is if you look at the terminal earlier on I had said a is something I had said a is some 1 or something like that. Later on I said c is 3 plus 4 j after that I say c is a floating point number. So, as you can see a variables type is not fixed forever in time. A variable can acquire a different type of object at any point of time and you control what you supply to it. So, this means that the objects are the names are actually bound dynamically to different kinds of objects. It is not statically defined as it could be in a statically type language like say c or c plus plus or java. So, moving on the other functions that are of interest are modulo. So, 87 percentage. So, the percentage operator is modulo and the power exponentiation operator is given by double star. Note that if you do 7 power 6 doing this will give you a very surprising answer. Doing 7 karat 6 actually does a bit wise operator. So, do not get confused the karat is only a bit wise operator and power is always given by double star. Notice that this slide is again just telling you what I have already shown you that all of the operations that I did could also be done as well on variables.  Similarly, c is 8, d is 8.0, f is c by 3 all of this again things that I have already shown you on the interpreter. So, in this all of these cases c is equal to 8, d is equal to 8.0 all of those cases show assignment. There are also in place assignments. So, for example, if c is equal to 8. So, c slash equal to 3 will be c is equal to c by 3. So, it will be 2 in this case. So, if I wanted to change it to a floating point number. So, now c will be 2.666. So, it is very straight forward. So, I am going to move on because this is very straight forward material. Let us move on to Booleans. So, for Boolean operations there are two basic quantities true and false. So, to define something as true you use the upper case true, little true is not defined. There is capital true is true. So, it is called true and not true is false. So, you can use to say something is true or false you use capital T for a small true and capital F false. The operators that you have operations on Booleans that you have are not please do not use something like this because that again does not quite denote Boolean operations. It will do bitwise operations. It will not every bit in some number for example or an and again all of these make it rather easy to read. So, for example, if you want to have a Boolean expression which says F and T or T it reads very naturally which is why another reason why Python is a lot easier to read for many people. So, notice in this case that I am using brackets here to denote operator of precedence. There is so I explicitly state what we mean by using brackets and this is generally a very good idea to do. And I am not going to discuss operator of precedence because it is kind of pointless. Even I do not remember half the time what is the operator of precedence in certain things. I can guess what is it. I can think of something but it does not really matter because always what you should be really concerned as a programmer is to make things readable to another programmer and not have to rely on some complex set of rules that someone has to remember in his mind. So, it is a good idea to generally use a parenthesis to denote explicitly what you try to mean and you can use as many parenthesis as you feel necessary for that particular expression. The other thing you should be worried about is do not use too many parenthesis. Then it becomes so many parenthesis that you cannot figure out what is happened. It is just a general point of style. So, moving on let us look at sequences. We will do the sequences in much greater detail in a little while. So, right now what we look at is the general flavor of sequences. What does a sequence? What kind of sequences are there? What can you expect from sequences? What are the most common operations that you would do on sequences? And that is what we will discuss right now. So, hold off any detailed questions of how do you manipulate strings? How do you manipulate lists or tuples? We will do all of that later. So, right now we will look at the big picture so that you get an overall perspective of the basic data types that Python has to offer, some of the basic data types that Python has to offer. So, the basic principle for a sequence is that it holds a bunch of elements. Sometimes the elements can be this have to be the same type. Sometimes they can be a different type. Elements are accessed based on their position in the sequence. So, the sequence is basically very efficient for random access which means I can access a sequence, any element of that sequence in constant time and they all have a position that is implicit in that particular sequence. I will give you examples to explain. And the basic sequence types that we are going to cover right now are strings, the type for which is str, lists and tuples. We will look at all of these shortly. So, here are 3 examples each creating a different sequence type. The first is what is called a string. So, let us just type this. Then you have num list which is a list of 1, 2, notice how it is created. A string is created with an open quote, close quote double quotation and a list is created with square brackets with elements separated by commas as you can see in this. So, square bracket open elements separated by commas close bracket. And a tuple is similar to a list, but it starts with an parenthesis 1, elements followed by spaces sorry by commas. The spaces are optional, the spaces that I am typing after the comma here or before the comma, they are all optional. However, they are important in terms of readability. So, it is a good idea to keep them. So, now I have created 3 variables grid string, num list, num tuple each of which can be created like this. So, now what can you do with this? To access the elements, the first major thing you will need to do is to access the elements, to access them, you basically can access them using the bracket operator. So, in this case if you do num list 2 or num tuple 2 or grid string 2, notice that the pattern is similar. That is the point that we are trying to illustrate. We are trying to give you the big picture. In the big picture if you want to access a list, an element from the list, you give it the bracket and you give it the index of the quantity. It turns out that in python the indices start from 0, they do not start from 1. So, num list 2 should give me what, think about it for a second. Num list 2 should give me what, it should give me 3. It will give me the third element in the list. Similarly, num tuple will also do the same thing. Like any reasonable language, all of the indices are based on 0, not on 1. It is not like strings are 1 and lists and tuples are 2. One of the things that you will notice with python is many things as you go along will become, will make sense and will kind of be the obvious thing to do in that particular language. The only thing different may be from Fortran is the fact that the indices are offset from 0 and not from 1. That is the only thing you need to remember. Now, given 2 sequences, you can add 2 sequences to form a new sequence. You are not going to change num list in this case. You are going to create a new sequence which is the sum of num list plus 3, 4, 5, 6. So, in this case what do you expect to see? You will get a new list which for whose the content are 1, 2, 3, 4, 5, 6, 7, 8, comma 3, 4, 5, 6. So, you will have a list of 1, 2, 3, 4, 5, 6, 7, 8 plus 1, 2, 3, 4, 12 elements. So, you will get a list of 12 elements. So, let us try that num list plus 5, 6. Now, how do you find the length of such a sequence? So, I will show you a little convenient trick. In the last case, I did not save the in this in this interpreter session. I said num list plus 3, 4, 5, 6. Now, I have lost that the thing that it evaluated to. I do not have that I did not store it as a variable. So, if I want it on the interpreter, the last expression is always available as underscore. So, if I say length of underscore. So, I could say for example, result is underscore. Now, I can say length of result and it is 12 as I had expected. Underscore is just a neat trick I am teaching you. It is not in the slides, but it is convenient sometimes. So, for any sequence, three things. You can access the elements using the bracket operator. You must give it an index. The index has to be an integer and it starts from 0. You will learn soon that there are negative indices that you can supply. We will do that subsequently when we do sequences in more detail. But it has to be an integer. The index starts from 0. So, the counting starts from 0. You can add two sequences of the same type. Obviously, it makes no sense to add a string to a num list. So, how do you know that you cannot do it? Well, we can try it. What do you expect? You will get an error. So, it says type error. You can only concatenate a list, not a string to a list. So, the error messages in Python are very, very clear. And I urge you to strongly ensure that you learn to read error messages. They are extremely important and many, many users, even people who are familiar with Python, who are familiar with programming often do not bother to read error messages. Error messages are there for a reason. They are for you to read and they are very precise. Typically, they give you good idea of what is going on. So, when you see an error message, do not just glaze your eyes over. Make sure that you read it and make sure that you try to at least attempt to understand what it is saying. And this is a very good practice for you, so that you are able to debug your own programs. If you see an error, you get a very clear understanding. So, what is it saying? It is saying a type error. It basically means the error has something to do with the types of the objects. Number two, it is telling you explicitly that it can only concatenate a list, but not a string to a list. So, given two lists, I could add them, but given two different types, you cannot add them. You may not be able to add them. Sometimes you can, sometimes you cannot. But by default, you should assume that you cannot unless there is a very obvious way that which they could be added. In this case, there is none. Finally, the last point is the length. So, if I say length of greet string, notice that I do not have to type all of greet string. I can do greet gr tab and it will, python will complete. So, python will complete on variable names and functions and anything that is available on your interpreter. So, tab completion is a useful thing to use as is history. So, length of greet string is 5. In my case, because greet string is hello. In the example that is given in the slides, the length will be slightly different. So, I hope you understand what is happening. So, the next major thing about sequences is the fact that there are certain common ways by which you can interact or program with these sequences. The first is checking for container ship. So, if I want to see if the number 3 is in the lists, in the elements of the list, I simply say 3 in known list. Same way, if I want to say if the character h is in the greet string. So, let us try some simple experiments. So, h in greet str. So, what do you expect in this case? If I am doing a check, it means the result should be a boolean. So, if I did this, what do you think I will get? I should get true. So, for example, if I did z in greet string, it should give me false. So, what if, does this also work for h e? Remember that my greet string is hello. Does this make sense? So, the first question you have to ask is h e in greet string. Is that a reasonable question to ask? The answer is yes. So, h e in greet string, it is certainly there and it should give me true. So, now, if I say 3 in known list, that is true. But can I do this? So, now the question that you must ask yourself is, is there an unambiguous way for python to determine what the user is trying to do? So, in this case, it turns out that 3 and 4 is not in known list. So, what do you think is happening? What is known list? So, 3 and 4 are there. So, why are you surprised? Well, what you are actually asking is, is this element 3 comma 4 in known list? It turns out that list can store anything, list can store other lists. So, if I say l is 1, 2 and 3. So, what is 3 comma 4 given in as a list? So, remember a list can contain other lists. So, now if I try 3 comma 4 in l, it is true.  So, when I say something is in a list, you have to be very careful. You are essentially asking, is that element there in that list? Whereas, this does not hold for sequences which are strings, because in strings it is unambiguous. When I say he in greed string, what do I mean? Is that substring he available in this string? So, it is very clear, it is very obvious to the programmer. And in this case, again you should not be surprised, because this there is an ambiguity. Should I check for both 3 and 4 in that list or should I check for 3, 4 in a list? That is in this list. So, it obviously means that 3 comma 4 in known list, I would want to check for this because I can have 3 comma 4 as an element in that list. So, keep these small differences in mind as you program. One very useful tip that I am going to give you now, that you may not appreciate that I am telling you now, but as you program you will appreciate is to please use the interpreter more and more. So, if you have a question, should this work like this or should this work like that? What will be what is Python going to do? Do not ask me, ask your interpreter. So, you just start up the interpreter, type in the expression you are trying to experiment with, understand what it does, figure out why it is doing what it is doing and that will give you the answer. I can be wrong, but your Python interpreter is not going to be wrong because that is the interpreter. So, we now have seen how to look at, how to access the elements, how to add sequences, get the length of a sequence. This length function is a built-in. So, it is always available in Python. The check for container ship, you can do 3 or whatever element you are looking for, in is a keyword, the necessary list and this applies to all types of sequences. To find the maximum and minimum, you can say max of, there is 8 as you would expect, but what is minimum of grid string E? So, now it is going to do some kind of alphabetical listing and which is the smallest element in the grid string. Slicing, which is described in this third point, bullet point here, is an extremely important aspect of sequences. We will do this in much greater detail as we do sequences in more detail, but I want you to understand that there is this fundamental operator that you can apply to any sequence and it is called a slice. So, notice the next line, num underscore list, open square bracket 1 colon 5. The important thing for you to notice is, there is this 1 colon 5 here. Earlier the last slide, we simply had a single integer, but now you have this funny syntax of this 1 integer followed by a colon followed by another integer. So, what does this mean? So, let us see. So, as I said before, how do you find out what something does? Well, you type it, num list 1 colon 5. What would you expect? You would expect a slice to basically say, give me all the elements between 1 to 5, which is what it does. So, original num list is 1, 2, 3, 4, 5, 6, 7, 8. 1 to 5 is basically giving me element number 1, which is 2, element number 2, which is 3, element number 3, which is 4, element number 4, which is 5. And notice that it does not give you the fifth index. What is num list 5? Num list 5 is 6. So, it is not giving me that element. So, the general syntax that you should understand is, when you slice over a sequence, it will give you the starting index value, that is the first index, to every element excluding the last index. So, it will give me 1, 2, 3, 4. Is this clear? So, this is what a slice is, and it is an extremely powerful way. So, for example, if I want to get greet string, I want to get that is only a low. So, you can understand that this works for all kind of sequences, for tuples or lists or strings. So, these are common operations that are very important for you to understand. The last point that you will again, we will again revisit several times in this course is what is called striding. Notice that when I did 1, 5, the indices that I was interested on were 1, 2, 3 and 4. So, which gave me num list first, index number 1, index number 2, 3 and 4, which gave me the result 2, 3, 4, 5. So, I am striding there between those indices by one element. So, 1, 2, 3, 4. But if I want to jump the intermediate fellow, what do I do? I want to say give me 1, give me 3 and give me 5, but 5 is beyond 4. So, I want to just get 1 and 3, I could say num list 1, 5, 2. This will simply give me 2, 4. Is this clear? What it is doing is, it is giving me elements between 1, 2, 3, 4, but stepping by 2. So, it is essentially start index, last index plus 1 and 2 is jump by step by soming. So, if I did 1, 5, 3, what do you expect? It should give me 2, 5. If I did 1 and 4, it will simply give me 2, because by stepping by 1, I have exceeded my last index. So, I will recap all of these. Sending elements is through the bracket operator. Indices start from 0. You can add two sequences of the same type, that is very important. You can find the length of a sequence using the LEN built-in. You can check for container ship using the IN keyword. There are built-ins available to find the maximum and minimum element. Now, obviously these are only going to apply or make sense if you have elements of the same type and there is a notion of comparison between those elements. If there is no notion of comparison, you are finished. It is not going to work. You can slice a sequence using this syntax, which is starting index colon final index plus 1. So, why is it doing final index plus 1 and does not give you that last index? The reason is to do with supposing I have noom 1 colon 5. How do I get the remainder? I will do noom 5 colon. So, this will give me everything from 1 till the end. So, notice that if I do not supply an index, it means go to the end. If I just give a colon, it means from fifth to the end. Finally, striding, if you supply an additional colon 2, it will stride by 2. Colon 3 will stride by 3. So, with this we finish the basic introduction and now we will go on to string. So, at this point I will stop for some questions. So, please ask your questions, raise your hand or ask your questions and we will take a quick round of questions maybe for 5 or 10 minutes. I think there is a break at 11 o'clock. So, before the break 5 minutes we will ask questions. So, first question is what is the difference between a list and a tuple? We will answer that when we do lists and tuples later on. I will not answer that question now. The second question on the chat is if alphabets are capital and small in the same string then how does min max function determine the output? Please try this as an exercise for yourself and answer the question by yourself. You have the interpreter to give you. Third question is what is the use of ABS in complex number? Well, for that you need to understand complex numbers and this is not a class on complex analysis. So, ABS in complex number in complex number system, the absolute value of a complex number is defined as the square root of, so if you have a number A plus J B that is real part A, complex part B the absolute magnitude of that number is defined as square root of A square plus B square. So, think of it as a definition and ABS simply does that. Yes, so there was one question by VP COE Baramati. I will switch over. Yes, yes please ask your question. Sir, my question is when you told that when we are using print space 1, 2, 3, 4, 5, 4 plus 2, so in that case it is not going to show out. Yes. But when we are using the another functions like ABS or the round, so at that time it shows that. So, print and round all the in build functions are there. Print is not a function. But why it is happening with print? Print is a keyword. So, what print does is print is not a function. Print does not return anything. Print is a keyword, so that expression simply prints what is the expression you give print on the screen. It does not return anything, it does not do anything apart from that. Therefore, it is not going to give any output. The only output of print is what it returns, that is all, is sorry, is what it puts on screen, I am blabbering. The only output of print is what it prints on screen, so there is no out that is produced and do not worry about it. Basically, if you want to print something on screen, you have to say print. This 1 plus 2, if you put on a python file and run that from python, you will never see anything, because it is just an expression. It is not going to be printed to screen, only when you say print explicitly it will print. Otherwise, the interactive interpreter is simply doing it for your convenience. Next question is it is always returning minimum of the small alphabets, though there are capital alphabets present. So, that is an implementation detail that you have to deal with. So, if you really want to do a comparison better, you will have to do something, you will have to do it in a more intelligent way. Min is going to do something that it thinks is right. It is not going to do the right thing always. So, if you have for example, if you are transliterating Hindi and you want to find the min, does min make sense at all for a string string? It does not. Are you ever going to ask me the minimum of the string? No. If you are going to ask me to sort a set of strings, it makes sense. So, do not worry about min and max for in the context. I have personally never used min and max for a string and I have written a lot of python code. So, please trust me that in this case it does not quite make much sense to do minimum maximum of a string. So, do not get hung up on some silly detail like minimum or maximum of a string. Any more questions? Please ask them now, because after this we will be building on what we have learnt so far. I agree we have only done very basic material right now. We will be building on this and we will be looking at more details of a lot of these things. We will look at strings in detail. In between we will throw in some interesting problems that we need to solve. Then we will look at conditionals, loops, lists, input, output. So, we will be building a lot on top of this. So, any questions at this point? Okay. Question is can we reverse the sequence? If yes, how? The answer is yes, you can reverse the sequence. We will look at it in detail later. When we are doing lists, we will show you how to do it. There are ways to do it. There are many ways to do it. There is something called reversed which is a built in. There is also you can do it with slicing also. We will do it later. So, do not worry about it right now. So, there is reverse, there is sorted, you can sort.  So, let us not get into those details right now. Any other questions on material presented so far? Any doubts? Please ask them now, because it is important you understand whatever you have understood properly to respond. Is bounds checking performed? Well, why do not you try for yourself? So, the question is, is bounds checking performed? So, for those of you who do not understand what that means, supposing I have noom list, what if I say noom list of 100 or noom list of even 9, what will happen? So, try it. Try it and see for yourself. So, someone is asking, can you explain stride over a sequence? Okay. So, when you stride, so let us take the example. So, can you see the terminal? If I want to say, I want a sublist, I want noom list, I will take the simple example that we already discussed 1 colon 5. The result is 2345. Is that clear? So, it gives me index value number 1, which is 2, 3, 4 and 5. The index for this is 0, 1, 2, 3, 4, 5. So, the 5th index value is 6, which is not included in this. So, 1 colon 5 suggests 1 is starting value, 5 is last value plus 1. So, 1 is 2, 2 is 3, 3 is 4, 4 is 5, 5 is not included. Okay. Now, if you look at 1 colon 5 colon 2, what this will do is, in this case, I got the indices of 1, 2, 3, 4. So, I was stepping by 1 plus 1 plus 1 plus 1. Instead of that, I will now do 1 plus 2, which is 3 plus 2, which is 5. So, I will give you the first index k value, step by 2, give you 4th index value and then step by 2, I go to 6, which is not any more relevant. So, I will get simply 2 comma 4. Is this clear? Does it make sense? So, what this second colon, the index you specify after this second thing is simply saying step by 2. So, give me first index at 1, go all the way till 4, step by 2. So, it will be 1, 3, 5, 7, 9, but all those 5, 7, 9 are irrelevant because I am stopping at 4. That is what is dividing. So, if I did 1, 5, 3, it will give me 1, 4. Sorry, what I mean? So, it will give me 1, 4. 4th element is 5. So, does list inside a list represent a matrix? The answer is, well, yes and no. You can represent a matrix as a list of lists, but remember that a list is a heterogeneous. So, I need not have, the first element need not be another list. So, if every element is consistently a list and of the same size, yes, it could represent a matrix, but that is something you will have to implement. There are other ways to create matrices, which we will look at later in advanced Python. Anything else? Please feel free to ask me questions. I am not making fun of anybody, I am just saying it is an irrelevant, it does not make sense for me to answer that question and I have already said so twice. How can you access the list inside list? Okay, good question. So, I will create a simple list inside list L of 1, 2, 3, 4, close bracket. Notice here, I forgot to close a bracket, very common thing, no problem. I just came to the next line and closed it. So, L is that, so if I say print L. So, to access the first element, what do you think I will do? It will give me 1, 2. So, the first element is 1, 2. So, if I want now inside, so this is a list. So, if I want to get the next element inside the list, what will I do? So, if I want the second element, I will say this. That is 2. So, basically it is just another list. So, when I do L of 0, I get a list. That is also a list. So, I will access that element as a list. That is it. So, let us take a


Hello and welcome to the Santiago Bernabéu for this, the first Madrid derby of the 1994-95 season. It's match day 10, but Vistas Atlético already on their second coach of the campaign. Jorge de la Sandra returning for his second spell in charge. Real Madrid are looking to get back to winning ways after a setback in Zaragoza last weekend. Incredible atmosphere as always for a Madrid derby here at the Estadio Santiago Bernabéu. There's the young man Raul Gonzalez Blanco made his debut last week against Zaragoza. He has the faith of coach Jorge Valdano who gives him a start in this game under particularly taxing circumstances. A Madrid derby. Raul Gonzalez Blanco gets this underway taking the kickoff Raul Madrid playing from left to right in this first half. Really important the way the whites start this game. Need to dominate in terms of possession. See plenty of the ball and find a way of breaking down Atlético Madrid. Moving the ball around nicely here. Interception and the ball is out of play. But a space here for Atlético to get forward. Working it out to this left hand side. Shot from distance first of the game. Well wide. Amavisca here. Moving inside. Chance for a ball into the box. Got a bit of space here. Shot on goal just over the bar. First chance for Real Madrid. Good effort. Out of their seats here at the Bernabéu. Raul is there on the edge of the wall. It comes in. It's not a million miles away but it's just over the bar. Powerful effort. Wasn't able to get it on target. You can see from this angle. Not too far away. Space out on the right for Luis Enrique. That was the far post. Zamorano was there. Raul as well. Raul was the closest to it. In fact it's a Real Madrid corner. Lovely ball from Luis Enrique. Raul got there. It's a dangerous ball in his head. So close to the opening goal. And it's just wide from Zamorano. His first chance to the game. So dangerous in the air. One of the best in the world. With his head Zamorano. And that was a really good chance. Just couldn't direct it. Goldwoods. Lovely delivery. Perfect for the Chilean. Here's Redondo. Again looking to get something started. The base. The midfield exchanges passes with Michael Laudrup. Redondo in Tomaviska. Here's Raul into the box. Chance here for the whites. He's brought down Raul. Surely that's a penalty kick. And the referee agrees it's a penalty. Raul's run into the box. The Atlético defenders protesting furiously. It won't make any difference. It's a penalty kick to Raul Madrid. And a chance for the whites to go a goal up in the Derby. Raul with such an intelligent run. His movement has been really good so far in this game. Just as it was in his debut last weekend. Look, here Raul goes. Brought down. Here comes Michelle with the penalty up against Diego. I want to hit 1-0. Raul Madrid lead. Brilliantly struck. Penalty made no mistake. Fired it into the roof of the net. And Raul Madrid a 1-0 up here. And let's go. Players continue to protest. It won't make the slightest bit of difference. What a superb penalty kick. Diego went the wrong way. Michelle Reifelth at home. Raul Madrid have the lead here. You have to say it's deserved. Whether it's the occasion, the pressure, the start to the season they've had, the new coach, a combination of all of the above. They haven't quite got going far. Bullio takes that clearance quickly. It's a really good one as well. All the way up the pitch. Raul's out there on that left-hand side. Raul left footed. That's a really good delivery. Zamorano's there. It's 2-0. What a head-up. Raul Madrid double their advantage here at the Bernabeu. It's Ivan Zamorano. So good in the air. But what a delivery from Raul Gonzalez Blanco. The cross left footed was absolutely superb. Spot on. Exactly where Zamorano wanted it. He didn't apply to finish. He gets the congratulations. But so too. Just Raul Gonzalez Blanco for the cross he put in there. Just look at that delivery left footed. Zamorano rises to meet it. The low head-up. Really difficult for the goalkeeper to save because it's close to him. He can't get down to it. Diego Diaz. Zamorano the master when it comes to the headed goal. He's got another one here. He just wanted that more. Ivan Zamorano. Zamorano. What a ball in from Raul. That's a lovely ball. Let's go. Could be in here. Buyo comes for it. Gets the touch and the follow-up. Oh, they've got a goal back here. Let it go. 2-1 now. Paco Buyo did well to make the save initially. It was Kozeki. The number 10. He slotted home the follow-up. Let's go have a little bit of hope now having just gone two goals down seconds earlier. Corner kick decent delivery from Michel the header from Raul. Not too far away. He's already had quite an impact in this game. Raul Gonzalez Blanco won the penalty kick for Madrid's opening goal. Played the crossing for their second. There's Kiki. Laudrup just possessed but Madrid have it again. This is really good running from Laudrup. Laudras pulled his Raul.  It's 3-1. His first goal for Raul Madrid. The youngster. He's made on this game. Scores the goal to add to his assist and winning the penalty. And this 17-year-old in his first Madrid derby is running the show here. Unbelievable performance so far from Raul. Gonzalez Blanco. What a hit. What a finish from Raul. Took it left-footed first time. Kiki, Diego. Absolutely no chance. Michael Laudrup with the no-look pass. So good at that, of course. Looks one way. Plays the ball. The other. Raul Gonzalez Blanco does the rest. What a promising young player. Raul is. Come on, let it go. Again, they've got four players forward there. It's a really good ball in and that's an excellent save. I think the flag was up. Chance for a shot from distance. Brilliant hit off the woodwork. What an effort from distance. Power in that shot. Effort from Michel. What a goal. That would have been is Michael Laudrup. Again, the space opens up in front of him. Raul Madrid getting forward in numbers. Laudrup. Lovely pass. Out to Michel. Oh, it's 4-1. Again, Raul Madrid with a deadly counter-attacking goal to make it 4-1. It's the Chilean second of the game. The fans are ecstatic here. And before half time at the Bernabeu in the Madrid derby, Raul Madrid have scored four two for Zamorano. Raul and Michel with the others. The pass from Michel was perfect. A death finish from Ivan Zamorano. Guided it home. Let's go. Marking was poor. The ball from Michel was exquisite. A relatively simple task. First time on the half volley. What's this? Straight away. The referee has given Atletico I think a penalty kick out of nowhere. Straight from kickoff. Sanchez with the challenge went to ground very easily there. And it's Diego Simeoni with the chance to pull a goal back. Simeoni against Bullio. Simeoni last home the penalty. And it's four to six goals inside the first half here as we get this second half underway. Raul perhaps the outstanding performer in that opening 45 minutes. Kiko there getting involved with Paco Bullio. Bullio is always standing up to the wannabe intimidation. Shrugs off the challenge. He's going to the box. What a run. If he could have finished that off Laodra it really would have been one of the great goals. Michael Laodra with the ball at his feet there's no one better in world football. So close from Manuel Sanchez. Bullet header over the bar. Diego couldn't have got near it if it was on target. Rose height. This is the substitution and it's Raul Gonzalez Blanco what's a debut Madrid Darby for him. Scored a brilliant goal created a goal as well for Zamorano. Won the penalty for Michel. Wait to see how he develops just 17 years of age. Looks to have the world at his feet. This is good running from Amaviska. It's good ball to the far post as well. Zamorano is there with the flick down surely Laodra want to save. So close to making it five two. The danger still not over. Madrid wanted a penalty. Laodra there. Had the goal at his mercy but give credit to Diego Diaz who pulled off a wonderful save to deny it. Laodra he kept it low. This was in fact the penalty shout. I think it is. Plenty of space here for Amaviska. Left foot it. It's an important save from Diego. Could have made it five two. Got it on target. On effort. So close to going in. From Vasquez. Freaky played him right foot. Good delivery. It's put over. Madrid forward in numbers here and that effort not far at all away from making it five two. Left footed and rising from Michel. Would have been his second to the game. It's got great left foot. Laodra. And there is the final whistle. Real Madrid win the Derby by four goals to do a magical first half. And what's a debut Madrid Derby for Raul. Hope you've enjoyed the game here on Real Madrid TV. For now it's Adios.


I'm currently waiting to get a sleep. I'm hoping my meds kick in soon because I've got to be up early because we're filming. Film student. Wow. I'm not letting it everybody. It's an early start. Do you see it? It's getting discreet printed. Oh yeah it is though. Scene 3, shot 4, take 1. So that's it for my day filming. Thanks for watching and I'll see you guys in the next vlog. Peace.


There is a toxic drug supply out there on the street. If you use drugs or know somebody that does, please get informed. Overdoses are preventable. Lives can be saved. We can all be part of the solution.