Skip to content

stellarcompiler/Public-repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Directory structure: └── stellarcompiler-public-repo.git/ β”œβ”€β”€ CalculatorP.py β”œβ”€β”€ date_time.py β”œβ”€β”€ Dictionary.ipynb β”œβ”€β”€ intro.txt └── string_test.py

Files Content:

================================================ FILE: CalculatorP.py

op=["Add (+)","Subtract (-)","Division (/)","Multiply ()"] i=0 x=eval(input("input1 :")) y=eval(input("input2 :")) print("Select the operator") for i in range(len(op)): print (op[i]) ch="" ch=input("Operator :") print("Selected operation :" ,ch) if (ch=="+"or ch=="add"or ch=="Add"): sum=x+y print("Total sum :",sum) elif (ch=="-"or ch=="Sub"or ch=="sub"or ch=="Subtract"or ch=="subtract"): diff=x-y print("Difference :",diff) elif (ch=="/"or ch=="Div"or ch=="div"or ch=="Division"or ch=="division"): div=x//y rem=x%y print("Quotient :",div) print("Remainder :",rem) elif (ch=="" or ch=="mul" or ch=="Mul"): m=x*y print("Multiplied :",m) else: print("ERROR 400 BAD REQUEST")

================================================ FILE: date_time.py

import datetime as dt date= dt.date.today() print(date.day ,"/" ,date.month, "/", date.year) print("October","", date.day,"",date.year)

time=dt.time(10,30,55,4565) print(time)

================================================ FILE: Dictionary.ipynb

Jupyter notebook converted to Python script.

""" Open In Colab """

"""

Example For Sets:

"""

set1={"apple","kiwi","Cherry","Durian"}

print(set1)

for i in set1: print(i)

Output:

{'Cherry', 'kiwi', 'Durian', 'apple'}

Cherry

kiwi

Durian

apple

"""

πŸ‘† This shows us that Sets does not support indexing

"""

set2={5,3,8,2,1,5,10,8,9,10}

print(set2)

for i in set2: print(i)

Output:

{1, 2, 3, 5, 8, 9, 10}

1

2

3

5

8

9

10

"""

This shows us the set are unordered**(UNIQUE)** or reduces redundancy

"""

"""

EXAMPLES FOR DICTIONARIESπŸ“– IN PYTHON :

"""

"""

Storing Info of a Book:

"""

book={"Title":"ATOMIC HABITS","Author":"James Clear","Year":"2018"} print(book["Title"]) print(book["Author"]) print(book["Year"])

"""

Example for storing Student Info:

"""

student_01={"First name":"Arthur","Last name":"Morgan","Roll No":"01","Class":"C1SB"}

print("Name :",student_01["First name"]+" "+student_01["Last name"])

print("Roll Number :",student_01["Roll No"])

print("Class :",student_01["Class"]) print("\n")

for key in student_01: print(key,":",student_01[key])

Output:

Name : Arthur Morgan

Roll Number : 01

Class : C1SB

First name : Arthur

Last name : Morgan

Roll No : 01

Class : C1SB

"""

Adding Values:

dictionary_name[Key]=value πŸ‘ˆ This adds this key-value pair to the end of dictionary

"""

user={'name': 'Alice', 'age': 25}

user['city']='Ernakulam'

print(user)

Output:

{'name': 'Alice', 'age': 25, 'city': 'Ernakulam'}

"""

.update(other_dictionary) :

For Updating the values inside Dictionary:

use : dictionary_name.update({other dictionary})

"""

user = {'name': 'Alice', 'age': 25}

user.update({'age':30,'city': 'New York'})

print(user)

Output:

{'name': 'Alice', 'age': 30, 'city': 'New York'}

"""

.get() :

For Pulling the values from a Dictionary:

use: dict_name.get(Key, default_value)

"""

user= {'name': 'Alice', 'age': 25}

print(user.get('name'))

print(user.get('city','Not Found'))

Output:

Alice

Not Found

"""

.pop() :

For Deleting a key-value pair and returning the value

use: user.pop(key,default)

"""

user= {'name': 'Alice', 'age': 25,'city':'Ernakulam'}

