Vedakeerthi / Python-programs

Repository about python and its programs are available.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python-programs

Repository about basic python and its programs are available.

  • Alice, bob
  • Fizz buzz
  • Alphabets
  • Number to words
  • Detecting vowels
  • Numpy operations
  • Two d array manipulation
  • Alarm clock
  • Basic calculator
  • BMI
  • Alarm clock.TK
  • BMI.TK
  • Calendar 2020.TK
  • Cash converter from rupees.TK
  • Date time module
  • Digital clock
  • Find the date after the given date
  • Number system converter
  • Password generator
  • Password generator.Tk
  • PY to EXE file conversion steps.Tk
  • Random number game
  • Random number game.Tk
  • Tables
  • Wikipedia module
  • Stone paper scissor.Tk

Alice, bob :

A simple hackerrank problem where two arrays have their elements and both the arrays are compared if the first array element is greater than that of the second array element then alice gets a point else bob gets a point, this is the description about the program.

Fizz buzz :

Another hackerrank problem, where a certain integer is taken as input, then it is passed to the fizzbuzz function. A for loop upto that integer is made to run and in between the range if a number is divisible by 3 it prints 'Fizz' else if it is divisible by 5 it prints 'Buzz' or if it is divisible by both 3 and 5, it prints as 'Fizzbuzz'.

Alphabets :

A simple creative program where a number is taken as input and added with 64 to display the number's specified alphabet for example if the number is 1 then it returns A, since we add it with 64 which is the ASCII values of alphabets, if the number is between 64 to 91, it prints the required alphabet else it prints as an invalid number. The alphabet is converted using a integer using the chr inbuilt function.

Number to words :

A beginner level program which is to convert the given number in terms of name, for example if 100, it should return one hundred. This program is implemented in two ways, one is by using the num2words module and the other by using user defined function. The module takes the input and return the words, whereas the function takes the integer and takes the name digit by digit, and return their names from the list specified. But the disadvantage is that it can only be done upto thousand digit, and not above that.

Detecting vowels :

A simple basic level program where a sentence is given as input and the number of vowels and the vowels are printed as output, the string is examined through a for loop if the word matches any of the vowel words then it is appended to an other list, which is then printed as output.

Numpy operations :

This numpy operations python file consists of a new module named numpy, which is used to mathematical operations and array related operations. The module is imported using the import statement, then an array is created and stored in a variable. This array is of one dimensional array, and then the basic operations on this array is performed, such as addition, subtration, multiplication, division and etc. Then a two dimensional array is declared and initialized in the variable b and the transpose of the array is printed. And thus some basic operations on an array is done.

Two D array manipulation :

A simple array operation program which is very helpful and handy, but the array is of 2D array. Here the array is created using the arange function where upto the declared value the array is created, and it is reshaped as 6x6 matrix. Once this is done the 4th and the 5th row of the matrix is extracted from the array. Next to that, an another 2d array is declared and stored in a variable, then the sum of the columns of the array is done using the sum function declaring that axis=0, which means it takes the columns not the rows.

Alarm clock :

A perfect intermediate project for all python programmers. The program takes input of all the necessary details like when to set the alarm like hours, minutes and am/pm. Then a while loop is made to run and if the hour and minutes are as same as the input then a music is made to play using the mixer function from the pygame module, then a notification is made to display on your pc using the notification function from the plyer module. This is how this program works, if the alarm is said to pm and hours is less than 12, then the hours is added with 12, since it uses railway timings.

Basic calculator :

A simple calculator executed in functions, the operations of the calculator includes, addition, subtraction, multiplication, division, power, modulus and factorial. The operations are executed using the if else statement.

BMI :

A python program to calculate the body mass index of a person, and if the bmi is lesser than or equal to 18.5 it prints you as thin, else if the bmi is greater than or equal to 25 then it will print as, that you are under an overweight condition else prints as that you are normal. The basic if, elif and else conditions are used.

Alarm clock.TK :

The same clock which is worked out on a GUI (Graphical user interface) platform, in python GUI models can be built using the tkinter module, here the tkinter module is used to get the base GUI which includes, font, filedialog box, the color, width and height of the api, then the datetime module is used to compare the timings with the entered timing. The plyer module is used to print the information entered by the user as information and the mixer function from the pygame module is used to play a song from the device to notify as alarm. This is how the alarm clock in GUI.

BMI.TK :

This is the same BMI program where GUI is used for the BMI calculation, the title is used to give the GUI a title, iconbitmap is used to give the icon for the GUI, and the geometry of the box are set. The different functions are used to get the input from the user as the entry column in the GUI, these inputs are then shared to the bmi function where the bmi is calculated and the result is printed as the messagebox option in GUI. Finally the window mainloop is used to tell the end of the GUI program.

Calendar 2020.TK :

An another GUI project where the windows are predefined and based on the user input of the year, this GUI prints the calendar of that particular year. The input is obtained from the Entry column of the GUI, once the input is obtained, the calendar module is used to print the calendar for the year, then using the label option in GUI, the calendar is printed. This is how the calendar GUI works.

