Tuesday, 22 June 2021
SORTING DATAFRAME (BY COLUMN) IN PANDAS (Part-2) - PYTHON PROGRAMMING
Author June 22, 2021 Python No comments
MANIPULATING DATAFRAME IN PANDAS (ADD COLUMN , DROP COLUMN) || DATAFRAME MANIPULATIONS
Author June 22, 2021 Python No comments
SORTING DATAFRAME (BY COLUMN) IN PANDAS - PYTHON PROGRAMMING
Author June 22, 2021 Python No comments
#SORTING DATAFRAME (BY COLUMN) IN PANDAS
Monday, 21 June 2021
How do you generate random Password?
Author June 21, 2021 Python No comments
How do you reverse the string without take another string?
Author June 21, 2021 Python No comments
Sunday, 20 June 2021
INDEXING & SLICING DATAFRAMES IN PANDAS [PART 3]- PYTHON PROGRAMMING
Author June 20, 2021 Python No comments
INDEXING & SLICING DATAFRAMES IN PANDAS [PART 2]- PYTHON PROGRAMMING
Author June 20, 2021 Python No comments
INDEXING & SLICING DATAFRAMES IN PANDAS [PART 1]- PYTHON PROGRAMMING
Author June 20, 2021 Python No comments
MATHEMATICAL FUNCTIONS ON SERIES IN PANDAS [Boolean Functions] - PYTHON PROGRAMMING
Author June 20, 2021 No comments
MATHEMATICAL FUNCTIONS ON SERIES IN PANDAS [Part 1] - PYTHON PROGRAMMING
Author June 20, 2021 Python No comments
Saturday, 19 June 2021
OPERATIONS ON SERIES - PYTHON
Author June 19, 2021 Python No comments
ATTRIBUTES OF SERIES IN PANDAS - PYTHON PROGRAMMING
Author June 19, 2021 Python No comments
Join us: https://t.me/jupyter_python
DIFFERENT WAYS OF CREATING DATAFRAME IN PANDAS - PYTHON PROGRAMMING TWO (II)
Author June 19, 2021 Python No comments
DIFFERENT WAYS OF CREATING DATAFRAME IN PANDAS - PYTHON PROGRAMMING
Author June 19, 2021 Python No comments
Friday, 18 June 2021
How to find any vowels without using any loops
Author June 18, 2021 Projects, Python No comments
How do you find dayname of particular date of year?
Author June 18, 2021 Projects, Python No comments
Thursday, 17 June 2021
Print month of a year
Author June 17, 2021 Projects, Python No comments
How to create your own Dataset
Author June 17, 2021 Projects, Python No comments
How to make a text in python colorfull.
Author June 17, 2021 Projects, Python No comments
Join us: https://t.me/jupyter_python Like us: https://www.facebook.com/pirawenpython
How to use class and method without creating object
Author June 17, 2021 Projects, Python No comments
How do you find which string largest between two strings?
Author June 17, 2021 Projects, Python No comments
How to print only the special characters
Author June 17, 2021 Projects, Python No comments
Convert a number into scientific format
Author June 17, 2021 Projects, Python No comments
#Convert a number into scientific format
#clcoding
a = '{:.0e}' .format(1111111111111)
b = '{:.0e}' .format(2222222222222)
print(a)
print(b)
Join us: https://t.me/jupyter_python
Tuesday, 15 June 2021
Login with Retrofit in android Studio with SourceCode | Login and Registration form in android using JSON example
Irawen June 15, 2021 Android No comments
Build.gradle File:-
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.6.0'
Activity-main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:background="@color/colorWhite"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:text="Login to continue"
android:layout_marginTop="100dp"
android:textSize="24sp"
android:layout_gravity="center_horizontal"
android:textColor="@color/colorPrimaryDark"
android:layout_height="wrap_content" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_marginTop="30dp"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:hint="Username"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:inputType="text"
android:id="@+id/edUsername"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_marginTop="30dp"
android:hint="Password"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:inputType="textPassword"
android:id="@+id/edPassword"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_margin="30dp"
android:text="Login"
android:id="@+id/btnLogin"
android:background="@color/colorPrimary"
android:textColor="@color/colorWhite"
android:layout_height="wrap_content" />
</LinearLayout>
Java File :-
1. Api Client
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ApiClient {
private static Retrofit getRetrofit(){
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new OkHttpClient.Builder().addInterceptor(httpLoggingInterceptor).build();
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl("http://api.irawen.net/") //Change server URL
.client(okHttpClient)
.build();
return retrofit;
}
public static UserService getUserService(){
UserService userService = getRetrofit().create(UserService.class);
return userService;
}
}
2. Login Request :-
public class LoginRequest {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
3. Login response :-
public class LoginResponse {
private int user_id;
private String email;
private String username;
public int getUser_id() {
return user_id;
}
public void setUser_id(int user_id) {
this.user_id = user_id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
4. Main Activity :-
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.material.textfield.TextInputEditText;
import androidx.appcompat.app.AppCompatActivity;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainActivity extends AppCompatActivity {
TextInputEditText username, password;
Button btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username = findViewById(R.id.edUsername);
password = findViewById(R.id.edPassword);
btnLogin = findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(TextUtils.isEmpty(username.getText().toString()) || TextUtils.isEmpty(password.getText().toString())){
Toast.makeText(MainActivity.this,"Username / Password Required", Toast.LENGTH_LONG).show();
}else{
//proceed to login
login();
}
}
});
}
public void login(){
LoginRequest loginRequest = new LoginRequest();
loginRequest.setUsername(username.getText().toString());
loginRequest.setPassword(password.getText().toString());
Call<LoginResponse> loginResponseCall = ApiClient.getUserService().userLogin(loginRequest);
loginResponseCall.enqueue(new Callback<LoginResponse>() {
@Override
public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
if(response.isSuccessful()){
Toast.makeText(MainActivity.this,"Login Successful", Toast.LENGTH_LONG).show();
LoginResponse loginResponse = response.body();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(MainActivity.this,DashboardActivity.class).putExtra("data",loginResponse.getUsername()));
}
},700);
}else{
Toast.makeText(MainActivity.this,"Login Failed", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Call<LoginResponse> call, Throwable t) {
Toast.makeText(MainActivity.this,"Throwable "+t.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
});
}
}
5. User Service :-
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface UserService {
@POST("authenticate/")
Call<LoginResponse> userLogin(@Body LoginRequest loginRequest);
}
Sunday, 23 May 2021
DIGITAL CLOCK IN PYTHON
Author May 23, 2021 Python No comments
Sunday, 2 May 2021
Conversion of Hex, Oct, Bin numbers from integer using python
Author May 02, 2021 Python No comments
Monday, 26 April 2021
Let’s play with inheritance. What will be outputted?
Irawen April 26, 2021 C# No comments
class A
{
public void abc(int q)
{
Console.WriteLine("abc from A");
}
}
class B : A
{
public void abc(double p)
{
Console.WriteLine("abc from B");
}
}
static void Main(string[] args)
{
int i = 5;
B b = new B();
b.abc(i);
Console.ReadLine();
}
Answer :-
abc from B.
A typical polymorphism understanding swindle. The main thing is not to forget and overlook anything. What will be the result of execution of the following code?
Irawen April 26, 2021 C# No comments
class Program
{
static void Main(string[] args)
{
MyClassB b = new MyClassB();
MyClassA a = b;
a.abc();
Console.ReadLine();
}
}
class MyClassA
{
public MyClassA()
{
Console.WriteLine("constructor A");
}
public void abc()
{
Console.WriteLine("A");
}
}
class MyClassB:MyClassA
{
public MyClassB()
{
Console.WriteLine("constructor B");
}
public void abc()
{
Console.WriteLine("B");
}
}
Answer :-
constructor A
constructor B
A
During initialization of the B class, the constructor of the A class will be executed by default, then constructor of the B class. After assignment of the b value to a type variable of the A class, we will get an instance of the B class in it. One would think that abc() from the B class should be called, but since there is no specification of any predicate of the abc method in the B class, it hides abc from the A class. The example is not quite correct and abc() in the B class will be underlined, since the new predicate is required.
Friday, 23 April 2021
Print Color text in Python
Author April 23, 2021 Python No comments
Print Emoji's in Python
Author April 23, 2021 Python No comments
Popular Posts
-
Exploring Python Web Scraping with Coursera’s Guided Project In today’s digital era, data has become a crucial asset. From market trends t...
-
What does the following Python code do? arr = [10, 20, 30, 40, 50] result = arr[1:4] print(result) [10, 20, 30] [20, 30, 40] [20, 30, 40, ...
-
Explanation: Tuple t Creation : t is a tuple with three elements: 1 → an integer [2, 3] → a mutable list 4 → another integer So, t looks ...
-
What will the following code output? a = [1, 2, 3] b = a[:] a[1] = 5 print(a, b) [1, 5, 3] [1, 5, 3] [1, 2, 3] [1, 2, 3] [1, 5, 3] [1, 2, ...
-
What will the following Python code output? What will the following Python code output? arr = [1, 3, 5, 7, 9] res = arr[::-1][::2] print(re...
-
Through a recent series of breakthroughs, deep learning has boosted the entire field of machine learning. Now, even programmers who know c...
-
What will the following code output? import pandas as pd data = {'Name': ['Alice', 'Bob'], 'Age': [25, 3...
-
What will the output of the following code be? def puzzle(): a, b, *c, d = (10, 20, 30, 40, 50) return a, b, c, d print(puzzle()) ...
-
What will be the output of the following code? import numpy as np arr = np.array([1, 2, 3, 4]) result = arr * arr[::-1] print(result) [1, ...
-
Step-by-Step Explanation: Dictionary Creation: my_dict = {'a': 1, 'b': 2, 'c': 3} A dictionary named my_dict is crea...