├── CONTRIBUTING.md ├── DOUBLY_LINKEDLIST_PYTHON.py ├── Downloads └── Slides │ ├── chapter1.pdf │ ├── chapter2.pdf │ ├── chapter3.pdf │ └── chapter4.pdf ├── LICENSE ├── New.class ├── Numpy └── list.py ├── README.md ├── SINGLY_LINEDLIST_PYTHON.py ├── evenOdd.py ├── expression.py ├── foo.py ├── input.py ├── lec1.pdf ├── naya.py ├── nestedConds.py ├── new.py ├── operators.py ├── palindrome.py ├── password.py ├── prob1.py ├── programm.py ├── pybot.py └── reversestr.py /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribute and learn with other geeks here 2 | -------------------------------------------------------------------------------- /DOUBLY_LINKEDLIST_PYTHON.py: -------------------------------------------------------------------------------- 1 | class node: 2 | def __init__(self,data): 3 | self.prev=None 4 | self.next=None 5 | self.data=data 6 | class dll: 7 | def __init__(self): 8 | self.head=None 9 | 10 | def insert(self,data): 11 | new_node=node(data) 12 | 13 | if self.head==None: 14 | self.head=new_node 15 | else: 16 | n=self.head 17 | while n.next!=None: 18 | n=n.next 19 | new_node.prev=n 20 | n.next=new_node 21 | 22 | 23 | def display(self): 24 | if self.head==None: 25 | print('list is empty') 26 | else: 27 | n=self.head 28 | while n.next!=None: 29 | print(n.data,'',end='') 30 | n=n.next 31 | print(n.data) 32 | print('\nprinting elements in reverse order') 33 | while n.prev!=None: 34 | print(n.data,'',end='') 35 | n=n.prev 36 | print(n.data) 37 | ob=dll() 38 | l=[10,20,30,40,50,60,70,80,90] 39 | for ele in l: 40 | ob.insert(ele) 41 | 42 | ob.display() 43 | -------------------------------------------------------------------------------- /Downloads/Slides/chapter1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ctoic/Python-For-Beginners/24f3bb00fb16ebcb9560a535e034144570431ef9/Downloads/Slides/chapter1.pdf -------------------------------------------------------------------------------- /Downloads/Slides/chapter2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ctoic/Python-For-Beginners/24f3bb00fb16ebcb9560a535e034144570431ef9/Downloads/Slides/chapter2.pdf -------------------------------------------------------------------------------- /Downloads/Slides/chapter3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ctoic/Python-For-Beginners/24f3bb00fb16ebcb9560a535e034144570431ef9/Downloads/Slides/chapter3.pdf -------------------------------------------------------------------------------- /Downloads/Slides/chapter4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ctoic/Python-For-Beginners/24f3bb00fb16ebcb9560a535e034144570431ef9/Downloads/Slides/chapter4.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Najam Ali Abbas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /New.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ctoic/Python-For-Beginners/24f3bb00fb16ebcb9560a535e034144570431ef9/New.class -------------------------------------------------------------------------------- /Numpy/list.py: -------------------------------------------------------------------------------- 1 | # Including numpy in python 2 | import numpy as np 3 | 4 | # adding a list to another list 5 | 6 | list = [2 , 3 ,4 ,4 ,4 ] 7 | list2 = [3 ,4 ,5,5,5,6,] 8 | 9 | list3 = list+list2 10 | print("List 3:`",list3) 11 | 12 | # adding numpy arrray to list 13 | print("List 4") 14 | list4 = np.array(list3) 15 | print(list4) 16 | print("List 5") 17 | list5 = np.array(list3) + list4 18 | 19 | print(list5) 20 | 21 | 22 | print(len(list4)) 23 | print(len(list3)) 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python for Beginners 2 | Welcome to Python for Beginners! This repository is dedicated to helping beginners learn the basics of Python programming. The aim of this repository is to provide a comprehensive introduction to the Python programming language and to help you develop the skills needed to become a confident and competent Python programmer. 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Table of Contents 21 | 1. Introduction to Python 22 | 2. Setting up your development environment 23 | 3. Basic syntax and data types 24 | 4. Variables and operators 25 | 5. Control flow statements (if-else, for loop, while loop) 26 | 6. Functions and modules 27 | 7. Exception handling 28 | 8. Working with files and directories 29 | 9. Classes and objects (OOP) 30 | 10. Regular expressions 31 | 11. Advanced topics (e.g. decorators, generators, etc.) 32 | ## Introduction to Python 33 | Python is a high-level, interpreted programming language that is widely used for web development, data analysis, artificial intelligence, and many other applications. Python has a simple and straightforward syntax, making it an excellent choice for beginners. It is also very powerful, with a large and active community of developers who contribute to its growth and development. 34 | 35 | ## Setting up your development environment 36 | To start programming in Python, you'll need to have a development environment set up on your computer. You can use an Integrated Development Environment (IDE) such as PyCharm or Visual Studio Code, or a simple text editor like Notepad++ or Sublime Text. We recommend using PyCharm, as it provides many helpful tools for debugging and writing code. But for beginners I will recommend jupyter-notebook. 37 | 38 | ## Basic syntax and data types 39 | In this section, you'll learn about the basic syntax of the Python language and the different data types that you'll use when programming in Python. Data types include numbers (integers and floating-point numbers), strings, lists, tuples, dictionaries, and more. 40 | 41 | ## Variables and operators 42 | Variables are used to store data in your program. You'll learn about the different types of operators in Python and how to use them to perform arithmetic operations, comparison operations, and more. 43 | 44 | ## Control flow statements 45 | Control flow statements are used to control the flow of execution in your program. You'll learn about if-else statements, for loops, and while loops and how to use them to make decisions and perform repetitive tasks. 46 | ### Internal Working of Lists 47 |
48 | The Python code in the script already creates a list with the name areas and a copy named areas_copy. Next, the first element in the areas_copy list is changed and the areas list is printed out. If you hit Run Code you'll see that, although you've changed areas_copy, the change also takes effect in the areas list. That's because areas and areas_copy point to the same list. 49 |
50 | If you want to prevent changes in areas_copy from also taking effect in areas, you'll have to do a more explicit copy of the areas list. You can do this with list() or by using [:]. 51 | 52 | 53 | ## Functions and modules 54 | Functions are reusable blocks of code that can be called from anywhere in your program. Modules are collections of related functions and data that can be imported into your program to be used. 55 | 56 | ### Numpy 57 | : rocket 58 | 59 | ## Exception handling 60 | Exception handling is used to handle errors and unexpected conditions in your program. You'll learn about the try-except statement and how to use it to catch and handle exceptions. 61 | 62 | ## Working with files and directories 63 | In this section, you'll learn how to work with files and directories in Python. This includes opening and closing files, reading from and writing to files, and more. 64 | 65 | ## Classes and objects 66 | Classes and objects are the building blocks of object-oriented programming (OOP) in Python. You'll learn about classes, objects, inheritance, polymorphism, and other OOP concepts. 67 | 68 | ## Regular expressions 69 | Regular expressions are a powerful tool for pattern matching and text processing. You'll learn how to use regular expressions in Python to search for and manipulate strings. 70 | 71 | ## Advanced topics 72 | In this section, you'll learn about some advanced topics in Python programming, such as decorators, generators, and more. These topics are not necessary for beginners, but they are useful to know if you want to become a more advanced Python programmer. 73 | 74 | ## Projects for beginners 75 | Guess the Number Game - A simple game where the user has to guess a randomly generated number within a specified range. 76 | 77 | To-Do List Application - An application where users can add and manage their to-do items. This project can cover topics such as reading and writing to files, using dictionaries, and working with functions. 78 | 79 | Mad Libs Generator - A fun project that generates a mad lib story based on user input. This project can cover topics such as string formatting and working with user input. 80 | 81 | Weather Application - An application that retrieves the current weather for a given location. This project can cover topics such as making API requests and working with JSON data. 82 | 83 | Rock, Paper, Scissors Game - A simple game where two players play rock, paper, scissors against each other. This project can cover topics such as control flow and making decisions based on user input. 84 | 85 | Tip Calculator - An application that calculates the tip for a given amount based on a specified percentage. This project can cover topics such as arithmetic operations and formatting output. 86 | 87 | Encryption/Decryption Tool - An application that encrypts and decrypts messages using a simple substitution cipher. This project can cover topics such as working with strings and characters. 88 | 89 | Hangman Game - A classic game where the user has to guess a word within a certain number of tries. This project can cover topics such as arrays and working with random numbers. 90 | 91 | I hope this list gives you some inspiration for your next Python project! 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /SINGLY_LINEDLIST_PYTHON.py: -------------------------------------------------------------------------------- 1 | class node: 2 | def __init__(self,data): 3 | self.data=data 4 | self.next=None 5 | class linked_list: 6 | def __init__(self): 7 | self.head=None 8 | def insert(self,data): 9 | new_node=node(data) 10 | if self.head is None: 11 | self.head=new_node 12 | else: 13 | n=self.head 14 | while n.next!=None: 15 | n=n.next 16 | n.next=new_node 17 | def display(self): 18 | if self.head==None: 19 | print('list is emptry\n') 20 | else: 21 | print('printing elements in the list') 22 | n=self.head 23 | while n!=None: 24 | print(n.data,'',end='') 25 | n=n.next 26 | def drop(self): 27 | if self.head==None: 28 | print('\n list is empty deletion ot possible') 29 | else: 30 | print('\ndeleting element in the list\n') 31 | n=self.head 32 | while n.next.next!=None: 33 | n=n.next 34 | print('element deleted-->:',n.next.data) 35 | n.next=None 36 | print('') 37 | def find(self,key): 38 | if self.head==None: 39 | print('\n list is empty...element not found') 40 | else: 41 | n=self.head 42 | while n.next!=None: 43 | if n.data==key: 44 | print('element is found',n.data) 45 | return 46 | n=n.next 47 | print('element is not found') 48 | 49 | 50 | ob=linked_list() 51 | l=[10,20,30,40,50,60,70,80,90] 52 | for ele in l: 53 | ob.insert(ele) 54 | print('\n') 55 | ob.display() 56 | ob.drop() 57 | ob.find(60) 58 | ob.display() 59 | -------------------------------------------------------------------------------- /evenOdd.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | x = int(input('Enter an integer: ')) 4 | if x%2 == 0: 5 | print('') 6 | print('Even') 7 | else: 8 | print('') 9 | print('Odd') 10 | print('Done with conditional') 11 | -------------------------------------------------------------------------------- /expression.py: -------------------------------------------------------------------------------- 1 | num = 90 2 | num2 = 32 3 | 4 | expression1 = num + num2 5 | expression2 = num - num2 6 | expression3 = num * num2 7 | expression4 = num / num2 8 | expression5 = num % num2 9 | expression6 = num ** num2 10 | 11 | 12 | print(expression1) 13 | print(expression2) 14 | print(expression3) 15 | print(expression4) 16 | print(expression5) 17 | print(expression6) -------------------------------------------------------------------------------- /foo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jun 15 09:15:09 2016 4 | 5 | @author: ericgrimson 6 | """ 7 | 8 | x = 6 9 | 10 | if x != 5: 11 | print('i am here') 12 | else: 13 | print('no I am not') -------------------------------------------------------------------------------- /input.py: -------------------------------------------------------------------------------- 1 | #taking input marks 2 | 3 | marks = int(input("Enter marks: ")) 4 | if marks >= 90: 5 | print("Grade A") 6 | elif marks >= 80: 7 | print("Grade B") 8 | elif marks >= 70: 9 | print("Grade C") 10 | elif marks >= 60: 11 | print("Grade D") 12 | elif marks >= 50: 13 | print("Grade E") 14 | else: 15 | print("Grade F") 16 | -------------------------------------------------------------------------------- /lec1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ctoic/Python-For-Beginners/24f3bb00fb16ebcb9560a535e034144570431ef9/lec1.pdf -------------------------------------------------------------------------------- /naya.py: -------------------------------------------------------------------------------- 1 | #finding length of string built in function 2 | #len() function 3 | x = "kkkkkk" 4 | print(len(x)) 5 | -------------------------------------------------------------------------------- /nestedConds.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jun 8 11:07:33 2016 4 | 5 | @author: ericgrimson 6 | """ 7 | 8 | if x%2 == 0: 9 | if x%3 == 0: 10 | print('Divisible by 2 and 3') 11 | else: 12 | print('Divisible by 2 and not by 3') 13 | elif x%3 == 0: 14 | print('Divisible by 3 and not by 2') 15 | 16 | 17 | 18 | # creating a calculator in python using switch statements and function 19 | 20 | -------------------------------------------------------------------------------- /new.py: -------------------------------------------------------------------------------- 1 | def newfoo(number): 2 | if number % 2 == 0 : 3 | return number*number 4 | else if : 5 | return number+number 6 | print(newfoo(89)) 7 | 8 | -------------------------------------------------------------------------------- /operators.py: -------------------------------------------------------------------------------- 1 | # simple area of triangle circle and square 2 | 3 | # area of triangle 4 | def area_triangle(base, height): 5 | return 1/2 * base * height 6 | 7 | # area of circle 8 | def area_circle(radius): 9 | return 3.14 * radius ** 2 10 | 11 | # area of square 12 | def area_square(side): 13 | return side ** 2 14 | 15 | # area of rectangle 16 | def area_rectangle(length, width): 17 | return length * width 18 | 19 | # area of parallelogram 20 | def area_parallelogram(base, height): 21 | return base * height 22 | -------------------------------------------------------------------------------- /palindrome.py: -------------------------------------------------------------------------------- 1 | # checking ehweather a string is a palindrome or not 2 | check_palindrome = input("Enter a string: ") 3 | length = len(check_palindrome) 4 | for i in range(length): 5 | if check_palindrome[i] != check_palindrome[length - i - 1]: 6 | print("Not a palindrome") 7 | break 8 | else: 9 | print("Palindrome") 10 | 11 | def check_palindrome(string): 12 | length = len(string) 13 | for i in range(length): 14 | if string[i] != string[length - i - 1]: 15 | return False 16 | return True 17 | 18 | print(check_palindrome("madam")) 19 | print(check_palindrome("madam1")) -------------------------------------------------------------------------------- /password.py: -------------------------------------------------------------------------------- 1 | # password validation if len is greater than 6 valid 2 | 3 | password = input("Enter your password: ") 4 | if len(password) >= 6: 5 | print("Valid password") 6 | else: 7 | print("Invalid password") 8 | 9 | -------------------------------------------------------------------------------- /prob1.py: -------------------------------------------------------------------------------- 1 | # string_input=input("Enter a string: ") 2 | # for i in string_input: 3 | # if string_input[i] == 'a' or string_input[i]=='e' or string_input[i] == 'i' or string_input[i] == 'o' or string_input[i] == 'u': 4 | # count += 1 5 | # print("Number of vowels: " , count) 6 | 7 | 8 | string_input = input("Enter a string: ") 9 | count = 0 10 | for i in string_input: 11 | if i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u': 12 | count += 1 13 | print("Number of vowels: " , count) 14 | 15 | 16 | for i in range(10): 17 | for j in range(2): 18 | for k in range : 19 | print(i,j,k) 20 | 21 | # whats object in python explain with example 22 | 23 | 24 | -------------------------------------------------------------------------------- /programm.py: -------------------------------------------------------------------------------- 1 | pi = 3.14159 #constant 2 | 3 | radius = 2.2 4 | # area of circle 5 | area = pi*(radius**2) 6 | print('Area of circle with radius', radius, 'is', area) 7 | # Increment radius by 1 8 | radius = radius+1 9 | 10 | area_2 = pi*(radius**2) 11 | print('Area of circle with radius', radius, 'is', area_2) 12 | print(radius) 13 | -------------------------------------------------------------------------------- /pybot.py: -------------------------------------------------------------------------------- 1 | # creating a chat bot with openai gpt-3 2 | # 3 | import openai 4 | import os 5 | import json 6 | import random 7 | import time 8 | import datetime 9 | import requests 10 | openai.api_key = os.getenv("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") 11 | prompt = "Hellp my name is pybot. I am a chatbot. I am here to help you. What is your name?" 12 | response = openai.Completion.create( 13 | engine="davinci", 14 | prompt=prompt, 15 | temperature=0.9, 16 | max_tokens=150, 17 | top_p=1, 18 | frequency_penalty=0, 19 | presence_penalty=0.6, 20 | stop=["\n", " Human:", " AI:"] 21 | ) 22 | print(response) 23 | print(response["choices"][0]["text"]) -------------------------------------------------------------------------------- /reversestr.py: -------------------------------------------------------------------------------- 1 | strng = input("Enter a string: ") 2 | length = len(strng) 3 | 4 | # method 1 5 | for i in range(length): 6 | print(strng[length - i - 1], end = "") 7 | 8 | # method 2 9 | for i in range(length - 1, -1, -1): 10 | print(strng[i], end = "") 11 | 12 | # method 3 13 | print(strng[::-1]) 14 | 15 | # method 4 16 | print("".join(reversed(strng))) 17 | 18 | # method 5 19 | print("".join(strng[length - i - 1] for i in range(length))) 20 | 21 | # method 6 22 | print("".join(strng[i] for i in range(length - 1, -1, -1))) 23 | 24 | # method 7 25 | print("".join(strng[i] for i in reversed(range(length)))) 26 | 27 | # method 8 28 | print("".join(strng[i] for i in range(length))[::-1]) 29 | 30 | 31 | 32 | 33 | --------------------------------------------------------------------------------