Calendar.TK :

This is quiet similar to the previous program, but only the month of the particular year is printed, based on our GUI, we have preprocessed the title, iconbitmap, geometry and the background color of the window, once this all done, we deckare the font, the label to get the year, this input is obtained using the entry column and stored in the n variable, once this done, next to that the month, we use the combobox for the user to give the month as input, so the other input is also obtained, now the same calendar module is used to get the month particulary, this then printed using the label option is the GUI.

Cash converter form rupees.TK :

An intermediate GUI project, where the window is preprocessed, then the font and we use a list to specify the selected currencies that a rupees can be converted to, then these are available in the combobox. The user ask for the indian rupees as input and converts it to the selected foreign currencies from the combobox. Once the button convert is pressed it commands to the function, then the function get the input from the rupees and the foreign currency then compares and outputs the result based on the converted rupees.

Date time module :

This program is uplooaded to learn the essentials of the Date time module, using date time module, the date and time data can be handled in python, here from installing the module to learning some important functions are studied.

Digital clock :

As we studied about the datetime module, now lets combine our learning in the datetime and the tkinter module and the outcome of the learning, here comes the digital clock program, where the window pre requirements are declared and the font for the window are optimized, then a label is made in the window to show the current timing, the time function is where the current time from the date time module is executed and printed in the label of the window.

Find the date after the given date :

A simple GUI concept where the date after the given date is printed, the window pre processing are done, then the current date is taken as input from the user and stored in the variable n, next to that when the 'GET DATE' function is pressed it moves to the gd function then using the timedelta function the date after the given date is calculated and printed as a label to the window, then this window is exited using the mainloop function.

Number system converter :

An intermediate program to convert the decimal system to binary, octal, and hexa decimal. Python functions are used, here for a single input of a specific system, the other three systems are printed as output. The program starts from the main function, so a while loop is made to run without a stopping condition, for the user to run endlessly. For the users int input different functions are made to run. In case of converting decimal to binary and the other three, a specific function is executed, the bin, oct and hex inbuilt functions are used to for conversion of the other three. Likewise different operations are made for the conversion.

Password generator :

The password generator is used to generate passwords randomly, based on the number of length of the password length, the password length is specified by the user. The characters of the password are specified such as the numbers, lower case letters, higher case letters, and the symbols for the password, then these string values are concatenated together. The random module is used to select the string values randomly as a password, and finally the password is printed.

Password generator. Tk :

The same password generator program but it is executed in a GUI. As similar to the other programs, the window is updated and label and a entry option is used in the window to print the password length and to get the int input of the length of the password. Then a radiobutton is used to check if numbers need to added, small case letters need to be added, large case letters need to be added or symbols need to be added, based on the selection of radio buttons, the characters are used in the password. Then using the get password button the password is printed using a label. Finally the window is closed using the mainloop function.

PY to EXE file conversion steps. Tk :

The step by step process of converting a py python file to executable file, exe file using window powershell is performed step by step. These steps are printed in the GUI window using the label option. Perform these steps to get an exe file of the python file.

Random number game :

A simple game, where we need to guess the numbers which have a range from 1 to 10. The user is made to guess the number and the guessed number and the random number is checked if the random number is equal to the guessed number then we print as 'Yay!! you did it'', else if the random number is close to the guessed number then it is printed as 'Soo close' and we display the number, else we print as 'Try again', the random number of the particular range is given by the randint function in the random module.

Random number game. Tk :

The same game which implemented in python is now implemented on a GUI, as known the window is preprocessed first, then the essential input or the number to be guessed is taken as input from the user using the entry option, then label and a button is used, once the button is pressed, then the function is executed where the guessed number and the random number generated by the random module are compared and the final result is printed as a messagebox to the user.

Tables :

A simple python program to print the mathematical tables of a particular integer input from the user, like the same way we studied the mathematical table in lower classes, for the particular input, the input is made to run in a for loop which is multiplied till 20.

Wikipedia module :

A full glance and the important functions about the wikipedia module is learned, the program starts with installing the module, then importing it, then a summary about a particular topic is searched and printed upto the selected sentences. Meanwhile the page function is used to get the things that are present in the page of the particular topic, we can get the html format, title and even the image of the page. The wikipedia module also consists of a very useable and important function name set_lang function using which we can set the language and the summary can be of the language which is set.

Stone paper scissor.Tk :

A simple GUI project where, the computer is automated to play with you, once you give your input and the computer's random choice, this game is played, being a GUI project tkinter module in python is used. So the window's preprocessing has been declared, then the user is made to input either stone, paper or scissor from the combobox column, then this input is stored in the n variable, once this happens, the spin button is pressed, then the program executes the function sps, where path of the stone, paper and scissor images are stored in a list. Now the computer is made to select any one of them randomly, and based on the comparison, the result will be displayed in a label. While our input in combobox, the random output of the computer will be in image format, that's why we use photoimage function in the module. This is how the stone, paper and scissor game is played in the computer.

About

Repository about python and its programs are available.

License:MIT License


Languages

Language:Python 100.0%