print(user.pop('city'))

print(user)

Output:

Ernakulam

{'name': 'Alice', 'age': 25}

"""

.popitem() :

Used to delete the element from the end and return the Key-value pair

Use: dict_name.popitem()

"""

user= {'name': 'Alice', 'age': 25,'city':'Ernakulam'}

print(user.popitem()) print(user)

Output:

('city', 'Ernakulam')

{'name': 'Alice', 'age': 25}

"""

.del()

To simply delete a Key-value pair

Syntax: del dict_name(key)

"""

user= {'name': 'Alice', 'age': 25,'city':'Ernakulam'} del user['city'] print(user)

Output:

{'name': 'Alice', 'age': 25}

"""

.copy() :

Returns a copy of a dictionary to another dict. variable

syntax: variable=dict_name.copy()

"""

user= {'name': 'Alice', 'age': 25,'city':'Ernakulam'}

user_copy=user.copy() print(user_copy)

Output:

{'name': 'Alice', 'age': 25, 'city': 'Ernakulam'}

"""

.items():

It returns a view of the dictionary in Key Value tuple pairs

"""

user= {'name': 'Alice', 'age': 25} print(user.items())

Output:

dict_items([('name', 'Alice'), ('age', 25)])

"""

'IN' KEYWORD

We can check if a key is present inside a dictionary using 'IN' keyword - which returns a boolean ('T' or 'F')

"""

user= {'name': 'Dhishu', 'age': 25} print('name' in user) print('city' in user)

Output:

True

False

"""

Iterating through Dictionary:

We can use 'for' loop to iterate through a dictionary by using the key

"""

user= {'name': 'Aurora', 'age': 25,'city':"Ernakulam"}

for key in user: print(key,":",user[key])

Output:

name : Aurora

age : 25

city : Ernakulam

"""

Nested Dictionaries

As the name suggest, we can write a dictionary within another dictionary.

###inside a dictionary - we can write another dictionary as a "value" Example code πŸ‘‡ """

Students={'stud1':{'name':'Abel','Roll no':1},'stud2':{'name':'Abhiram','Roll no':2} }

print(Students) print(Students['stud1']) print(Students['stud1']['name'])

Output:

{'stud1': {'name': 'Abel', 'Roll no': 1}, 'stud2': {'name': 'Abhiram', 'Roll no': 2}}

{'name': 'Abel', 'Roll no': 1}

Abel

================================================ FILE: intro.txt

Welcome to git and github

(i). Git and Github are version control system that can track Changes to a file and control the file dynamics
(ii). Git and Github and separate systems - 
    Git is a local version control systems
    Github is a cloud based version control system

HOW TO USE GIT AND GITHUB:

Step 1: Git Configuration > Install Git and create a github User profile > Enter to command prompt and Configure Git by [git config --global user.name "github username" git config --global user.mail "Enter the email used for Github"] > Check the status of git by [git config --list] > Exit and go to your local repository(Desired folder), and open a terminal on that folder. > Open Visual Studio Code (VS CODE) by ["code ."] > Initialise Git in terminal [git init] > Open a file [.txt, .py, .js, etc....]

   End of Step 1

Step 2: Adding and Commiting > Type in terminal : git add . (for adding a group of files) or git add > After "add" command the files go for staging > For checking the staging : type git status > Type git commit -m "Type any message" for commiting it into the local repository > type git log for the commit status and Commit "Hash" > Now the file is stored in the local repository

End of Step 2

Step 3: Pushing the file to Github > Type git remote add origin <"The github repo url"> for acknowledge the git about cloud repo > Type git remote -v for init status > Type git push origin for uploading > Check on github repo for file updation

================================================ FILE: string_test.py

ch="" str1="" ch=input("Enter any string :\n") str1=input("Enter any string :\n")

out1=ch.upper() out2=ch.lower() str2=ch+" "+str1 print("Extract substring") x=int(input("From :")) y=int(input("To :")) char=ch[x:(y+1)]

print("Uppercase :",out1) print("Lowercase :",out2) print("Concatenation Operation :",str2) print("Extracted Substring :",char)

About

Public accessible files here πŸ‘‡

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published